JS Logging API
JS API guide for logging
This file provides methods to write logging traces.
How the message is built
Every logging function takes an arbitrary number of parameters (...msg) and concatenates them into a
single message. Each one is turned into text according to what it is:
- Primitive values — strings, numbers, booleans — are written as their text representation.
- Objects and JSON are serialised with
JSON.stringify. Errorobjects contribute their message plus the context that helps locate the failure.
Tip
Rather than passing several parameters, you can build the message yourself with a template literal and string interpolation:
Logger Object
The logger object is the main object for logging functions.
logger.trace(…msg)
Creates TRACE level logging messages. It concatenates msg parameters to compound message to be logged.
Kind: global function
Returns: Void
| Param | Type | Description |
|---|---|---|
| …msg | any | The function takes as parameters a list of elements to be concatenated to generate the string message to be printed. |
Example of use:
logger.debug(…msg)
Creates DEBUG level logging messages. It concatenates msg parameters to compound message to be logged.
Kind: global function
Returns: Void
| Param | Type | Description |
|---|---|---|
| …msg | any | The function takes as parameters a list of elements to be concatenated to generate the string message to be printed. |
Example of use:
logger.info(…msg)
Creates INFO level logging messages. It concatenates msg parameters to compound message to be logged.
Kind: global function
Returns: Void
| Param | Type | Description |
|---|---|---|
| …msg | any | The function takes as parameters a list of elements to be concatenated to generate the string message to be printed. |
Example of use:
logger.warn(…msg)
Creates WARN level logging messages. It concatenates msg parameters to compound message to be logged.
Kind: global function
Returns: Void
| Param | Type | Description |
|---|---|---|
| …msg | any | The function takes as parameters a list of elements to be concatenated to generate the string message to be printed. |
Example of use:
logger.error(…msg)
Creates ERROR level logging messages. It concatenates msg parameters to compound message to be logged.
Kind: global function
Returns: Void
| Param | Type | Description |
|---|---|---|
| …msg | any | The function takes as parameters a list of elements to be concatenated to generate the string message to be printed. |
Example of use: