Jaxer.Log : Object
Return to: Jaxer Framework index

Log is a static object meant to be shared across the framework and perhaps even the user's code. In a module, use it to create a module-specific logger and then log with it.

Platform Support

Jaxer Server FrameworkJaxer Client Framework
1.0no

Classes

Jaxer.Log.Appender
Jaxer.Log.CoreAppender
Jaxer.Log.FileAppender
Jaxer.Log.Level
Jaxer.Log.ModuleLogger

Functions

MethodActionJaxer Server FrameworkJaxer Client Framework
static addAppender(String name, Jaxer.Log.Appender appender) : void
Add an appender to the referenced Log object

(Advanced)
Show Details1.0no

Parameters
StringnameThe name of the appender
Jaxer.Log.AppenderappenderAn instance of the appender. It should be derived from Jaxer.Log.Appender.

static getAppender(String name) : Jaxer.Log.Appender
Get an appender reference from the referenced Log object

(Advanced)
Show Details1.0no

Parameters
StringnameThe name of the appender to look for

Returns
Jaxer.Log.AppenderThe appender instance

static getLevelNames() : String[]
Return a array of implemented Logger levelnames e.g. "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL"

(Advanced)
Show Details1.0no

Returns
String[]

static getSortedModuleNames() : Array
Gets a sorted array of all the currently-defined modules.

(Advanced)
Show Details1.0no

Returns
ArrayAn array of strings, sorted alphabetically, of the names of modules for which ModuleLoggers have been defined.

static removeAppender(String name) : void
Remove the specified appender from the referenced Log object

(Advanced)
Show Details1.0no

Parameters
StringnameThe name of the appender to use.

static debug(String message, [Error exception,] [Function inFunction]) : void
Logs a message at the "DEBUG" level. The message will only be appended to the log if the level for that module (and that appender) is set at or below Jaxer.Log.DEBUG. This is the second-most verbose level - instrument your code with debug() calls in those places where debugging is likely to benefit from them.
Show Details1.0no

Parameters
StringmessageThe message to append to the log. The timestamp, modulename, and terminating newline will be added automatically.
Errorexception(optional)An optional error or exception to be logged with this message
FunctioninFunction(optional)An optional indication of which function this message should appear to originate from. By default, it's the function that called this logging method.

static error(String message, [Error exception,] [Function inFunction]) : void
Logs a message at the "ERROR" level. The message will only be appended to the log if the level for that module (and that appender) is set at or below Jaxer.Log.ERROR. Use this to log non-fatal but nonetheless real errors.
Show Details1.0no

Parameters
StringmessageThe message to append to the log. The timestamp, modulename, and terminating newline will be added automatically.
Errorexception(optional)An optional error or exception to be logged with this message
FunctioninFunction(optional)An optional indication of which function this message should appear to originate from. By default, it's the function that called this logging method.

static fatal(String message, [Error exception,] [Function inFunction]) : void
Logs a message at the "FATAL" level. The message will only be appended to the log if the level for that module (and that appender) is set at or below Jaxer.Log.FATAL. Use this to log the most serious errors.
Show Details1.0no

Parameters
StringmessageThe message to append to the log. The timestamp, modulename, and terminating newline will be added automatically.
Errorexception(optional)An optional error or exception to be logged with this message
FunctioninFunction(optional)An optional indication of which function this message should appear to originate from. By default, it's the function that called this logging method.

static forModule(String moduleName) : Jaxer.Log.ModuleLogger
Lazily creates a logger for the given module name, if needed, and in any case returns it. The referenced Log object knows to create log entries marked as belonging to the specific module.
Show Details1.0no

Parameters
StringmoduleNameThe name of the module (just an identifier string).

Returns
Jaxer.Log.ModuleLoggerThe module-specific logger to use for log entries.

static getLevel() : Jaxer.Log.Level
Get the logging level of the generic logger
Show Details1.0no

Returns
Jaxer.Log.LevelThe level below which non-module-specific messages will not be logged

static getStackTrace([String linePrefix,] [Number framesToSkip]) : String
Get the current JavaScript stack trace.
Show Details1.0no

Parameters
StringlinePrefix(optional)An optional prefix (e.g. whitespace for indentation) to prepend to every line of the stack trace
NumberframesToSkip(optional)An optional number of frames to skip before starting to trace the remaining frames

Returns
StringThe stack trace as a string consisting of a number of lines, starting at the deepest frame

static getStackTraceAlt([String linePrefix,] [Number framesToSkip]) : String
Get the current JavaScript stack trace.
Show Details1.0no

Parameters
StringlinePrefix(optional)An optional prefix (e.g. whitespace for indentation) to prepend to every line of the stack trace
NumberframesToSkip(optional)An optional number of frames to skip before starting to trace the remaining frames

Returns
StringThe stack trace as a string consisting of a number of lines, starting at the deepest frame

static hasModule(String moduleName) : Boolean
Returns a boolean to indicate whether the referenced Log object is wired to do logging for the provided modulename
Show Details1.0no

Parameters
StringmoduleNameThe name of the module to look up

Returns
Boolean

static info(String message, [Error exception,] [Function inFunction]) : void
Logs a message at the "INFO" level. The message will only be appended to the log if the level for that module (and that appender) is set at or below Jaxer.Log.INFO. By default, modules are set to show messages at this level, so use info() when you want to show log messages without needing to set the level to more verbose than usual, but don't keep info() messages in your code long term.
Show Details1.0no

Parameters
StringmessageThe message to append to the log. The timestamp, modulename, and terminating newline will be added automatically.
Errorexception(optional)An optional error or exception to be logged with this message
FunctioninFunction(optional)An optional indication of which function this message should appear to originate from. By default, it's the function that called this logging method.

static setAllModuleLevels(Jaxer.Log.Level level) : void
Set the logging level on ALL modules to level provided for the referenced Log object
Show Details1.0no

Parameters
Jaxer.Log.LevellevelThe new level to use for all of them

static setLevel(Jaxer.Log.Level level) : void
Set the logging level for the generic logger (the one that's not module- specific)
Show Details1.0no

Parameters
Jaxer.Log.LevellevelThe level to use on the generic logger messages below this level will not be logged.

static trace(String message, [Error exception,] [Function inFunction]) : void
Logs a message at the "TRACE" level. The message will only be appended to the log if the level for that module (and that appender) is set at Jaxer.Log.TRACE. This is the most verbose level - instrument your code liberally with trace() calls to be able to pinpoint any issues.
Show Details1.0no

Parameters
StringmessageThe message to append to the log. The timestamp, modulename, and terminating newline will be added automatically.
Errorexception(optional)An optional error or exception to be logged with this message
FunctioninFunction(optional)An optional indication of which function this message should appear to originate from. By default, it's the function that called this logging method.

static warn(String message, [Error exception,] [Function inFunction]) : void
Logs a message at the "WARN" level. The message will only be appended to the log if the level for that module (and that appender) is set at or below Jaxer.Log.WARN. Use this to warn of any unusual or unexpected, but not necessarily erroneous, conditions.
Show Details1.0no

Parameters
StringmessageThe message to append to the log. The timestamp, modulename, and terminating newline will be added automatically.
Errorexception(optional)An optional error or exception to be logged with this message
FunctioninFunction(optional)An optional indication of which function this message should appear to originate from. By default, it's the function that called this logging method.

Examples

To log without a module name, use Jaxer.Log.info("my message"), where instead of info you can use any of the six logging levels: trace(...), debug(...), info(...), warn(...), error(...), and fatal(...). The generic logger is set by default to only log messages at or above the info level.
To log with a module name, first define a log helper: var log = Jaxer.Log.forModule("myModule"); This will get or create the module logger with this name. Then use log.info(...) or any of the other methods. The default level of messages to log is set in configLog.js (default and local) and can also be changed in memory:

aptana_docs