Log class

The Log class is an Itential Platform class used to output errors, warnings, and other information to the console or the Itential Platform log files.

Access the log object

Itential Platform instantiates the Log class on startup and exposes it as the global log object. Applications and adapters may reference it directly.

Example cog file

1/* global adapters */
2/* global brokers */
3/* global cogs */
4/* global log */
5
6function test(callback) {
7 log.info("I am a log entry");
8}
9
10function debug(callback) {
11 log.debug("reconciling:" + device);
12}

Log levels

Log levels control the amount of information recorded. Each level has an associated severity. The following levels are available:

MethodDescription
consoleDeprecated.
spamCollect or output excessive or repetitive messages, large text files, or large quantities of data such as search results — information that, though relevant, would clutter the log file and render it unusable.
traceMinor events within functions. Like “breadcrumbs” within a function.
debugMajor events such as successful data retrieval from an external system or the completion of a function.
infoSuccessful status change; limited to one message per successful action.
warnIssues or unexpected behavior that does not impact functionality.
errorErrors or failures in the code that impact functionality.

console.log is not supported by Itential Platform. Use the Log class instead.

Log levels are defined in the loggerProps object of the Itential Platform Profile, configurable within the Admin Essentials application.

  • The log_level property determines the level for the log file.
  • The console_level property determines the level for the console.
  • In the example below, log_level is set to info, which means any logging at info severity or higher will be written to the log file (info, warn, error, debug, console, trace).
  • If log_level were debug, Itential Platform would log all log.debug messages from cogs and adapters.

Properties file

The following is an example of the loggerProps object in an Itential Platform Profile:

1"loggerProps": {
2 "description": "Logging",
3 "log_max_files": 100,
4 "log_max_file_size": 1048576,
5 "log_level": "info",
6 "log_directory": "/var/log/itential/",
7 "log_filename": "itential.log",
8 "log_timezone_offset": 0,
9 "console_level": "info"
10}