loog

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.

Source:

Methods

clear() → {loog}

Clears the console, does nothing if muted

Source:
See:
Returns:
Type:
loog

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 null to skip logging the current count

Returns:
Type:
loog

debug(message) → {loog}

Logs message as debug.

Visible when logLevel is set to: all, silly or debug

Source:
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.

Source:
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

Source:
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

Source:
Parameters:
Name Type Description
message string

The message to log

Returns:
Type:
loog

log(message) → {loog}

Issues a log statement marked as 'log'

Source:
Parameters:
Name Type Description
message string

The message to log

Returns:
Type:
loog

mute() → {loog}

Mutes all subsequent log statements

Source:
See:
Returns:
Type:
loog

notice(message) → {loog}

Logs message as notice.

Visible when logLevel is set to: all, silly, debug, verbose, timing, http or notice

Source:
Parameters:
Name Type Description
message string

The message to log

Returns:
Type:
loog

outdent() → {loog}

Outdent subsequent log statements one level.

Source:
See:
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

report() → {loog}

Reports existing trackers, does nothing if muted

Source:
See:
Returns:
Type:
loog

resetIndentation() → {loog}

Resets the indent level to 0.

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)
Source:
Parameters:
Name Type Attributes Default Description
newLevel string <optional>
quiet

The log level to set, must be one of
- all
- silly
- debug
- verbose
- timing
- http
- notice
- info
- warn
- quiet
- error
- silent

Returns:
Type:
loog

silly(message) → {loog}

Logs message as silly.

Visible when logLevel is set to: all or silly

Source:
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

Source:
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

Source:
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

unmute() → {loog}

Unmutes all subsequent log statements

Source:
See:
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

Source:
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

Source:
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

Source:
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