class Logger
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
| Field Summary |
|---|
| static int | Level indicating debug message. |
| static int | Level indicating error. |
| static int | Level indicating fatal error. |
| static jsx3.util.Logger | Convenient access to jsx3.util.Logger.getLogger('global'). |
| static int | Level indicating informational message. |
| static int | Set the level of a Logger or Handler to this value to ignore all messages. |
| static int | Level indicating trace message. |
| static int | Level indicating warning. |
| Method Summary |
|---|
| void | Add a handler to this Logger. |
| void | Log a message at level DEBUG. |
| static void | Deprecated. use either jsx3.log or Logger.log() |
| void | Log a message at level ERROR. |
| static String | |
| void | 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 | 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 | Log a message at level INFO. |
| boolean | 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 | Returns the string (English) representation of a level value. |
| void | Log a message. |
| void | Log an exception. |
| static void | Deprecated. use instance method Logger.logError()
|
| void | Log the current stack with a message. |
| void | Remove a handler from this Logger. |
| static void | |
| void | 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 | Log a message at level TRACE. |
| void | 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 |
Level indicating debug message.
Level indicating fatal error.
Convenient access to jsx3.util.Logger.getLogger('global').
Level indicating informational message.
Set the level of a Logger or Handler to this value to ignore all messages.
Level indicating trace message.
Level indicating warning.
Add a handler to this Logger.
Parameters:
Log a message at level DEBUG. Polymorphic method honors the signature of either log() or
logError() (without the first intLevel parameter).
Parameters:
strMessage – the message to log
strArgs – either an array of message parameters, variable
argument message parameters, or an exception; optional argument
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:
strErrorNumber – arbitrary identifier passed by the calling function to track the specific location of the error
strMessage – message to describe the error
PRIORITY – one of 1, 2 or 3, with 1 being most serious (red..orange..yellow)
bTrace – true if null; if true, the stack trace is printed, displaying the order of the call stack
See Also:
Log a message at level ERROR. Polymorphic method honors the signature of either log() or
logError() (without the first intLevel parameter).
Parameters:
strMessage – the message to log
strArgs – either an array of message parameters, variable
argument message parameters, or an exception; optional argument
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:
Returns:
Log a message at level FATAL. Polymorphic method honors the signature of either log() or
logError() (without the first intLevel parameter).
Parameters:
strMessage – the message to log
strArgs – either an array of message parameters, variable
argument message parameters, or an exception; optional argument
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:
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:
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
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:
strName – the name of the logger to return
Returns:
static void getMinPriority()
Deprecated. use Logger.isLoggable()
No errors will be published with priority level less than (integer greater than) this value.
Returns the name of this Logger.
Returns:
Returns the parent Logger of this Logger. The global logger will return null from this method.
Returns:
Returns whether this Logger will publish log messages to the handlers of its parent Logger.
Returns:
Log a message at level INFO. Polymorphic method honors the signature of either log() or
logError() (without the first intLevel parameter).
Parameters:
strMessage – the message to log
strArgs – either an array of message parameters, variable
argument message parameters, or an exception; optional argument
Returns true if a log message sent to this logger at level intLevel will be forwarded on to the
handlers of this logger.
Parameters:
intLevel – the level to test
Returns:
Returns the string (English) representation of a level value.
Parameters:
intLevel – a level value between FATAL and TRACE
Returns:
a string representation of the level value
Log a message.
Parameters:
intLevel – the level of the message
strMessage – the message to log
strArgs – either an array of or variable argument message parameters, optional argument
Log an exception.
Parameters:
intLevel – the level of the message
strMessage – the message to log with the exception, may be null
objError – the exception to log
static
void logError(e
: Object, PRIORITY
: int)
Deprecated. use instance method Logger.logError()
Log all properties of an exception to the system log.
Parameters:
e – the exception object to log
PRIORITY – priority of error
void logStack(intLevel
: int, strMessage
: String, intSkip
: int)
Log the current stack with a message.
Parameters:
intLevel – the level of the message
strMessage – the message to log, optional argument
intSkip –
Remove a handler from this Logger.
Parameters:
static void reset()
Deprecated. no effect
Resets the system out; publishes event to the jsx3.util.Logger.ON_MESSAGE subject.
void setLevel(intLevel
: int)
Sets the level of this Logger.
Parameters:
Sets the parent Logger of this Logger.
Parameters:
void setUseParentHandlers(bUseParent
: boolean)
Sets whether this Logger will publish log messages to the handlers of its parent Logger.
Parameters:
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:
Log a message at level TRACE. Polymorphic method honors the signature of either log() or
logError() (without the first intLevel parameter).
Parameters:
strMessage – the message to log
strArgs – either an array of message parameters, variable
argument message parameters, or an exception; optional argument
Log a message at level WARN. Polymorphic method honors the signature of either log() or
logError() (without the first intLevel parameter).
Parameters:
strMessage – the message to log
strArgs – either an array of message parameters, variable
argument message parameters, or an exception; optional argument
Copyright © 2001-2011, TIBCO Software Inc.