backend:(function|string) - a callback function which will receive all log messages. all default loggers can be accessed by name (allowed values: fancy-cli, cli).
minLogLevel:int=99 (optional) - the minimum log-level of the backend in case it's initialized by name not function
Example:
const _loggingFacility = require('logging-facility');// add logging backend for fatal errors_loggingFacility.addBackend(function(facility, level, args){ // send a e-mail on fatal errors occured if (level > 3){ Mailer.notify(args[0]); }});// add fancy console output_loggingFacility.addBackend('fancy-cli');// add simple cli output_loggingFacility.addBackend('cli');
::setBackend()
DEPRECATED
Description: Removes all exsiting backends and add a new one to the stack
Syntax:setBackend(backend:function|string)
Arguments:
backend:(function|string) - a callback function which will receive all log messages. all default loggers can be accessed by name.
Example:
const _loggingFacility = require('logging-facility');// add fancy console output_loggingFacility.addBackend('fancy-cli');// add logging backend for fatal errors - WILL REMOVE the fancy-cli backend added previously!_loggingFacility.setBackend(function(facility, level, args){ // send a e-mail on fatal errors occured if (level > 3){ Mailer.notify(args[0]); }});
::LEVEL
Description: Constants used for different log-levels @see lib/loglevel.js
const _loggingFacility = require('logging-facility');// get warning log-levelconsole.log(_loggingFacility.LEVEL.WARNING);
::LOGGER
Description: Build-In logging backends
CLI - simple cli loggingFANCY - colorized cli outputDEFAULT - alias of CLI
Example:
const _loggingFacility = require('logging-facility');// add logging function with min-loglevel of 5_loggingFacility.addBackend(_loggingFacility.LOGGER.CLI(_loggingFacility.LEVEL.NOTICE));