2.0.2 • Published 10 years ago

service-logging v2.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
10 years ago

Service Logging

NPM

Build Status

Does some logging bootstrapping with Bunyan and basic serializers and exposes Connect middleware to wire up logging in a service.

Usage

var express = require('express'),
  myStreams = require('./my-streams'),
  logging = require('service-logging')({
    name: 'my-service',
    environment: 'dev',
    streams: myStreams
  });

var app = express();
app.use(logging.attachLoggerToReq); // adds req.logger
app.use(logging.logResponses);
app.use(function(req, res, next) {
  req.thing = 'otherThing';
  next();
});
app.use(logging.attachToLogger('thing')); // {thing: 'otherThing'} is now added to future req.logger calls
app.get('/', function(req, res) {
  res.send('Hello!');
});
app.use(logging.logErrors);

Configuration

The following options are exposed on the context:

  • environment - A description of the environment (e.g., dev, staging)
  • name - The service's name
  • streams - Bunyan streams to write to (takes an array, not a function)
  • serializers - (Optional) Additional Bunyan serializers
  • version - (Optional) Version object to include in logs
2.0.2

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago