Class Logger

A Logger is responsible for creating the log messages and propagating these to the appenders. It is initialized with a ref fragment in order to be assigned to a specific software unit. In order to provide fully qualified refs, the loggers will hold a reference to its parent. The same applies to the origin and category parameters.

Version

1

Hierarchy (view full)

Constructors

Properties

_category: null | string | Category = null

The fallback category, if none is specified via the category() method.

_localAppenders: IAppender[] = []

Stores logger-local appenders.

_onceIds: string[] = []

Stores ids of messages that are to be logged only once.

_origin: null | string = null

A fallback origin, if none is specified via the origin() method. If the parent of this logger is set, it derives its origin from there.

_parent: null | AbstractLogger = null

The parent logger of which to optain the parent ref fragment.

_ref: string = ":"

The ref fragment.0

Severity: typeof Severity = Severity
_rootLogger: AbstractLogger = ...

The root logger.

appenders: IAppender[] = []

The root logger.

fallBackMessagesCache: null | LogMessage[] = []

Caches log messages that have not been handled due to missing fallback appender.

fallbackAppenders: IAppender[] = []

The root logger.

Accessors

Methods

  • Determines the log message origin based on the origin configured and the globally set origin. If the origins of this logger and the root are set and differ, they will be concatenated using a slash ('/).

    Parameters

    • Optional explicitOrigin: null | string

      The origin configured in this logger is extensible by an explicit string specified.

    Returns null | string

  • If the implementor of this interface provides a category, the category string will be determined in form of a string with the syntax 'Category.Subcategory.*'. If the category specified in this object starts with a period ('.'), it is appended to this and/or a parent logger's category.

    Parameters

    • Optional explicitCategory: null | string | Category

      The category specified to this object can be overridden by providing an absolute category string (not starting with period) or a category object.

    Returns null | string

  • The implementor of this interface provides a ref fragment, else, a parent's ref will be used. If it also provides a parent logger entity, its ref fragment will be prepended to this ref fragment so that the resulting ref string has the syntax 'Module:SubModule:*:Class:Function' of which every element is optional.

    Parameters

    • Optional subRef: null | string

      If specified, this ref will be appended to the logger's basic ref.

    Returns string

  • Receives an internal log message from a log message builder instance in order to create a corresponding log message object. The created message object is then forwared to the appender or fallback appender channel.

    Parameters

    Returns void

  • Sets a category for the next log message. The respective log method must be called on the returned object (method chaining). The returned object allows to call more parameter specifying methods. If the returned object is withdrawn, the set category information is lost. The category of the new log message defaults to the logger's category.

    Parameters

    • category: string | Category

      The category to set for the next log message. If a Category object or a string is provided, it will be used as the actual category of the message. If a string is provided that starts with a period, e.g. '.subcategory', it will be used as a sub category of the parent logger's category. The categories will then be concatenated separated by a perios ('.').

    Returns ILogger

    The log message builder object that allows to specify more parameters of the next log message.

  • For debugging purposes.

    Parameters

    • message: string

      The actual log message.

    • Optional parameters: null | object

      The log message parameters. Its keys will replace the '%key%' placeholders in the message string.

    Returns ILogger

  • Errors due to malconfiguration of the software.

    Parameters

    • message: string

      The actual log message.

    • Optional parameters: null | object

      The log message parameters. Its keys will replace the '%key%' placeholders in the message string.

    Returns ILogger

  • Sets the next log message to be appended to the fallback appender. The respective log method must be called on the returned object (method chaining). If the returned object is withdrawn, the set fallback information is lost. This disables the evaluation of message filters to the appenders. The log framework does this internally, if errors in custom code or appenders occur.

    Parameters

    • fallBack: boolean = true

      If true, the next message will be handled by a fallback appender.

    Returns ILogger

    The returned object allows to call more parameter specifying methods.

  • Unintended behaviour of the software, e.g. unhandled exceptions.

    Parameters

    • message: string

      The actual log message.

    • Optional parameters: null | object

      The log message parameters. Its keys will replace the '%key%' placeholders in the message string.

    Returns ILogger

  • Determines a registerable once id. If a once id is set for the message, it is used. Else, if a message id is set, it is used, prepended with the severity level. If no id is set, the message is used prepended with the severity level.

    Parameters

    Returns undefined | string

    the registerable id if found, or undefined, if not available

  • Sets the id for the next log message. The respective log method must be called on the returned object (method chaining). The returned object allows to call more parameter specifying methods. If the returned object is withdrawn, the set id information is lost.

    Parameters

    • id: string

      The id to set for the next log message

    Returns ILogger

    The log message builder object that allows to specify more parameters of the next log message.

  • Information about the actions that are executed by the software. For User feedback.

    Parameters

    • message: string

      The actual log message.

    • Optional parameters: null | object

      The log message parameters. Its keys will replace the '%key%' placeholders in the message string.

    Returns ILogger

  • Creates a new LogMessage by calling the abstract methods in this interface.

    Parameters

    • severity: Severity

      The severity of the log message. Possible values are specified by the LogMessage.Severity Enum.

    • message: string

      The actual log message.

    • Optional parameters: null | object

      The log message parameters. Its keys will replace the '%key%' placeholders in the message string.

    Returns ILogger

  • Sets the onceId for the new log message. The respective log method must be called on the returned object (method chaining). If the returned object is withdrawn, the set fallback information is lost. If set, other messages using the same onceid will not be handled.

    Parameters

    • Optional onceId: string | boolean

      if set to true, only, the combination of loglevel, id or message text will be used for identifying similar messages

    Returns ILogger

  • Sets the origin (current environment) for the next log message. The respective log method must be called on the returned object (method chaining). The returned object allows to call more parameter specifying methods. If the returned object is withdrawn, the set origin information is lost. The origin of the new log message defaults to the logger's origin. If providing an origin that differs from the logger's origin, the strings are concatenated separated by a slash ('/')

    Parameters

    • origin: string

      The origin to set for the next log message

    Returns ILogger

    The log message builder object that allows to specify more parameters of the next log message.

  • Sets a ref fragment for the next log message. The respective log method must be called on the returned object (method chaining). The returned object allows to call more parameter specifying methods. If the returned object is withdrawn, the set ref fragment information is lost. The ref fragment of the new log message defaults to the logger's ref fragment. All fragments in the chain of loggers are concatenated separated by a colon (':')

    Parameters

    • ref: string

      The ref fragment to set for the next log message

    Returns ILogger

    The log message builder object that allows to specify more parameters of the next log message.

  • Sets the category of this logger.

    Parameters

    Returns void

  • Sets the origin of this logger.

    Parameters

    • origin: null | string

    Returns void

  • Creates a new logger instance as a child of this logger.

    Parameters

    • ref: string

      The ref fragment of the source code organization unit (e.g. module, class, function) that requests the new logger.

    • Optional category: null | string | Category

      The (new sub-/root-) category of the new logger.

    • Optional origin: null | string

      The origin of the new logger.

    Returns AbstractLogger

  • The most verbose output level.

    Parameters

    • message: string

      The actual log message.

    • Optional parameters: null | object

      The log message parameters. Its keys will replace the '%key%' placeholders in the message string.

    Returns ILogger

  • Warnings about unintended behaviour or usage of the software or possible security and safety risks.

    Parameters

    • message: string

      The actual log message.

    • Optional parameters: null | object

      The log message parameters. Its keys will replace the '%key%' placeholders in the message string.

    Returns ILogger

  • Adds a new appender to the root logger.

    Parameters

    Returns void

  • Adds a new fallback appender. If the appender specified is the first explicit fallback appender, it will receive all cached log messages that have not been appended yet. The internal log message cache should be disabled, if no functional fallback appender is intended to be added to the log interface.

    Parameters

    Returns void