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

logwrangler

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logwrangler

Wrangle up your logging

  • 0.1.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

logwrangler is a module logging system that you can easily extend to add various logging locations and functions.

Install

npm install --save logwrangler

Use

Logging to stdout

var logwrangler = require('../index');
var logger = logwrangler.create();

logger.log({
	level: logger.levels.INFO,
	ns: 'web server',
	message: 'some log message',
	data: {}
});

Options

level <string>

Specifies the level of the log. Levels can be found in logwrangler object or in the logger instance object.

Available levels include:

  • DEBUG
  • INFO
  • WARN
  • ERROR

ns <string>

Specifies a particular namespace for your log. Good for grouping logs by location in your codebase or by component.

node <string>

Name of the node, machine, or specific process currently running.

ident <string>

A more local identifier for the particular log. This could be something like a user ID to make it easy to trace the actions of a user.

message <string>

A human readable message to describe what is happening

data <object>

Contextual data related to the this particular log message. If the value of data is an Error(), the error will be parsed to grab it's message and stack trace and data will be rewritten to have an error property that will contain the contents of the Error object.

data, no error

{
	data: {
		someKey: 'someValue'
	}
}

data, with error

{
	data: new Error('Some error message')
}

// will become:

{
	data: {
		error: {
			message: 'Some error message',
			stack: <stack trace>
		}
	}
}

data, error and context

{
	data: {
		error: new Error('Some error message'),
		someKey: 'someValue'
	}
}

// will become

{
	data: {
		error: {
			message: 'Some error message',
			stack: <stack trace>
		},
		someKey: 'someValue'
	}
}

Custom logging handler

Creating a custom logger is as easy as providing an anonymous function to logger.use.

Parameters

options

Options that you passed in during initialization

	{
		options: {
			level: <level to use>
		}
	}

data

The data to be logged

{
	data: {
		level: <log level>,
		ns: <namespace - string>,
		ident: <custom identifier - string>,
		node: <node, machine, process, identifier - string>
		message: <message - string>,
		data: <custom data - object>
	}
}

Usage

var logger = fancyLog.create({
	level: fancyLog.levels.DEBUG, // default level to log
});

logger.use(function(options, data){
	
	// do something with your data
});

Keywords

FAQs

Package last updated on 02 Sep 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