AnewtLog class

The AnewtLog class provides static methods for logging.

Class Overview

The AnewtLog class provides static methods for logging.

Public Static Methods

static init($setup_default_handler=false) [static]

Initializes the AnewtLog module.

Parameters

$setup_default_handler

Whether to setup a default handler. If true, a new AnewtLogHandlerDefault instance with default level filtering will be initialized. This parameter defaults to false, which means a log handler needs to be added manually before using the logging facilities.

static add_handler(&$handler, $level=ANEWT_LOG_LEVEL_MESSAGE) [static]

Adds a log handler to the list of log handlers.

Parameters

$handler

A AnewtLogHandlerBase subclass instance

$level

The minimum log level this handler should log messages for. The default is ANEWT_LOG_LEVEL_MESSAGE, which means that normal messages, warnings, critical warnings and errors are logged. Set to ANEWT_LOG_LEVEL_DEBUG to enable logging of all messages, set to ANEWT_LOG_LEVEL_WARNING to only log warnings and higher priority messages.

static set_domain($domain) [static]

Sets the current log domain to the specified domain.

Previous domain names will be remembered (stack-based).

Parameters

$domain

A string with the new domain name.

See also

static reset_domain() [static]

Resets the log domain to the previous domain.

Return value

The current log domain.

See also

static get_domain() [static]

Retrieves the current log domain.

Return value

The current log domain.

See also

static loglevel_to_string($level) [static]

Converts a log level integer to a string representation.

Parameters

$level

The log level to convert, eg. ANEWT_LOG_LEVEL_MESSAGE

Return value

The name for this log level.

static error($message, $args=null) [static]

Log an error.

Parameters

$message

The message to log, with optional sprintf-style placeholders.

$args

One or more parameters (or a single array) with values that will be substituted for the placeholders in $message.

static error_with_domain($domain, $message, $args=null) [static]

Log an error with a custom domain.

This is particularly useful for library routines.

Parameters

$domain

The custom domain

$message

$args

See also

static critical($message, $args=null) [static]

Log a critical warning.

Parameters

$message

$args

See also

static critical_with_domain($domain, $message, $args=null) [static]

Log a critical warning with a custom domain.

Parameters

$domain

$message

$args

See also

static warning($message, $args=null) [static]

Log a warning.

Parameters

$message

$args

See also

static warning_with_domain($domain, $message, $args=null) [static]

Log a warning with a custom domain.

Parameters

$domain

$message

$args

See also

static message($message, $args=null) [static]

Log a normal message.

Parameters

$message

$args

See also

static message_with_domain($domain, $message, $args=null) [static]

Log a normal message with a custom domain.

Parameters

$domain

$message

$args

See also

static info($message, $args=null) [static]

Log an informational message.

Parameters

$message

$args

See also

static info_with_domain($domain, $message, $args=null) [static]

Log an informational message with a custom domain.

Parameters

$domain

$message

$args

See also

static debug($message, $args=null) [static]

Log a debug message.

Parameters

$message

$args

See also

static debug_with_domain($domain, $message, $args=null) [static]

Log a debug message with a custom domain.

Parameters

$domain

$message

$args

See also

Public Methods

__construct()

Constructor throws an error.

Only static usage of this class is allowed.

Private Static Methods

static _is_initialized() [private] [static]

Checks if the AnewtLog module was initialized.

Return value

True if initialized, false otherwise.

static _log($level, $message, $args=null) [private] [static]

Log a message to the output handlers.

Parameters

$level

The message log level. This should be one of the ANEWT_LOG_LEVEL_* constants.

$message

The message itself. sprintf-style placeholders can be specified.

$args

An array with data (optional). These values will be substituted for the placeholders in $message.

static _log_with_domain($domain, $level, $message, $args) [private] [static]

Log a message to the output handlers, temporarily overriding the log domain.

Parameters

$domain

The temporary log domain

$level

$message

$args

See also