Class LogMessage

The LogMessage is the internal formal object containing all relevant information of an event that is to be logged.

Version

1

Hierarchy (view full)

Constructors

  • Parameters

    • severity: Severity

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

    • id: null | string

      An id that can be set in order to identify a specific log message.

    • category: null | string | Category

      The category classifying the log message. The syntax is 'Category.Subcategory.*'.

    • ref: string

      The reference to the source code structural entity ("Module:Submodule:Class:Function") where the log message has been created.

    • origin: null | string

      An optional origin (runtime environment, process id, etc.) where the instance of the code from where the message originates has been executed.

    • message: string

      The actual message containing '%key%' entries that will be replaced with the values of the respective keys in the parameters object.

    • parameters: null | object

      An optional parameters object containing some parameters that are to be inserted into the message string.

    • onceId: null | string | boolean

      An id to enable messages to be logged only once. If set to true, the id must be set in order to prevent the message from being logged twice

    • Optional time: Date

    Returns LogMessage

Properties

_category: null | string | Category

The category classifying the log message. The syntax is 'Category.Subcategory.*'.

_id: null | string

An id that can be set in order to identify a specific log message.

_message: string

The actual message containing '%key%' entries that will be replaced with the values of the respective keys in the parameters object.

_onceId: null | string | boolean

An id that enables the message to be logged only once. If set to true, at least the message id must be set.

_origin: null | string

An optional origin (runtime environment, process id, etc.) where the instance of the code from where the message originates has been executed.

_parameters: null | object

An optional parameters object containing some parameters that are to be inserted into the message string.

_ref: string

The reference to the source code structural entity ("Module:Submodule:Class:Function") where the log message has been created.

_severity: Severity

The severity of the log message.

_time: Date

The time of creation of the log message.

NO_MESSAGE: string = "NO_MESSAGE"
NO_REF: string = "NO_REF"

Accessors

  • get category(): null | string | Category
  • The category classifying the log message. The syntax is 'Category.Subcategory.*'.

    Returns null | string | Category

  • get id(): null | string
  • An id that can be set in order to identify a specific log message.

    Returns null | string

  • get message(): string
  • The actual message containing '%key%' entries that will be replaced with the values of the respective keys in the parameters object.

    Returns string

  • get onceId(): null | string | boolean
  • An id that enables the message to be logged only once. If set to true, at least the message id must be set.

    Returns null | string | boolean

  • get origin(): null | string
  • An optional origin (runtime environment, process id, etc.) where the instance of the code from where the message originates has been executed.

    Returns null | string

  • get parameters(): null | object
  • An optional parameters object containing some parameters that are to be inserted into the message string.

    Returns null | object

  • get ref(): string
  • The reference to the source code structural entity ("Module:Submodule:Class:Function") where the log message has been created.

    Returns string

  • get time(): Date
  • The time of creation of the log message.

    Returns Date

Methods

  • Serializes an error object to JSON. Adds extended error properties like fileName and lineNumber.

    Parameters

    • e: Error & {
          columnNumber?: number;
          description?: string;
          fileName?: string;
          lineNumber?: string;
          number?: number;
      }

      The error object, that shall to be serialized.

    Returns {
        columnNumber: undefined | number;
        description: undefined | string;
        fileName: undefined | string;
        lineNumber: undefined | string;
        message: string;
        name: string;
        number: undefined | number;
        stack: undefined | string;
    }

    the serialized error object

    • columnNumber: undefined | number
    • description: undefined | string
    • fileName: undefined | string
    • lineNumber: undefined | string
    • message: string
    • name: string
    • number: undefined | number
    • stack: undefined | string
  • Inserts the parameters of the logmessage into the '%key%' placeholders within the message string. Only members of a primitive value in the parameters object will be printed to the message. Nested objects are supported in a way that the message may have paths as placeholders, e.g. '%key.subkey.subkey%'. Circular parameter objects are supported whilst not being encouraged, so that the same value may appear per different paths.

    Parameters

    • Optional message: string

      An optional string to update with the log message parameters. If not provided, the log message string will be used.

    Returns null | string

    the updated message string or null, if no message string is provided or stored in the current object.

  • serializes the message to a self-contained serializable json object.

    Returns object

  • Transforms the log message object to a json-string. Circular references or duplicate objects in the parameters object are handled prior to serialization. Error objects are transformed into plain json objects.

    Parameters

    • pretty: string | number | boolean = false

      Whether to generate human-readable JSON. String or number parameters will be used to set the indentation.

    Returns string

  • Serialized the log message to an XML string representation.

    Parameters

    • pretty: boolean = false

      Whether to generate human-readable XML.

    Returns string

    An XML string containing the message data.

  • Creates a log message object from a json-string.

    Parameters

    • json: string

      The stringyfied message.

    Returns null | LogMessage

    The restored log message.

  • Deserializes an XML string into a log message object.

    Parameters

    • xml: string

      The XML log message string.

    Returns LogMessage

    The deserealized log message object.