Skip to content
This repository has been archived by the owner on Aug 1, 2020. It is now read-only.
Alex Dadukin edited this page Apr 9, 2016 · 18 revisions

Base

There are three basic types in Logger.

Default 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

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!'

Error logger

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!'

Advanced

Imagine that the logger setup might be more accurate. Still dreaming of it? Now you should not...

Custom logger

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');
Clone this wiki locally