A simple log with an extra character.
The result of importing this module serves as the loog
object and a function to reconfigure it.
A quick example:
// Use its methods directly, with the default configuration
const loog = require('loog');
loog.info('Hi!');
// Use it as a function to reconfigure the instance
const loog = require('loog')({
prefixStyle: 'emoji'
});
loog.info('Hi!');
See the docs for the global loog function for more documentation on how to reconfigure loog.
Methods
clearCount(messageopt) → {loog}
Clears a counter
- Source:
- See:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
message |
string
|
<optional> |
'' |
The message or label to clear the counter for |
Returns:
- Type:
-
loog
clearLine() → {loog}
Clears the last line from the console, does nothing if muted
- Source:
- See:
Returns:
- Type:
-
loog
count(messageopt, typeopt) → {loog}
Count a given message or label and show a message (optional)
- Source:
- See:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
message |
string
|
<optional> |
null |
The message or label |
type |
string
|
<optional> |
log |
The type of log to use, pass |
Returns:
- Type:
-
loog
debug(message) → {loog}
Logs message
as debug.
Visible when logLevel
is set to: all
, silly
or debug
Parameters:
Name | Type | Description |
---|---|---|
message |
string
|
The message to log |
Returns:
- Type:
-
loog
error(message) → {loog}
Logs message
as error.
Visible when logLevel
is set to: all
, silly
, debug
, verbose
, timing
, http
, notice
, info
, warn
, quiet
or error
.
Parameters:
Name | Type | Description |
---|---|---|
message |
string
|
The message to log |
Returns:
- Type:
-
loog
http(message) → {loog}
Logs message
as http.
Visible when logLevel
is set to: all
, silly
, debug
, verbose
, timing
or http
Parameters:
Name | Type | Description |
---|---|---|
message |
string
|
The message to log |
Returns:
- Type:
-
loog
indent() → {loog}
Indent subsequent log statements one level deeper.
- Source:
- See:
Returns:
- Type:
-
loog
info(message) → {loog}
Logs message
as info.
Visible when logLevel
is set to: all
, silly
, debug
, verbose
, timing
, http
, notice
or info
Parameters:
Name | Type | Description |
---|---|---|
message |
string
|
The message to log |
Returns:
- Type:
-
loog
log(message) → {loog}
Issues a log statement marked as 'log'
Parameters:
Name | Type | Description |
---|---|---|
message |
string
|
The message to log |
Returns:
- Type:
-
loog
notice(message) → {loog}
Logs message
as notice.
Visible when logLevel
is set to: all
, silly
, debug
, verbose
, timing
, http
or notice
Parameters:
Name | Type | Description |
---|---|---|
message |
string
|
The message to log |
Returns:
- Type:
-
loog
pauseIndentation() → {loog}
Temporarily pause indentation, subsequent statements will be logged at the root level. Use module:loog#resumeIndentation to recover the indent level.
- Source:
- See:
Returns:
- Type:
-
loog
resumeIndentation() → {loog}
Resumes the previously paused indentation.
- Source:
- See:
Returns:
- Type:
-
loog
setLogLevel(newLevelopt) → {loog}
Changes the log level for subsequent statements.
Possible levels are:
- all
- silly
- debug
- verbose
- timing
- http
- notice
- info
- success
- warn
- quiet
- error
- silent
Log levels are aggregative, so they enable/or disable log functions like this:
- Level: all, silly
loog.error
loog.warn
loog.warning
loog.info
loog.success
loog.notice
loog.http
loog.timing
loog.verbose
loog.debug
loog.silly
loog.log
- Level: debug, verbose
loog.error
loog.warn
loog.warning
loog.info
loog.success
loog.notice
loog.http
loog.timing
loog.verbose
loog.debug
loog.log
- Level: timing
loog.error
loog.warn
loog.warning
loog.info
loog.success
loog.notice
loog.http
loog.timing
loog.log
- Level: http
loog.error
loog.warn
loog.warning
loog.info
loog.success
loog.notice
loog.http
loog.log
- Level: notice
loog.error
loog.warn
loog.warning
loog.info
loog.success
loog.notice
loog.log
- Level: info
loog.error
loog.warn
loog.warning
loog.info
loog.success
loog.log
- Level: warn
loog.error
loog.warn
loog.warning
loog.log
- Level: error, quiet
loog.error
loog.log
- Level: silent
- (none)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
newLevel |
string
|
<optional> |
quiet |
The log level to set, must be one of |
Returns:
- Type:
-
loog
silly(message) → {loog}
Logs message
as silly.
Visible when logLevel
is set to: all
or silly
Parameters:
Name | Type | Description |
---|---|---|
message |
string
|
The message to log |
Returns:
- Type:
-
loog
success(message) → {loog}
Logs message
as success.
Visible when logLevel
is set to: all
, silly
, debug
, verbose
, timing
, http
, notice
or info
Parameters:
Name | Type | Description |
---|---|---|
message |
string
|
The message to log |
Returns:
- Type:
-
loog
timing(message) → {loog}
Logs message
as timing.
Visible when logLevel
is set to: all
, silly
, debug
, verbose
or timing
Parameters:
Name | Type | Description |
---|---|---|
message |
string
|
The message to log |
Returns:
- Type:
-
loog
track(label) → {loog}
Tracks a label or message so that it can be later retrieved using report
.
- Source:
- See:
Parameters:
Name | Type | Description |
---|---|---|
label |
string
|
The label or message to track |
Returns:
- Type:
-
loog
untrack(label) → {loog}
Stops tracking a label
- Source:
- See:
Parameters:
Name | Type | Description |
---|---|---|
label |
string
|
The label or message to stop tracking |
Returns:
- Type:
-
loog
verbose(message) → {loog}
Logs message
as verbose.
Visible when logLevel
is set to: all
, silly
, debug
or verbose
Parameters:
Name | Type | Description |
---|---|---|
message |
string
|
The message to log |
Returns:
- Type:
-
loog
warn(message) → {loog}
Logs message
as warn.
Visible when logLevel
is set to: all
, silly
, debug
, verbose
, timing
, http
, notice
, info
or warn
Parameters:
Name | Type | Description |
---|---|---|
message |
string
|
The message to log |
Returns:
- Type:
-
loog
(inner) module:loog$json(json, indentopt, typeopt)
Logs a JSON object using JSON.stringify
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
json |
Object
|
The JSON object to log |
||
indent |
number
|
<optional> |
4 |
The number of spaces on each indent level |
type |
string
|
<optional> |
log |
The logging method to use |