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

bunyan-node-logger

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

bunyan-node-logger

a simple bunyan based logger

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

#bunyan-node-logger A simple bunyan based logger for Node.js

Install

npm install bunyan-node-logger

Usage

Site configuration

Define the sitewide application id and log level

require('../dist').configure({
  appId: 'TestApp',
  level: 'debug'
});

###Log messages Create a logger instance

const Logger = require('bunyan-node-logger').default;
const l = new Logger('MyModules');

Log messages

l.info('main', {id: 1, name: 'sam'});
l.error('main', 'yikes!!!');

API

Methods

methodparams
error(method: string, msg: any)
warn(method: string, msg: any)
info(method: string, msg: any)
debug(method: string, msg: any)
trace(method: string, msg: any)

Parameters

method is the method name e.g. 'myMethod'

msg is the message to log. it can be any js primitive, object, or array e.g. {id: 'test', arr: [1,2,3], b: true}

Run the example

This repo contains a simple example. To run it, execute:

node examples/ex1.js

Example

Below is a simple example. See exmples/ex1.js

const Logger = require('bunyan-node-logger').default;
// configure the app wide log level and app name
require('bunyan-node-logger').configure({
  appId: 'TestApp',
  level: 'debug'
});

// Example class with its own logger
class MyClass {
  constructor() {
    this.l = new Logger(this.constructor.name);
  }
  myMethod() {
    this.l.debug('myMethod', {key: 'value'});
  }
}

####output:

{"name":"TestApp","hostname":"Carmines-MacBook-Pro-7.local","pid":18620,"level":30,"module":"MyApp","method":"main","msg":"my app is starting","time":"2016-09-28T00:58:19.688Z","v":0}
{"name":"TestApp","hostname":"Carmines-MacBook-Pro-7.local","pid":18620,"level":20,"module":"MyClass","method":"myMethod","msg":"{ key: 'value' }","time":"2016-09-28T00:58:19.689Z","v":0}
{"name":"TestApp","hostname":"Carmines-MacBook-Pro-7.local","pid":18620,"level":30,"module":"MyApp","method":"main","msg":"my app is finished","time":"2016-09-28T00:58:19.689Z","v":0}

##License MIT

Keywords

FAQs

Package last updated on 28 Sep 2016

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