This package has been deprecated

Author message:

this package has been deprecated

koa-logging

0.1.0 • Public • Published

koa-logging

install

$ npm install --save koa-logging

example

var koa = require("koa");
var app = koa();
 
var logger = require(".");
app.use(logger());
 
app.use(function*() {
    this.log.info({
        logId: this.logId,
        msg: "hello world"
    });
});
 
app.listen(8000);
$ node --harmony example.js | ./node_modules/bunyan/bin/bunyan &
$ curl http://localhost:8000/ &> /dev/null
[2015-01-25T14:01:52.125Z]  INFO: yet-another-koa-app/45527 on localhost:  (logId=fa3d4c0f-5538-41ef-930d-3401527b8023, message="hello world")
[2015-01-25T14:01:52.135Z]  INFO: yet-another-koa-app/45527 on localhost: response (logId=fa3d4c0f-5538-41ef-930d-3401527b8023, start=1422194512124, ctx=null, responseTime=9ms, contentLength=9b, req.remoteAddress=::ffff:127.0.0.1, req.originalUrl=/)
    GET / HTTP/1.1
    user-agent: curl/7.37.1
    host: localhost:8000
    accept: */*
    --
    HTTP/1.1 404 Not Found
    content-type: text/plain; charset=utf-8
    content-length: 9
$ fg
^C

options

var app = require("koa")();
var logger = require("koa-logging");
 
var opts = {
    name: "yet-another-koa-app", // log name
    logRequest: false, // log request
    logResponse: true, // log response
    logError: true, // log error
    serializers: {}, // bunyan serializers, { logId, req, res, ctx, err, start, responseTime, contentLength }
    bunyanArgs: {} // other bunyan arguments
};
 
app.use(logger(opts));

license

MIT

Package Sidebar

Install

npm i koa-logging

Weekly Downloads

4

Version

0.1.0

License

MIT

Last publish

Collaborators

  • npm