Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sails-bunyan-cls

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sails-bunyan-cls

CLS integration for Bunyan for sails.js

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

sails-bunyan-cls

A module modifying the sails-bunyan logger to support adding context with CLS. Support sails 0.10.x.

To use, simply initialize the logger in config/bootstrap.js after injecting with sails-bunyan.

var createNamespace = require('continuation-local-storage').createNamespace;
var injectBunyan = require('sails-bunyan').injectBunyan;
var ns = createNamespace('mynamespace');
var initializeCls = require('sails-bunyan-cls').initialize;

module.exports.bootstrap = function (done) {
  injectBunyan();
  initializeCls(ns);
  done();
}

To add context, use sails.log.addContext.

function processRequest(params) {
    sails.log.info('About to fetch widget.');

    fetchWidget(params, function onWidgetChosen(widget) {
        sails.log.addContext({widget: widget});
        sails.log.info('Got widget successfully.');
    });
}

Log output looks like this.

{"name":"myapp","hostname":"myhost","pid":34572,"level":30,"msg":"start","time":"2013-01-04T07:47:25.814Z","v":0}
{"name":"myapp","hostname":"myhost","pid":34572,"widget":{widgetType: "foo"},"level":30,"msg":"creating a wuzzle","time":"2013-01-04T07:47:25.815Z","v":0}

Keywords

FAQs

Package last updated on 12 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc