cp

console-prefix

Drop in replacement for console to add a prefix to messages. Adds an ISO timestamp by default.

Showing:

Popularity

Downloads/wk

0

Maintenance

No Maintenance Data Available

Package

Dependencies

1

License

ISC

Type Definitions

Tree-Shakeable

No?

Categories

Readme

console-prefix Build Status Dependency Status

Drop in replacement for console to add a prefix to messages. Adds an ISO timestamp by default.

Example

var console = require('console-prefix')

console.log('Hello!')
// Output:
// 2015-04-29T22:46:37.444Z Hello!

Customise prefix

var console = require('console-prefix')('[Sprocket]')

function Sprocket () {
  console.log('in constructor')
}

new Sprocket()
// Output:
// [Sprocket] in constructor
var console = require('console-prefix')(function () {
  return new Date() + ' --'
})

console.log('Hello World!')
// Output:
// Wed Apr 29 2015 19:56:24 GMT-0300 (CLT) -- Hello World!

Options

Configure the proxy object returned by passing an options object:

var console = require('console-prefix')({
  prefix: function () { return new Date().toISOString() },
  methods: ['log', 'info', 'warn', 'error'],
  console: global.console
})

prefix

A string or function to prefix log messages with. Defaults to an ISO timestamp.

methods

The logging methods the prefix should be applied to. Defaults to 'log', 'info', 'warn', 'error'.

console

The logger object to proxy to. Defaults to global.console or window.console (depending on the environment).

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial