1.0.6 • Published 3 years ago

wikibit-winston-log v1.0.6

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

wikibit-winston-log

这是一个 NUXT 项目的依赖于 winston 的插件

使用方法:

  1. 直接注入到 nuxt 项目 nuxt.config.js文件 modules选项下
  2. 参数实例 { logPath: './log' } logPath 参数为日志路径 默认为./log 在开发环境(windows 环境下设置不生效,强制为./log
modules: [
    ['wikibit-winston-log', { logPath: './log' }],
  ],

日志将会默认输出在 ./logs/{NODE_ENV}.log 或者是你自定义的目录下 但是在开发环境(windows 环境下设置不生效,强制为./log

引用方法

  1. Install npm package
$ yarn add wikibit-winston-log # or npm i wikibit-winston-log
  1. 根据需要使用$winstonLog 键更改选项。有关详细信息,请参见示例:
if ($winstonLog) {
  // $winstonLog只在服务端存在,需要判断是否存在
  $winstonLog.error(
    `[status:${err.status}] |errCode:${err.code}| url:${err.config.url} | message:${err.message}`
  )
}

Usage

  1. 配置

    // ...
    {
      // Path that log files will be created in.
      // Change this to keep things neat.
      logPath: './logs',
    
      // Name of log file.
      // Change this to keep things tidy.
      logName: `${process.env.NODE_ENV}.log`,
    
      // Setting to determine if filesystem is accessed to auto-create logPath.
      // Set this to `false` for non-filesystem based logging setups.
      autoCreateLogPath: true,
    
      // Setting to determine if default logger instance is created for you.
      // Set this to `false` and provide `loggerOptions` (usage item #3) to
      // completely customize the logger instance (formatting, transports, etc.)
      useDefaultLogger: true,
    
      // Settings to determine if default handlers should be
      // registered for requests and errors respectively.
      // Set to `true` to skip request logging (level: info).
      skipRequestMiddlewareHandler: false,
      // Set to `true` to skip error logging (level: error).
      skipErrorMiddlewareHandler: false
    }
    // ...

Changelog

1.0.2

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago