1.1.2 • Published 5 years ago

koa-ctx-logger v1.1.2

Weekly downloads
7
License
MIT
Repository
github
Last release
5 years ago

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

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.1.0

5 years ago