Every instance of a log in loglevelnext
is a LogLevel
class. This reference
applies both to the default logger and all loggers created with getLogger()
.
By default loglevelnext
ships supporting the following log level name-value
pairs:
{
TRACE: 0,
DEBUG: 1,
INFO: 2,
WARN: 3,
ERROR: 4,
SILENT: 5
}
The constructor for this class accepts an options
Object. The following is a
property reference for the Object:
Type: Class:MethodFactory
Default: null
Specifies the factory to use when wrapping console
methods. The value must be
a class which inherits from MethodFactory
.
Type: String
Default: 'info'
Specifies the level the logger should use. A logger will not produce output for any log level beneath the specified level. Available levels and order are:
[
'trace',
'debug',
'info',
'warn',
'error',
'silent'
]
Note: The level names shown above correspond to the available logging methods,
with the notable exception of the silent
level.
Type: String
Default: +new Date()
Specifies the name of the log to create. This property is required, and used to
differentiate between loggers when webpack-log
is used in multiple projects
executing in the same process space.
The prefix
object defines properties for adding a prefix to each bit of data
logged.
disable() { this.level = this.levels.SILENT; }
Instructs the logger to hide output for every log level. This is equivalent
to setting the level
property to 'silent'
or 5
.
Instructs the logger to produce output for every log level. This is equivalent
to setting the level
property to 'trace'
or 0
.
Type: Function
Default: options => `[${options.level}]`
A function used to define the value used to replace instances of
{{level}}
within the prefix template. The options
argument will
contain an Object
matching { level: (String), logger: (LogLeveL) }
. This
function should represent the current level of log producing output.
Type: Function
Default: options => `[${options.name}]`
A function used to define the value used to replace instances of
{{name}}
within the prefix template. The options
argument will
contain an Object
matching { level: (String), logger: (LogLeveL) }
. This
function should represent the name of the logger producing output.
Type: String
Default: '{{time}} {{level}} '
Defines the template that represents the prefix. The template uses
Mustache syntax. When prefixing log output, the
logger will interpolate the template string and attempt to execute a function on
the prefix
object corresponding to a given tag.
For example:
{
prefix: {
foo: () => 'bar',
template: '{{foo}}-'
}
}
Would then result in a prefix of 'bar-'
prepended to the output for each log
method call.
Type: Function
Default: () => new Date().toTimeString().split(' ')[0]
A function used to define the value used to replace instances of
{{time}}
within the prefix template. This function should
represent the time at which the logger produced output.
Type: Class:MethodFactory
Gets or sets the factory to use when wrapping console
methods. When setting
this property, the value must be a class which inherits from MethodFactory
.
Type: String|Number
Gets or sets the level the log should operate on. When setting this property, the
value must be a String
or Number.
Type: Object
Gets an object which represents the valid level name-value pairs for this log instance.