Egg.js plugin to make your debug more easier.
npm install egg-console[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][codecov-image]][codecov-url]
[![David deps][david-image]][david-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]
[![npm download][download-image]][download-url]
[npm-image]: https://img.shields.io/npm/v/egg-console.svg?style=flat-square
[npm-url]: https://npmjs.org/package/egg-console
[travis-image]: https://img.shields.io/travis/brickyang/egg-console.svg?style=flat-square
[travis-url]: https://travis-ci.org/brickyang/egg-console
[codecov-image]: https://img.shields.io/codecov/c/github/brickyang/egg-console.svg?style=flat-square
[codecov-url]: https://codecov.io/github/brickyang/egg-console?branch=master
[david-image]: https://img.shields.io/david/brickyang/egg-console.svg?style=flat-square
[david-url]: https://david-dm.org/brickyang/egg-console
[snyk-image]: https://snyk.io/test/npm/egg-console/badge.svg?style=flat-square
[snyk-url]: https://snyk.io/test/npm/egg-console
[download-image]: https://img.shields.io/npm/dm/egg-console.svg?style=flat-square
[download-url]: https://npmjs.org/package/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

bash
$ npm i egg-console --save
`
$3
`bash
$ yarn add egg-console
`
Usage
`js
// {app_root}/config/plugin.js
exports.console = {
enable: true,
package: 'egg-console',
};
`Configuration
`js
// {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.