npm.io
1.0.0 • Published 5 years ago

egg-format-logger

Licence
—
Version
1.0.0
Deps
2
Size
6 kB
Vulns
0
Weekly
0

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
property description
ctx Egg.Context
paddingMessage Part of the request information, including the domain name, request time, request method
level The level of logging
date The current time
pid The process ID
hostname The host name
message Log information to be printed

License

MIT

Keywords