service-logging
v2.0.2
Published
Utilities for service logging
Downloads
2
Readme
Service Logging
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 namestreams
- Bunyan streams to write to (takes an array, not a function)serializers
- (Optional) Additional Bunyan serializersversion
- (Optional) Version object to include in logs