bobble
Yet another node.js logger
Module Overview
bobble is a simple to use logging module. It can log to console, or a file and can also have custom log levels added that can be configured to log to different files.
Usage
In its simplest form, create an instance of bobble and call the log function to write to the console. Each logged line will be preceded with a timestamp, which is in UK format (DD-MM-YYYY HH:mm:ss.SSS) by default.
var bobble = ;var logger = ; logger;
To change bobble's default behavior, pass in a configuration object when creating the new instance. For example, in order to change the timestamp date format, pass a 'dateFormat' parameter specifying the date format to use. bobble uses Moment.js to format its timestamps, so any format that is supported by Moment.js is also supported by bobble.
var bobble = ;var logger = 'dateFormat' : 'MM-DD-YYYY HH:mm:ss.SSS'; logger;
In order to write output to a file instead of the console, pass a 'fileName' configuration parameter specifying the file to log to.
var bobble = ;var logger = 'fileName' : 'mylog.log'; logger;
Custom Log Levels
To add custom logging levels to bobble, pass in an object with the log levels as the keys, followed by an object containing an optional file name to log to. The new log levels are added to bobble as functions and can be called instead of the log() method.
var bobble = ;var logger = 'fileName' : 'default.log' 'logLevels' : 'warn' : 'fileName' : 'warnings.log' 'error' : 'fileName' : 'errors.log' 'info' : {} ; logger;logger;logger;logger;
Logging Object Properties
Custom log levels can also be used to output the properties of a passed object in a custom format. Pass the objectMapping parameter during the setup of a log level, then pass the object to log when calling the log level function:
var http = ;var bobble = ;var logger = 'fileName' : 'default.log' 'logLevels' : 'warn' : 'fileName' : 'warnings.log' 'web' : 'fileName' : 'web.log' 'objectMapping' : 'method' 'url' 'info' : {} ; var server = http