service-logging

2.0.2 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i service-logging

Weekly Downloads

12

Version

2.0.2

License

MIT

Last publish

Collaborators

  • jeffreycharles