OverviewSingleDeprecatedPropertiesEventsXSL Parameters

jsx3.util

class Logger

Object
->jsx3.lang.Object
  ->jsx3.util.Logger

class Logger
extends jsx3.lang.Object
A Logger is used to log messages about a particular component of an application.

Loggers are organized hierarchically according to name, descending from the root logger, "global." A period denotes levels in the hierarchy. For example, global is the parent of com is the parent of com.tibco is the parent of com.tibco.gi, etc.

A Logger has a level that determines what severity of messages will be handled. Messages with severity below the level of the Logger will be ignored. If the level of a Logger is not explicitly defined, the level is inherited from its parent.

A Logger can have any number of handlers, each of which can output a log message to a different place. By default a logger will also forward log messages to the handlers of its ancestors, although this can be disabled per Logger.

A typical usage pattern is to create a Logger for each class, setting it as a private static field of that class, as in the following code example:
jsx3.Class.defineClass('eg.Thing', null, null, function(Thing, Thing_prototype) {
  
  // import jsx3.util.Logger
  var Logger = jsx3.util.Logger;
  // create Logger for this class
  Thing._LOG = Logger.getLogger(Thing.jsxclass.getName());
  Thing.prototype.init = function(arg1, arg2, arg2) {
    Thing._LOG.debug("received args: " + arg1 + ", " + arg2 + ", " + arg3);
    if (isNaN(arg1)) {
      Thing._LOG.warn("arg1 is not a number, setting to 0");
      this._one = 0;
    } else {
      this._one = arg1;
    }
  };
});
If the creation of the log message is expensive (depending on the implementation, toString() can be expensive), isLoggable() can be used to check whether the log statement will actually be handled before creating the log message:
if (LOG.isLoggable(jsx3.util.Logger.INFO))
  LOG.info(anObject.toString());

Since:

3.1

Nested Class Summary
jsx3.util.Logger.AlertHandler
Handles a logging record by sending it to a JavaScript alert.
jsx3.util.Logger.ConsoleHandler
Handles a logging record by sending it to the Firebug console.
jsx3.util.Logger.FormatHandler
A subclass of Handler that includes functionality for formatting logging records as human-readable strings.
jsx3.util.Logger.Handler
The base logging handler class.
jsx3.util.Logger.Manager
Manager class for the logging system.
jsx3.util.Logger.MemoryHandler
A simple Handler class that stores a rotating cache of log records in memory.
jsx3.util.Logger.Record
Record bean that stores information about a logging message.
Field Summary
static int
DEBUG
Level indicating debug message.
static int
ERROR
Level indicating error.
static int
FATAL
Level indicating fatal error.
static jsx3.util.Logger
GLOBAL
Convenient access to jsx3.util.Logger.getLogger('global').
static int
INFO
Level indicating informational message.
static int
OFF
Set the level of a Logger or Handler to this value to ignore all messages.
static int
TRACE
Level indicating trace message.
static int
WARN
Level indicating warning.
Method Summary
void
Add a handler to this Logger.
void
debug(strMessage : String, strArgs : Array<String> | String... | jsx3.lang.Exception)
Log a message at level DEBUG.
static void
doLog(strErrorNumber : String, strMessage : String, PRIORITY : int, bTrace : boolean)
Deprecated. use either jsx3.log or Logger.log()
void
error(strMessage : String, strArgs : Array<String> | String... | jsx3.lang.Exception)
Log a message at level ERROR.
static String
errorToString(error : ?)
Deprecated.
void
fatal(strMessage : String, strArgs : Array<String> | String... | jsx3.lang.Exception)
Log a message at level FATAL.
int
Returns the effective level of this Logger, which is either the explicitly set value of this Logger or the effective level of this Logger's parent Logger.
int
Returns the level of this Logger.
static Object
Deprecated. returns an empty array
static jsx3.util.Logger
getLogger(strName : String)
Returns an Logger instance.
static void
Deprecated. use Logger.isLoggable()
String
Returns the name of this Logger.
jsx3.util.Logger
Returns the parent Logger of this Logger.
boolean
Returns whether this Logger will publish log messages to the handlers of its parent Logger.
void
info(strMessage : String, strArgs : Array<String> | String... | jsx3.lang.Exception)
Log a message at level INFO.
boolean
isLoggable(intLevel : int)
Returns true if a log message sent to this logger at level intLevel will be forwarded on to the handlers of this logger.
static String
levelAsString(intLevel : int)
Returns the string (English) representation of a level value.
void
log(intLevel : int, strMessage : String, strArgs : Array<String> | String...)
Log a message.
void
logError(intLevel : int, strMessage : String, objError : jsx3.lang.Exception)
Log an exception.
static void
logError(e : Object, PRIORITY : int)
Deprecated. use instance method Logger.logError()
void
logStack(intLevel : int, strMessage : String, intSkip : int)
Log the current stack with a message.
void
Remove a handler from this Logger.
static void
Deprecated. no effect
void
setLevel(intLevel : int)
Sets the level of this Logger.
void
Sets the parent Logger of this Logger.
void
Sets whether this Logger will publish log messages to the handlers of its parent Logger.
static Object
Deprecated. Returns empty string.
void
trace(strMessage : String, strArgs : Array<String> | String... | jsx3.lang.Exception)
Log a message at level TRACE.
void
warn(strMessage : String, strArgs : Array<String> | String... | jsx3.lang.Exception)
Log a message at level WARN.
Methods Inherited From jsx3.lang.Object
clone, equals, eval, getClass, getInstanceOf, getInstanceOfClass, getInstanceOfPackage, instanceOf, isInstanceOf, isSubclassOf, jsxmix, jsxsuper, jsxsupermix, setInstanceOf, toString
Field Detail

DEBUG

static final int DEBUG
Level indicating debug message.

ERROR

static final int ERROR
Level indicating error.

FATAL

static final int FATAL
Level indicating fatal error.

GLOBAL

static jsx3.util.Logger GLOBAL
Convenient access to jsx3.util.Logger.getLogger('global').

INFO

static final int INFO
Level indicating informational message.

OFF

static final int OFF
Set the level of a Logger or Handler to this value to ignore all messages.

TRACE

static final int TRACE
Level indicating trace message.

WARN

static final int WARN
Level indicating warning.
Method Detail

addHandler

void addHandler(objHandler : jsx3.util.Logger.Handler)
Add a handler to this Logger.

Parameters:

objHandler

debug

void debug(strMessage : String, strArgs : Array<String> | String... | jsx3.lang.Exception)
Log a message at level DEBUG. Polymorphic method honors the signature of either log() or logError() (without the first intLevel parameter).

Parameters:

strMessagethe message to log
strArgseither an array of message parameters, variable argument message parameters, or an exception; optional argument

doLog

static void doLog(strErrorNumber : String, strMessage : String, PRIORITY : int, bTrace : boolean)
Deprecated. use either jsx3.log or Logger.log()
Called by several foundation classes when non-critical errors occur. Basically allows the error to be saved to memory and be queried by the application developer for more-specific information about why a given request may have failed. Sends a log message to the global Logger. Attempts to convert the PRIORITY argument to a valid value for Logger, defaults to INFO.

Parameters:

strErrorNumberarbitrary identifier passed by the calling function to track the specific location of the error
strMessagemessage to describe the error
PRIORITYone of 1, 2 or 3, with 1 being most serious (red..orange..yellow)
bTracetrue if null; if true, the stack trace is printed, displaying the order of the call stack

See Also:

jsx3.log(), log()

error

void error(strMessage : String, strArgs : Array<String> | String... | jsx3.lang.Exception)
Log a message at level ERROR. Polymorphic method honors the signature of either log() or logError() (without the first intLevel parameter).

Parameters:

strMessagethe message to log
strArgseither an array of message parameters, variable argument message parameters, or an exception; optional argument

errorToString

static String errorToString(error : ?)
Deprecated.
returns a text-based version of the error log object. This is helpful when debugging a JSX application that doesn't fully initialize. In practice, if you are viewing a web page with an embedded JSX application, you can type (ctrl + o) to show the browser's 'open' dialog. From there, enter the following bit of Javascript to call this function: javascript:alert(jsx3.util.Logger.toString());

Parameters:

error

Returns:

 

fatal

void fatal(strMessage : String, strArgs : Array<String> | String... | jsx3.lang.Exception)
Log a message at level FATAL. Polymorphic method honors the signature of either log() or logError() (without the first intLevel parameter).

Parameters:

strMessagethe message to log
strArgseither an array of message parameters, variable argument message parameters, or an exception; optional argument

getEffectiveLevel

int getEffectiveLevel()
Returns the effective level of this Logger, which is either the explicitly set value of this Logger or the effective level of this Logger's parent Logger.

Returns:

 

getLevel

int getLevel()
Returns the level of this Logger. This method will return null unless the level of this Logger has been explicitly set either in the configuration file or with a call to setLevel().

Returns:

 

getLog

static Object getLog()
Deprecated. returns an empty array
returns the JavaScript Array containing all non-fatal app errors trapped by various foundation classes; as a developer, you can access a specific error by simply referencing its ordinal index. This will give you a handle to the individual error object (a JavaScript object). You can then query this object for a specific property, including: code, description, priority, timestamp. So, for example, to get the timestamp for the oldest error in the log you would call: jsx3.util.Logger.getLog[0]["timestamp"]

Returns:

JavaScript Array 

getLogger

static jsx3.util.Logger getLogger(strName : String)
Returns an Logger instance. Either creates a new logger or returns a pre-existing logger of the same name. This class is a factory class so instances of Logger may not be instantiated directly. Use this method to get a handle to a logger.

Parameters:

strNamethe name of the logger to return

Returns:

 

getMinPriority

static void getMinPriority()
Deprecated. use Logger.isLoggable()
No errors will be published with priority level less than (integer greater than) this value.

getName

String getName()
Returns the name of this Logger.

Returns:

 

getParent

jsx3.util.Logger getParent()
Returns the parent Logger of this Logger. The global logger will return null from this method.

Returns:

 

getUseParentHandlers

boolean getUseParentHandlers()
Returns whether this Logger will publish log messages to the handlers of its parent Logger.

Returns:

 

info

void info(strMessage : String, strArgs : Array<String> | String... | jsx3.lang.Exception)
Log a message at level INFO. Polymorphic method honors the signature of either log() or logError() (without the first intLevel parameter).

Parameters:

strMessagethe message to log
strArgseither an array of message parameters, variable argument message parameters, or an exception; optional argument

isLoggable

boolean isLoggable(intLevel : int)
Returns true if a log message sent to this logger at level intLevel will be forwarded on to the handlers of this logger.

Parameters:

intLevelthe level to test

Returns:

 

levelAsString

static String levelAsString(intLevel : int)
Returns the string (English) representation of a level value.

Parameters:

intLevela level value between FATAL and TRACE

Returns:

a string representation of the level value  

log

void log(intLevel : int, strMessage : String, strArgs : Array<String> | String...)
Log a message.

Parameters:

intLevelthe level of the message
strMessagethe message to log
strArgseither an array of or variable argument message parameters, optional argument

logError

void logError(intLevel : int, strMessage : String, objError : jsx3.lang.Exception)
Log an exception.

Parameters:

intLevelthe level of the message
strMessagethe message to log with the exception, may be null
objErrorthe exception to log

logError

static void logError(e : Object, PRIORITY : int)
Deprecated. use instance method Logger.logError()
Log all properties of an exception to the system log.

Parameters:

ethe exception object to log
PRIORITYpriority of error

logStack

void logStack(intLevel : int, strMessage : String, intSkip : int)
Log the current stack with a message.

Parameters:

intLevelthe level of the message
strMessagethe message to log, optional argument
intSkip

removeHandler

void removeHandler(objHandler : jsx3.util.Logger.Handler)
Remove a handler from this Logger.

Parameters:

objHandler

reset

static void reset()
Deprecated. no effect
Resets the system out; publishes event to the jsx3.util.Logger.ON_MESSAGE subject.

setLevel

void setLevel(intLevel : int)
Sets the level of this Logger.

Parameters:

intLevel

setParent

void setParent(objParent : jsx3.util.Logger)
Sets the parent Logger of this Logger.

Parameters:

objParent

setUseParentHandlers

void setUseParentHandlers(bUseParent : boolean)
Sets whether this Logger will publish log messages to the handlers of its parent Logger.

Parameters:

bUseParent

toString

static Object toString()
Deprecated. Returns empty string.
returns a text-based version of the error log object. This is helpful when debugging a JSX application that doesn't fully initialize. In practice, if you are viewing a web page with an embedded JSX application, you can type (ctrl + o) to show the browser's 'open' dialog. From there, enter the following bit of Javascript to call this function: javascript:alert(jsx3.util.Logger.toString());

Returns:

JavaScript Array 

Overrides:

toString in jsx3.lang.Object

trace

void trace(strMessage : String, strArgs : Array<String> | String... | jsx3.lang.Exception)
Log a message at level TRACE. Polymorphic method honors the signature of either log() or logError() (without the first intLevel parameter).

Parameters:

strMessagethe message to log
strArgseither an array of message parameters, variable argument message parameters, or an exception; optional argument

warn

void warn(strMessage : String, strArgs : Array<String> | String... | jsx3.lang.Exception)
Log a message at level WARN. Polymorphic method honors the signature of either log() or logError() (without the first intLevel parameter).

Parameters:

strMessagethe message to log
strArgseither an array of message parameters, variable argument message parameters, or an exception; optional argument