new Logger(loggerName)
Parameters:
| Name | Type | Description |
|---|---|---|
loggerName |
string | Name for this logger. |
Example
const log = new Logger('Bob');
foo(x) {
const me = foo.name;
log.entered(me, x);
... do stuff ...
log.starting('loop');
for (const item of items) {
log.log(`Processing ${item}`);
...
}
log.finished('loop');
log.leaving(me, y);
return y;
}
Logger.config(log.name).enabled = true;
Logger.config(log.name).group('foo').mode = 'silenced';
GM.setValue('Logger', Logger.configs);
... restart browser ...
Logger.configs = GM.getValue('Logger');
Classes
Members
-
includeStackTrace :boolean
-
-
mq :module:base.MessageQueue
-
-
name :string
-
-
silenced :boolean
-
-
static configDispatcherEnabled :boolean
-
-
static configs :object
-
-
static loggers :Array.<string>
-
Methods
-
entered(group, …rest)
-
Indicate entered a specific group.
Parameters:
Name Type Attributes Description groupstring Group that was entered.
restobject <repeatable>
Arbitrary items to pass to console.debug.
-
finished(group, …rest)
-
Indicate finished with a specific collapsed group.
Parameters:
Name Type Attributes Description groupstring Group that was entered.
restobject <repeatable>
Arbitrary items to pass to console.debug.
-
leaving(group, …rest)
-
Indicate leaving a specific group.
Parameters:
Name Type Attributes Description groupstring Group leaving.
restobject <repeatable>
Arbitrary items to pass to console.debug.
-
log(msg, …rest)
-
Log a specific message.
Parameters:
Name Type Attributes Description msgstring Message to send to console.debug.
restobject <repeatable>
Arbitrary items to pass to console.debug.
-
starting(group, …rest)
-
Indicate starting a specific collapsed group.
Parameters:
Name Type Attributes Description groupstring Group that is being started.
restobject <repeatable>
Arbitrary items to pass to console.debug.
-
static clear()
-
Clear the console.
-
static config(loggerName) → {module:base.Logger~Config}
-
Get configuration of a specific Logger.
Parameters:
Name Type Description loggerNamestring Logger configuration to get.
-
static offConfig(callback)
-
Remove all instances of a function attached for config change events.
Parameters:
Name Type Description callbackmodule:base.Logger~ConfigMutationHandler Function that receives events.
-
static onConfig(callback)
-
Attach a function for all config change events.
Parameters:
Name Type Description callbackmodule:base.Logger~ConfigMutationHandler Function that receives events.
-
static resetConfigs()
-
Reset all configs to an empty state.
Type Definitions
-
ConfigMutationHandler(evt, record)
-
Parameters:
Name Type Description evtstring Type of mutation.
recordmodule:base.Logger~ConfigMutationRecord Details about the mutation.
-
ConfigMutationRecord
-
Properties:
Name Type Attributes Description loggerstring Name of the affected Logger instance.
groupstring <nullable>
Name of a possibly affected group.