log-to-all
v0.1.4
Published
Combine a few loggers into one
Downloads
3
Maintainers
Readme
Log-To-All
Installation
npm install log-to-all
or
yarn add log-to-all
Try it out to see how simple it is
Basic example
This example use two of the implemented loggers:
const ConsoleLogger = require('log-to-all/lib/defaultLoggers/console');
const FileLogger = require('log-to-all/lib/defaultLoggers/file');
const logger = require('log-to-all').init([
new ConsoleLogger(),
new FileLogger(`${__dirname}/logs`)
]);
logger.info('♫♪♫♪!');
logger.debug('Will not be logged.');
logger.setDebugMode(true);
logger.debug('Now it will be logged.');
Implemented Loggers
Name| Description -------|------------------- console | Write the logs to the console file | Write the logs to files in the given path
const ConsoleLogger = require('log-to-all/lib/defaultLoggers/console');
const FileLogger = require('log-to-all/lib/defaultLoggers/file');
Add your own logger
In order to add your own logger all you have to do is to create new class with the functions:
- debug(msg, params) - Will log only if debug mode set to true.
- info(msg, params)
- warn(msg, params)
- error(msg, params)
It is recommended to use our base logger in order to make sure everything is implemented:
const baseLogger = require("log-to-all/lib/logger");
class YourLogger extends baseLogger {
}
Then add it to the array of init function like this:
const YourLogger = require('./YourLoggerPath');
require('log-to-all').init([
new YourLogger()
]);