New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bunlogger

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bunlogger

bunyan logger middleware for express/connect

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

bunlogger

express middleware powered by bunyan

Installation

$ npm install bunlogger --save

Features

  1. error log and access log share the same cor_id, so you can associate the error log to the access log happened at the same time.
  2. req.log is actually the bunyan logger, simply req.log.info('...') will share the same cor_id in the access log and error log.
  3. elapsed show the time spent in this req.

Usage

var pkg = require('../package.json'),
    bunlog = require('bunlogger'),
    express = require('express'),
    path = require('path');
    
// set up app
//===============
var app = express(),
    logger = app.logger = app.get('env') === 'production' ?
        bunlog({name: pkg.name, path : path.resolve(__dirname, 'log', pkg.name)}) :
        bunlog({name: pkg.name});
        // logging to a file in production environment or logging to process.stdout 

// as a middleware
app.use(logger.connect());

// as an error middleware
app.use(logger.error());

.....
// Example : logging in a request
function(req, res){
	auth.authenticate(req.body.username, req.body.password, function(err, user){
		if(err || !user){
			req.log.warn(err, 'login error %s', err);
			...
			return res.redirect('/login');
		}
		
		....
	}
}

FAQs

Package last updated on 05 Aug 2014

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