koa-logger
Logging middleware for koa
Last updated 8 years ago by coderhaoxin .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install koa-logger 
SYNC missed versions from official npm registry.

koa-logger

npm version build status

Development style logger middleware for koa. Compatible with request-received.

Notice: koa-logger@2 supports koa@2; if you want to use this module with koa@1, please use koa-logger@1.

<-- GET /
--> GET / 200 835ms 746b
<-- GET /
--> GET / 200 960ms 1.9kb
<-- GET /users
--> GET /users 200 357ms 922b
<-- GET /users?page=2
--> GET /users?page=2 200 466ms 4.66kb

Installation

$ npm install koa-logger

Example

const logger = require('koa-logger')
const Koa = require('koa')

const app = new Koa()
app.use(logger())

Notes

Recommended that you .use() this middleware near the top to "wrap" all subsequent middleware.

Use Custom Transporter

const logger = require('koa-logger')
const Koa = require('koa')

const app = new Koa()
app.use(logger((str, args) => {
  // redirect koa logger to other output pipe
  // default is process.stdout(by console.log function)
}))

or

app.use(logger({
  transporter: (str, args) => {
    // ...
  }
}))

Param str is output string with ANSI Color, and you can get pure text with other modules like strip-ansi
Param args is a array by [format, method, url, status, time, length]

License

MIT

Current Tags

  • 3.2.1                                ...           latest (5 years ago)
  • 2.0.1                                ...           next (8 years ago)

16 Versions

  • 3.2.1                                ...           5 years ago
  • 3.2.0                                ...           7 years ago
  • 3.1.0                                ...           7 years ago
  • 3.0.1                                ...           7 years ago
  • 3.0.0                                ...           8 years ago
  • 2.0.1                                ...           8 years ago
  • 1.3.1                                ...           8 years ago
  • 2.0.0                                ...           9 years ago
  • 1.3.0                                ...           9 years ago
  • 1.2.2                                ...           10 years ago
  • 1.2.1                                ...           11 years ago
  • 1.2.0                                ...           11 years ago
  • 1.1.1                                ...           11 years ago
  • 1.1.0                                ...           11 years ago
  • 1.0.1                                ...           11 years ago
  • 1.0.0                                ...           11 years ago
Downloads
Total 3
Today 1
This Week 1
This Month 2
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (13)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE