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.
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.
Demonstrate how to use the Logger with an existing object.
// 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");Instruments the specified logger with a context sensitive logging facility.
void addLogger( oObject, sLogName, sLogDescription, iContextId )
Sends a message in the ###.3 message block. Method is virtual and can be overridden.
void log( sMessage )
Sends a message in the ###.2 message block. Method is virtual and can be overridden.
void logAdvisory( sMessage )
Sends a message in the ###.1 message block. Method is virtual and can be overridden.
void logDebug( sMessage )
Sends a message in the #100.5 message block. Method is virtual and can be overridden.
void logError( sMessage )
Sends a message in the ###.7 message block. Method is virtual and can be overridden.
void logFatal( sMessage )
Sends a message in the ###.4 message block. Method is virtual and can be overridden.
void logWarning( sMessage )
[ Hemi JavaScript Framework - Stephen W. Cote, 2002 - 2009. ]