Module ringo/logging

This module provides generic logging support for Ringo applications. It uses SLF4J or Apache log4j if either is detected in the classpath, and will fall back to java.util.logging otherwise.

If the first argument passed to any of the logging methods is a string containing any number of curly bracket pairs ({}), the logger will interpret it as format string and use any following arguments to replace the curly bracket pairs. If an argument is an Error or Java Exception object, the logger will render a stack trace for it and append it to the log message.

This module's exports object implements the [EventEmitter](../events/) interface and emits logged messages using the log level name as event type.

Functions


Logger (name, impl)

Logger class. This constructor is not exported, use this module's {@link getLogger} to get a logger instance.

Parameters

name the Logger name
impl the logger implementation

See


Logger.prototype.debug ()


Logger.prototype.error ()


Logger.prototype.info ()


Logger.prototype.isDebugEnabled ()


Logger.prototype.isErrorEnabled ()


Logger.prototype.isInfoEnabled ()


Logger.prototype.isTraceEnabled ()


Logger.prototype.isWarnEnabled ()


Logger.prototype.trace ()


Logger.prototype.warn ()


getJavaStack (error, prefix)

Get a rendered JavaScript stack trace from a caught error.

Parameters

Error error an error object
String prefix to prepend to result if available

Returns

String the rendered JavaScript stack trace

getLogger (name)

Get a logger for the given name.

Parameters

string name the name of the logger

Returns

Logger a logger instance for the given name

getScriptStack (error, prefix)

Get a rendered JavaScript stack trace from a caught error.

Parameters

Error error an error object
String prefix to prepend to result if available

Returns

String the rendered JavaScript stack trace

setConfig (resource, watchForUpdates)

Configure log4j using the given file resource.

If you plan to update the configuration make sure to set the reset property to true in your configuration file.

Parameters

Resource resource the configuration resource in XML or properties format
Boolean watchForUpdates if true a scheduler thread is started that repeatedly checks the resource for updates.