Log:
Filter:
Log/Classes (extension) | Language

Log
ExtensionExtension

A simple logging class.

Description

Log is a simple logging class, enabling both simple setup-free logging and more extensive event-based logging.

NOTE: Log is a Singleton, so the common way to access global logs is via the Log constructor. Please refer to the Singleton help file, and examples below.

Class Methods

.logErrors

Enable/disable logging of caught Exceptions.

Arguments:

shouldLog

A Boolean.

NOTE: This creates a root level exception handler to allow logging of all exceptions. This will handle most but NOT all exceptions. Also, be aware that this risks throwing during exception handling, which is almost always bad - this should be considered unstable functionality.

Instance Methods

.critical

Log a message with a level of "debug". By default, these items are shown.

Arguments:

str

A String

... items

Arguments to be passed to str.format (see String: -format)

.error

Log a message with a level of "error". By default, these items are shown.

Arguments:

str

A String

... items

Arguments to be passed to str.format (see String: -format)

.warning

Log a message with a level of "warning". By default, these items are shown.

Arguments:

str

A String

... items

Arguments to be passed to str.format (see String: -format)

.debug

Log a message with a level of "debug". By default, these items are shown.

Arguments:

str

A String

... items

Arguments to be passed to str.format (see String: -format)

.shouldPost

A Boolean enabling / disabling posting of log events to the post window.

.level

A log level. Anything events with this log level or higher will be logged.

Arguments:

inLevel

A Symbol matching an entry in Log.levels (one of \debug, \info, \warning, \error, \critical).

.info

Log a message with a level of "info". By default, these items are shown.

Arguments:

str

A String

... items

Arguments to be passed to str.format (see String: -format)

.maxLength

An Integer representing the maximum log events to keep in the history of this log. This is relevent for log views.

.formatter

A Function of the form { |item, log| }, where item is a log event and log is the parent Log object. Log items are Event objects with at least keys for \string (a string representation of the log event), \level (the log level), and \time. This function should return a formatted or serialized string representation of the log event. Generally, this is used to customize the string output of a specific log.

.actions

An IdentitySet containing functions to be executed for each new log event. Functions should be of the form: { |item, log| }, where item is a log event and log is the parent Log object.

.splitLines

When set to true, multi-line strings will be split over multiple log lines - that is, each will be prepended with the name of the log.

Examples