koa-ctx-logger

1.1.2 • Public • Published

koa-ctx-logger

npm version

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

Package Sidebar

Install

npm i koa-ctx-logger

Weekly Downloads

23

Version

1.1.2

License

MIT

Unpacked Size

7.22 kB

Total Files

4

Last publish

Collaborators

  • gabzarp