-
Notifications
You must be signed in to change notification settings - Fork 0
Types
There are three basic types in Logger.
This is the simplest of all kinds of data loggers. By default it uses console to report about all events occurring in the application.
Example
const logger = LoggerFactory.createDefault('test');
logger.info('Hello World!');
// console writes 'Hello World!'
Request logger relates to loggers for files. It intercepts any messages and records into a file specially created for this purpose on the fly. Doesn't use the console transport.
Be careful when dealing with this type, since it requires passing the file name on initialization.
Example
const logger = LoggerFactory.createRequests('test', __dirname);
logger.debug('Hello World!');
// file writes 'Hello World!'
The most advanced of all standard data loggers. It uses console and the file system to notify you of your information system status.
Be careful when dealing with this type, since it requires to pass the file name on initialization.
Example
const logger = LoggerFactory.createError('test', __dirname);
logger.info('Hello World!');
// file and console writes 'Hello World!'
Imagine that the logger setup might be more accurate. Still dreaming of it? Now you should not...
It allows you to do anything you want! Carefully, it uses options
Example
const options = {
fileNamePrefix: 'custom-',
fileNameExtension: '.myfile',
logIntoConsole: true,
logIntoFile: true,
pathToLogsFolder: __dirname
};
const specific = {
env: 'test',
logType: 'log'
};
const customLogger = LoggerFactory.createCustom(options, specific);
customLogger.error('Hello world');