Hemi JavaScript Framework

Hemi.util.logger

Description

The Logger class may be used to instrument an object with logging functionality. Application logging is handled by the Hemi.message.service.sendMessage function, which supports multiple levels of message levels and message scoping.

static Hemi.util.logger

version 3.1.9

Utility for instrumenting a logging API into an object. Logging facilities use the Message Service message block format of: ###.#.###.### where the first set identifies the global scope, the second is the level, the third is the inner scope, and the fourth is the fine scope.

See Example Log for an example of implementating the script on a page.

Index

Example Index

Method Index

Examples

Example Log

Demonstrate how to use the Logger with an existing object.

Example Code

// Some JavaScript Object
var oMyObject = ...;
// The '900' block is an arbitrary value of 1 - 999
Hemi.util.logger.addLogger(oMyObject, "MyLog","Actions for my object", 900);
// Define a function to receive all log messages
oMyObject.HandleMessages = function(sType, oMessage){
   var iLevel = oMessage.level; // iLevel == 900
   var sMessage = oMessage.message;
}
// Listen for log messages on the same object
Hemi.message.service.subscribe("onsendmessage", oMyObject.HandleMessages);
// Test it out, optionally supply a numeric code pair (###.###) to identify message origination.
// The entire code for the message would be: 900.4.100.1
oMyObject.logWarning("Something happened!","100.1");

Methods

addLogger

Instruments the specified logger with a context sensitive logging facility.

Syntax

void addLogger( oObject, sLogName, sLogDescription, iContextId )

Parameters

log

Sends a message in the ###.3 message block. Method is virtual and can be overridden.

Syntax

void log( sMessage )

Parameters

logAdvisory

Sends a message in the ###.2 message block. Method is virtual and can be overridden.

Syntax

void logAdvisory( sMessage )

Parameters

logDebug

Sends a message in the ###.1 message block. Method is virtual and can be overridden.

Syntax

void logDebug( sMessage )

Parameters

logError

Sends a message in the #100.5 message block. Method is virtual and can be overridden.

Syntax

void logError( sMessage )

Parameters

logFatal

Sends a message in the ###.7 message block. Method is virtual and can be overridden.

Syntax

void logFatal( sMessage )

Parameters

logWarning

Sends a message in the ###.4 message block. Method is virtual and can be overridden.

Syntax

void logWarning( sMessage )

Parameters