1.0.0 • Published 3 years ago

egg-format-logger v1.0.0

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

egg-format-logger

English | 简体中文

Introduced

An egg plugin for formatting logs. This plugin and egg-logger to work together.

Install

npm i egg-format-logger --save

Configuration

Change ${app_root}/config/plugin.js to to enable this plugin.

exports.formatLogger = {
  enable: true,
  package: 'egg-format-logger',
};

Configure information in ${app_root}/config/config.default.js

config.formatLogger = {
  formatter: (meta) => {
    return  `[${meta.date}][${meta.pid}][${meta.level}][${meta?.ctx?.response?.status}]::${meta.message}`;
  }
}

Meta

propertydescription
ctxEgg.Context
paddingMessagePart of the request information, including the domain name, request time, request method
levelThe level of logging
dateThe current time
pidThe process ID
hostnameThe host name
messageLog information to be printed

License

MIT