Module: SimpleLoggerProvider

SimpleLoggerProvider

Simple LoggerProvider implementation that can be used to consume LoggerManager logging. To enable client logging, an instance of this class has to be created and supplied through the LoggerManager.setLoggerProvider method before any log can be consumed.
In order to determine how to consume the log, one or multiple "appenders" can be supplied to this object, through SimpleLoggerProvider#addLoggerAppender. The Logger instances created by this LoggerProvider for the various log categories will forward the log lines to the appenders, based on the appender preferences configured. Category and level filters are available and can be configured on each appender.
Several appender classes are distributed with the library in order to enable custom code to consume the log in different ways: ConsoleAppender, AlertAppender, DOMAppender, FunctionAppender and BufferAppender.

The SimpleLoggerProvider is available for the implementation of custom logging; just invoke the LoggerProvider#getLogger method to get Logger objects for custom categories, then invoke the various methods available on the loggers to produce log messages to be handled by the configured appenders.
Empty constructor for SimpleLoggerProvider.

Extends

Method Summary

addLoggerAppender
Adds a SimpleLogAppender to this SimpleLoggerProvider instance.
dispatchLog
Publish a log message on all SimpleLogAppender object instances added to this SimpleLoggerProvider so far.
getLogger
Logger factory that gets a logger related to a specified category name.
removeLoggerAppender
Removes a SimpleLogAppender from this SimpleLoggerProvider instance.

Method Detail

addLoggerAppender(logAppender)

Adds a SimpleLogAppender to this SimpleLoggerProvider instance. Such appender will receive log lines from the Logger instances generated by this SimpleLoggerProvider instance. The appender defines a category and a threshold level, so that it will receive only the log lines with a level equal to or greater than the threshold and only from the Logger associated with the requested category.
Appenders can be added at any time; any loggers already created by this SimpleLoggerProvider instance will start using the new appender. Until the first appender is added, all log will be discarded.
Parameters:
Name Type Description
logAppender SimpleLogAppender An instance of SimpleLogAppender that will consume the log.

dispatchLog(category, level, mex)

Publish a log message on all SimpleLogAppender object instances added to this SimpleLoggerProvider so far.
Parameters:
Name Type Description
category String The category name that produced the given message.
level String The logging level of the given message. It should be one of DEBUG INFO WARN ERROR FATAL constants values.
mex * The message to be logged. It could be a String instance, an Error instance or any other object, provided that it has a toString method.

getLogger(category) → {Logger}

Logger factory that gets a logger related to a specified category name. If such logger does not exist it is created. A unique instance is always maintained for each logger name. This method can potentially cause a memory leak as once a Logger is created it will never be dismissed. It is expected that the number of categories within a single application is somewhat limited and in any case not growing with time.
Parameters:
Name Type Description
category String The name of the desired log category.
Returns:
The desired Logger instance.
Type
Logger

removeLoggerAppender(logAppender)

Removes a SimpleLogAppender from this SimpleLoggerProvider instance.
Appenders can be removed at any time.
Parameters:
Name Type Description
logAppender SimpleLogAppender An instance of SimpleLogAppender that was previously added to this SimpleLoggerProvider instance.
See:
  • addLoggerAppender