A simple logging wrapper. Each instance of Log represents a 'namespace'
like @wlabs/maglev. Calling child on that instance will create a
nested namespace, like transport. All logs go to the same place.
There are 5 log levels, ERROR, WARN, INFO, DEBUG and TRACE as well as 2 pseudo-levels for convenience, ALL and NONE.
The log level can be set by adding the URL parameter log=[log-level] where [log-level] is any of the above levels including the pseudo-levels. On node the level can instead be with with the LOG environment variable.
The Log class is exposed directly on window for browser. Meaning in the
Chrome/Firefox console you can use static methods directly, like Log.dump
and Log.inspect.
Constructors#
constructor#
+ new Log(namespace: string): Log
Parameters:#
| Name | Type |
|---|---|
namespace | string |
Returns: Log
Defined in: utils/log.ts:36
Properties#
namespace#
• Readonly namespace: string
level#
â–ª Static level: LogLevel
Defined in: utils/log.ts:31
Methods#
assert#
â–¸ assert(condition: boolean, ...messageArgs: any[]): void
Parameters:#
| Name | Type |
|---|---|
condition | boolean |
...messageArgs | any[] |
Returns: void
Defined in: utils/log.ts:66
child#
â–¸ child(childNamespaces: string): Log
Parameters:#
| Name | Type |
|---|---|
childNamespaces | string |
Returns: Log
Defined in: utils/log.ts:42
debug#
â–¸ debug(...args: any[]): void
Parameters:#
| Name | Type |
|---|---|
...args | any[] |
Returns: void
Defined in: utils/log.ts:58
error#
â–¸ error(...args: any[]): void
Parameters:#
| Name | Type |
|---|---|
...args | any[] |
Returns: void
Defined in: utils/log.ts:46
info#
â–¸ info(...args: any[]): void
Parameters:#
| Name | Type |
|---|---|
...args | any[] |
Returns: void
Defined in: utils/log.ts:54
trace#
â–¸ trace(...args: any[]): void
Parameters:#
| Name | Type |
|---|---|
...args | any[] |
Returns: void
Defined in: utils/log.ts:62
warn#
â–¸ warn(...args: any[]): void
Parameters:#
| Name | Type |
|---|---|
...args | any[] |
Returns: void
Defined in: utils/log.ts:50
dump#
â–¸ Staticdump(from?: number, to?: number): void
Parameters:#
| Name | Type |
|---|---|
from? | number |
to? | number |
Returns: void
Defined in: utils/log.ts:72
inspect#
â–¸ Staticinspect(id: number): void
Parameters:#
| Name | Type |
|---|---|
id | number |
Returns: void
Defined in: utils/log.ts:83
pause#
â–¸ Staticpause(): void
Pauses logging to console. This is useful if the console is being spammed
but you're trying to look through old logs. The logs will still be recoded
and can later be dumped by simply calling dump() with no arguments.
Returns: void
Defined in: utils/log.ts:105
resume#
â–¸ Staticresume(): void
Resumes logging to the console. This does nothing is pause wasn't called
beforehand.
Returns: void
Defined in: utils/log.ts:113