new Logger(options/levelnullable)
Basic stdout and file logger.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
options/level |
String | Object |
<nullable> |
||
options.level |
String |
<nullable> |
||
options.colors |
Boolean |
<optional> |
true |
- Source:
Members
(static, constant) colors :Array:.<String:>
Default CSI colors.
Type:
- Default Value:
["0","1;31","1;33","94","90","90"]
- Source:
(static, constant) HAS_TTY :Boolean
Whether stdout is a tty FD.
Type:
- Boolean
- Source:
(static) levels :Number
Available log levels.
Type:
- Number
Properties:
Name | Type | Description |
---|---|---|
NONE |
Number | |
ERROR |
Number | |
WARNING |
Number | |
INFO |
Number | |
DEBUG |
Number | |
SPAM |
Number |
- Source:
(static, constant) levelsByVal :Array:.<String:>
Available log levels.
Type:
- Default Value:
["none","error","warning","info","debug","spam"]
- Source:
Methods
(private) _error(err)
Helper to parse an error into a nicer
format. Call's log
internally.
Parameters:
Name | Type | Description |
---|---|---|
err |
Error |
- Source:
close()
Destroy the write stream.
- Source:
debug(obj, …args)
Output a log to the debug
log level.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
String | Object | ||
args |
Object |
<repeatable> |
- Source:
error(err, …args)
Output a log to the error
log level.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
err |
String | Object | Error | ||
args |
Object |
<repeatable> |
- Source:
getStream() → {Object}
Create or get the current file stream.
- Source:
Returns:
- Type
- Object
info(obj, …args)
Output a log to the info
log level.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
String | Object | ||
args |
Object |
<repeatable> |
- Source:
(private) init(options)
Initialize the logger.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
- Source:
log(level, args)
Output a log to the desired log level. Note that this bypasses the level check.
Parameters:
Name | Type | Description |
---|---|---|
level |
String | |
args |
Array:.<Object:> |
- Source:
memory()
Log the current memory usage.
- Source:
open()
Open the logger.
- Source:
setFile(filename)
Set the log file location.
Parameters:
Name | Type | Description |
---|---|---|
filename |
String |
- Source:
setLevel(level)
Set or reset the log level.
Parameters:
Name | Type | Description |
---|---|---|
level |
String |
- Source:
spam(obj, …args)
Output a log to the spam
log level.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
String | Object | ||
args |
Object |
<repeatable> |
- Source:
warning(obj, …args)
Output a log to the warning
log level.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
String | Object | ||
args |
Object |
<repeatable> |
- Source:
writeConsole(level, args)
Write log to the console.
Parameters:
Name | Type | Description |
---|---|---|
level |
String | |
args |
Array:.<Object:> |
- Source:
writeStream(level, args)
Write a string to the output stream (usually a file).
Parameters:
Name | Type | Description |
---|---|---|
level |
String | |
args |
Array:.<Object:> |
- Source: