koa-ctx-logger
v1.1.2
Published
Logging middleware for koa
Downloads
116
Readme
koa-ctx-logger
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.
Installation
$ npm install koa-ctx-logger
How to use
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
License
MIT