
fastlog
stupid simple logging for Node.js. Prints messages to stdout.
Create a logger:
var logger = require('fastlog')(category, level);
logger then has a functions named after each of the available log levels.
Levels are (in order of severity) debug, info, warn, error and fatal.
Both arguments are optional. category defaults to to "default" and level
defaults to "debug". Anything less severe than the given level will not be
logged.
The logger functions take a string (interpolation optional):
var logger = require('fastlog')('security', 'debug');
logger.debug('there is a %s in my %s!', 'snake', 'boot');
Or an Error object. Any string property that's tacked onto the object will
be logged as well:
var err = new Error('someone poisoned the water hole!');
err.culprit = 'sid';
logger.error(err);
You can format your own prefix as well:
var logger = require('fastlog')('configured', 'error', '${level} [${ category }] <${timestamp}>');
logger.error('This town ain\'t big enough for the two of us!');
Usage via shell scripts
You may also use fastlog in shell scripts. First, make sure fastlog is installed globally
npm install -g fastlog
fastlog <level> [--category=<category>] [message]
> fastlog error --category important "You're my favorite deputy"
- Configure verbosity by specifying a
FASTLOG_LEVEL environment variable.
- Configure your prefix with a
FASTLOG_PREFIX environment variable.
- Specifying a
category is optional
> export FASTLOG_LEVEL=info
> export FASTLOG_PREFIX='<${timestamp}>'
> fastlog debug "I think you've had enough tea for today, let's get you outta here, Buzz."
> fastlog error "I think you've had enough tea for today, let's get you outta here, Buzz."