Improved version of koa-logger that saves logs to a /logs/log file, sends ctx.body on logs and has logs functions that you can call inside your context.
$ npm install koa-ctx-logger
const logger = require('koa-ctx-logger');
app.use(logger());
This will automatically log requests and responses in your console and in /logs/log.log file
Log example:
<-- PUT /send-lead
--> PUT /send-lead 500 111ms 66b {"shopId":["shopId is required but was either undefined or null"]}
To call log service in another part of your application simply call logger in your ctx:
ctx.logger.info('your string')
To get log:
INFO: your string
Or:
ctx.logger.error('your string')
To get:
ERROR: your string
MIT