Module: logger

Provides wica logging support. Below are some suggestions from Stack Overflow on how to effectively use these levels effectively. Credit: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
  • Trace - Only when I would be "tracing" the code and trying to find one part of a function specifically.
  • Debug - Information that is diagnostically helpful to people more than just developers (IT, sysadmins, etc.).
  • Info - Generally useful information to log (service start/stop, configuration assumptions, etc). Info I want to always have available but usually don't care about under normal circumstances. This is my out-of-the-box config level..
  • Warn - Anything that can potentially cause application oddities, but for which I am automatically recovering. (Such as switching from a primary to backup server, retrying an operation, missing secondary data, etc.).
  • Error - Any error which is fatal to the operation, but not the service or application (can't open a required file, missing data, etc.). These errors will force user (administrator, or direct user) intervention. These are usually reserved (in my apps) for incorrect connection strings, missing services, etc.
  • Fatal - Any error that is forcing a shutdown of the service or application to prevent data loss (or further data loss). I reserve these only for the most heinous errors and situations where there is guaranteed to have been data corruption or loss.
  • Note: the fatal function is not currently implemented.

Members

(inner, constant) logLevels

JS Object that defines the available log levels including the default that will be used in the absence of an explicit call to the setLevel function.
Properties:
Name Type Attributes Default Description
NONE number <optional>
0
ERROR number <optional>
1
WARN number <optional>
2
INFO number <optional>
3
LOG number <optional>
4
DEBUG number <optional>
5
TRACE number <optional>
6
DEFAULT number <optional>
2

Methods

(inner) debug(msg, …msgOptions)

Outputs a log message at DEBUG level.
Parameters:
Name Type Attributes Description
msg string A message string containing zero or more substitution strings.
msgOptions Object <repeatable>
Zero or more objects with which to replace substitution strings within msg.

(inner) error(msg, …msgOptions)

Outputs a log message at TRACE level.
Parameters:
Name Type Attributes Description
msg string A message string containing zero or more substitution strings.
msgOptions Object <repeatable>
Zero or more objects with which to replace substitution strings within msg.

(inner) info(msg, …msgOptions)

Outputs a log message at INFO level.
Parameters:
Name Type Attributes Description
msg string A message string containing zero or more substitution strings.
msgOptions Object <repeatable>
Zero or more objects with which to replace substitution strings within msg.

(inner) log(msg, …msgOptions)

Outputs a log message at LOG level.
Parameters:
Name Type Attributes Description
msg string A message string containing zero or more substitution strings.
msgOptions Object <repeatable>
Zero or more objects with which to replace substitution strings within msg.

(inner) setLevel(level)

Sets the logging level. Zero means log nothing.
Parameters:
Name Type Description
level number The logging level.

(inner) trace(msg, …msgOptions)

Outputs a log message at TRACE level.
Parameters:
Name Type Attributes Description
msg string A message string containing zero or more substitution strings.
msgOptions Object <repeatable>
Zero or more objects with which to replace substitution strings within msg.

(inner) warn(msg, …msgOptions)

Outputs a log message at WARN level.
Parameters:
Name Type Attributes Description
msg string A message string containing zero or more substitution strings.
msgOptions Object <repeatable>
Zero or more objects with which to replace substitution strings within msg.