Giter VIP home page Giter VIP logo

logger's Issues

分离 format for console and file

如果 console output 设置了颜色,也会同时作用到文件中。

export interface LoggerOptions {
    /**
     * Output format for console and file
     */
    format?: LoggerContextFormat;
}

日志输出被格式化两遍

  • Node Version: 18.5.0
  • Midway Version(Decorator/Core): 3.3.6
  • Component Name/Version: @midwayjs/[email protected]
  • Platform:
  • Mini Showcase Repository:
logger.info('%s', '%Y-%m-%d')
// 应该输出
// %Y-%m-%d
// 实际输出
// %Y-%m-NaN

在@midwayjs/logger中使用util.format%s部分格式化一遍,然后到了winston里又被splat格式化了一遍,导致日志中输出错误。

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/nodejs.yml
  • actions/checkout v4
  • actions/setup-node v4
  • codecov/codecov-action v4
npm
package.json
  • dayjs ^1.10.7
  • safe-stable-stringify ^2.4.3
  • @types/jest 29
  • @types/node 20.11.30
  • benchmark ^2.1.4
  • cross-env 7.0.3
  • fs-extra 11.2.0
  • jest 29
  • mwts 1.3.0
  • threads 1.7.0
  • ts-jest 29
  • ts-node 10.9.2
  • typescript 5.4.3
  • node >=10

  • Check this box to trigger a request for Renovate to run again on this repository

为标准输出禁用 ansi 提供进程内的显式配置项

容器运行时基于标准输出 -> log driver 的日志采集方式, 由于 ansi 的格式化, 导致采集日志的 agent 解析出现预期外的结果, 当前仅支持环境变量控制, 但 k8s 等环境的配置本身对于业务方来讲, 可控性不强.

且本场景理论上来说可能会因为不同的运行环境有差异, 比如本地开发环境依然是有意义的, 所以提供显式的配置项, 可针对不同的 profile 做相应的处理.

实际输出

^[[0m2022-08-01 21:57:13,543 INFO 75979 xxx^[[0m

基于 containerd + fluent-bit 的解析器

[PARSER]
    # http://rubular.com/r/tjUt3Awgg4
    Name cri
    Format regex
    Regex ^(?<time>[^ ]+) (?<stream>stdout|stderr) (?<logtag>[^ ]*) (?<message>(.|\n)*)$
    Skip_Empty_Values false
    Time_Key    time
    Time_Format %Y-%m-%dT%H:%M:%S.%L%z

自定义日志设置日志格式化不生效

midwayLogger: {
    default: {
      transports: {
        file: {
          maxSize: '100m',
          // 也可以配置数字,表示最多保留日志文件的个数。
          maxFiles: '10d',
        },
        error: {
          maxSize: '100m',
          maxFiles: '10d',
        },
      }
    },
    clients: {
      coreLogger: {
        fileLogName: 'core.log',
      },
      appLogger: {
        fileLogName: 'app.log',
      },
      // bull的日志文件名
      bullLogger: {
        fileLogName: 'bull.log',
      },
      customLogger: {
        fileLogName: 'custom.log',
        contextFormat: (info) => {
          const ctx = info.ctx;
          console.log("++++++++++++++++")
          console.log(`${info.LEVEL} ${info.timestamp} ${info.message}`)
          return `${info.LEVEL} ${info.timestamp}  ${info.message}`;
        }
      },
    }
  },

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.