egg-console

2.0.1 • Public • Published

egg-console

NPM version build status Test coverage David deps Known Vulnerabilities npm download

中文版

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.

License

MIT

Package Sidebar

Install

npm i egg-console

Weekly Downloads

57

Version

2.0.1

License

MIT

Last publish

Collaborators

  • brickyang