LoggerSingleton
A logging system.
Example:
import LoggerSingleton from 'ievv_jsbase/lib/log/LoggerSingleton';
let mylogger = new LoggerSingleton().loggerSingleton.getLogger('myproject.MyClass');
mylogger.debug('Hello debug world');
mylogger.info('Hello info world');
mylogger.warning('Hello warning world');
mylogger.error('Hello error world');
import LOGLEVEL from 'ievv_jsbase/lib/log/loglevel';
new LoggerSingleton().setDefaultLogLevel(LOGLEVEL.DEBUG);
import LOGLEVEL from 'ievv_jsbase/lib/log/loglevel';
new LoggerSingleton().getLogger('mylogger').setLogLevel(LOGLEVEL.DEBUG);
Constructor Summary
Public Constructor | ||
public |
Get an instance of the singleton. |
Method Summary
Public Methods | ||
public |
Get a string that summarize information about all the loggers. |
|
public |
getDefaultLogLevel(): int Get the default log level. |
|
public |
Get a logger. |
|
public |
Get the number of loggers registered using getLogger. |
|
public |
Get the names of all the registered loggers. |
|
public |
Get textual name for the default log level. |
|
public |
reset() Reset to default log level, and clear all custom loggers. |
|
public |
setDefaultLogLevel(logLevel: *) Set the default loglevel. |
Public Constructors
public constructor source
Get an instance of the singleton.
The first time this is called, we create a new instance. For all subsequent calls, we return the instance that was created on the first call.
Public Methods
public getDebugInfoString(): string source
Get a string that summarize information about all the loggers. The string has a list of loglevels with their loglevel. Perfect for debugging.
Intended for debugging. The format of the string may change.
public getDefaultLogLevel(): int source
Get the default log level.
Defaults to LogLevels#WARNING if not overridden with {@LoggerSingleton#setDefaultLogLevel}.
public getLogger(name: string): Logger source
Get a logger.
Params:
Name | Type | Attribute | Description |
name | string | A name for the logger. Should be a unique name, so typically the full import path of the class/function using the logger. |
public getTextualNameForDefaultLogLevel(): string source
Get textual name for the default log level.
Intended for debugging. The format of the string may change.
public setDefaultLogLevel(logLevel: *) source
Set the default loglevel.
All loggers use this by default unless you override their loglevel.
Params:
Name | Type | Attribute | Description |
logLevel | * | The log level. Must be one of the loglevels defined in LogLevels. |
Throw:
if LogLevels#validateLogLevel fails. |
Example:
import LoggerSingleton from 'ievv_jsbase/log/LoggerSingleton';
import LOGLEVEL from 'ievv_jsbase/log/loglevel';
let loggerSingleton = new LoggerSingleton();
loggerSingleton.getLogger('mylogger').setLogLevel(LOGLEVEL.DEBUG);