Logger

Singleton containing methods for asynchronous logging with clean, configurable output via custom Logger transports

Easiest manner of use is via the @logger parameter decorator to attach the logger to a class property for use within that class. Otherwise the singleton instance can be accessed via Logger.instance()

Logging can be turned off by setting the logging level to LogLevel.NONE

Constructor

new Logger()

Source:

Properties

.DEBUG: LogLevel

LogLevel.DEBUG enum shortcut

Type:
LogLevel
Source:

.ERROR: LogLevel

LogLevel.ERROR enum shortcut

Type:
LogLevel
Source:

.INFO: LogLevel

LogLevel.INFO enum shortcut

Type:
LogLevel
Source:

.LOG: LogLevel

LogLevel.LOG enum shortcut

Type:
LogLevel
Source:

.NONE: LogLevel

LogLevel.NONE enum shortcut

Type:
LogLevel
Source:

.WARN: LogLevel

LogLevel.WARN enum shortcut

Type:
LogLevel
Source:

Methods

(static) .instance()Logger

Returns the Logger singleton instance

Source:
Returns:
Logger

.addTransport(transport: Transport) → void

Add a Transport for the Logger to use for logging. The logger will log to all provided transports

Parameters:
Name Type Description
transport
Transport

The transport to add

Source:
Returns:
void

.debug(tag: string, text: string) → Promise<void>

Log debug text to the logger transports. Will not be logged unless the logging level is LogLevel.DEBUG

Parameters:
Name Type Attributes Description
tag
string

Tag to prefix the log with

text
string
<repeatable>

String(s) to log

Source:
Returns:
Promise<void>

.error(tag: string, text: string) → Promise<void>

Log error text to the logger transports. Will not be logged unless the logging level is LogLevel.ERROR or higher

Parameters:
Name Type Attributes Description
tag
string

Tag to prefix the log with

text
string
<repeatable>

String(s) to log

Source:
Returns:
Promise<void>

.info(tag: string, text: string) → Promise<void>

Log less important information to the logger transports. Will not be logged unless the logging level is LogLevel.INFO or higher

Parameters:
Name Type Attributes Description
tag
string

Tag to prefix the log with to identify the source of the log

text
string
<repeatable>

String(s) to log

Source:
Returns:
Promise<void>

.log(tag: string, text: string) → Promise<void>

Log useful information to the Logger transports. Will not be logged unless the log level is LogLevel.LOG or higher

Parameters:
Name Type Attributes Description
tag
string

Tag to prefix the log with

text
string
<repeatable>

String(s) to log

Source:
Returns:
Promise<void>

.removeBaseTransport() → void

Remove the default console logging transport. This is useful if you want to provide your own transport that uses the console.

This should be run before creating a YAMDBF Client instance if you do not any logging to be done with the base transport before you get the chance to swap it out.

Logger.instance().removeBaseTransport();
Logger.instance().addTransport({ transport[, level] });
Source:
Returns:
void

.setLogLevel(level: LogLevel) → void

Set the level of output that will be logged

Parameters:
Name Type Description
level
LogLevel

The level of logging to output

Source:
Returns:
void

.warn(tag: string, text: string) → Promise<void>

Log warning text to the logger transports. Will not be logged unless the logging level is LogLevel.WARN or higher

Parameters:
Name Type Attributes Description
tag
string

Tag to prefix the log with

text
string
<repeatable>

String(s) to log

Source:
Returns:
Promise<void>