egg-console
v2.0.1
Published
Egg.js plugin to make your debug more easier.
Downloads
446
Maintainers
Readme
egg-console
This plugin works like morgan, prints all request & result both to console and local file.
Generally, it prints [$userId/$ip/$traceId/${cost}ms $method $url] $status
. If there's an error, it will print the error attached. If the config.consoleLevel
is set to debug
, it will prints the request body as json format attached.
This plugin needs egg-logger which is a built-in plugin of egg.js. It bases on ctx.logger
, so the options of it will also impact this plugin.
info Mode
debug Mode
Install
NPM
$ npm i egg-console --save
yarn
$ yarn add egg-console
Usage
// {app_root}/config/plugin.js
exports.console = {
enable: true,
package: 'egg-console',
};
Configuration
// {app_root}/config/config.default.js
exports.console = {
// both default true in local env and false in prod env.
debug: true,
error: true,
};
debug: In this set the plugin will print the request body.
error: If false, the plugin will not print the error's stack. You should check the common-error.log
for details of error.
see config/config.default.js for more detail.