Moogsoft Docs

Logger

Warning

The Logger module was deprecated for the release of Moogsoft AIOps 7.1.0. See Configure Logging for details on the the new Logger.

The Logger module sets the log level in Moogfarmd, allowing log messages to be written to the common Moogfarmd log file.

For example, when you write a Moobot, you can use the Logger for debug. Writing a log message to a log file is an IO operation, and comes with execution time cost. When developing the Moobot it can be helpful to have a number of logging statements. Once the Moobot is operational, however, you should keep log messaging to a minimum.

The Logger module is available to load into any standard Moobot. To use, define a new global object logger at the top of a JavaScript Moobot file:

var logger = MooBot.loadModule('Logger');

Reference Guide

The following methods can be used with the Logger Moobot module.

The logmessage argument used in the Logger module is a single string. Multiple arguments are possible using concatenation. See the Examples for more information.

Note

Note

printf based Logger functions (for more information click here ) have been deprecated in favour of the 'single string argument' version.

debug

Sends a debug log message (the lowest severity level). For example, this can be used for logging detailed troubleshooting information (not for production).

Request Argument

Name Type Description
logmessage String A single string of valid JavaScript variables or objects, used to form a log message.

Return Parameter

None.

info

Sends an information log message (the intermediate severity level). For example, this can be used to log the changing of a setting.

Request Argument

Name Type Description
logmessage String A single string of valid JavaScript variables or objects, used to form a log message.

Return Parameter

None.

warning

Sends a warning log message (a higher severity level). For example, this can be used to log behavior which impacts normal operation of the system.

Request Argument

Name Type Description
logmessage String A single string of valid JavaScript variables or objects, used to form a log message.

Return Parameter

None.

fatal

Sends a fatal log message (the highest severity setting). For example this can be used to log extreme circumstances, such as an unrecoverable failure that caused Moogfarmd to exit.

Request Argument

Name Type Message
logmessage String A single string of valid JavaScript variables or objects, used to form a log message.

Return Parameter

None.

Examples

All the above methods work in the same way, with each sending a log message of a different severity level.

{
   	var dispText= "Reset";
   	var dispNum= 2;
   	var aReal= 3.141593;
   	var aString= "CPU@ >90%";
   	var intHigh= 4;
   	var intHighest= 5;

	logger.debug("A debug message");
	logger.info("Counter: "+ dispText);
	logger.info("Severity low. Level: "+ dispNum + ". ...Pi = "+ aReal);
	logger.warning("Warning: "+ aString);
	logger.warning("Severity high. Level: "+ intHigh);
	logger.fatal("Severity exceeds "+ intHighest + "! Restart required");
}

The above six logger arguments give the following six corresponding log messages:

DEBUG:... ...A debug message
INFO :... ...Counter: Reset
INFO :... ...Severity low. Level: 2. ...Pi = 3.141593
WARN :... ...Warning: CPU@ >90%
WARN :... ...Severity high. Level: 4
FATAL:... ...Severity exceeds 5! Restart required