Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Logger

Abstract logger that captures and formats log messages. Child classes take the captured messages and write them to their specific destinations.

Configuration parameters

Parameters to pass to the configure method for component configuration:

  • level: maximum log level to capture
  • source: source (context) name

References

  • *:context-info:*:*:1.0 (optional) ContextInfo to detect the context id and specify counters source
see

ILogger

Hierarchy

Implements

Index

Constructors

Protected constructor

  • Creates a new instance of the logger.

    Returns Logger

Properties

Protected _level

_level: LogLevel = LogLevel.Info

Protected _source

_source: string = null

Methods

Protected composeError

  • composeError(error: Error): string
  • Composes an human-readable error description

    Parameters

    • error: Error

      an error to format.

    Returns string

    a human-reable error description.

configure

  • configure(config: ConfigParams): void
  • Configures component by passing configuration parameters.

    Parameters

    • config: ConfigParams

      configuration parameters to be set.

    Returns void

debug

  • debug(correlationId: string, message: string, ...args: any[]): void
  • Logs a high-level debug information for troubleshooting.

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • message: string

      a human-readable message to log.

    • Rest ...args: any[]

      arguments to parameterize the message.

    Returns void

error

  • error(correlationId: string, error: Error, message: string, ...args: any[]): void
  • Logs recoverable application error.

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • error: Error

      an error object associated with this message.

    • message: string

      a human-readable message to log.

    • Rest ...args: any[]

      arguments to parameterize the message.

    Returns void

fatal

  • fatal(correlationId: string, error: Error, message: string, ...args: any[]): void
  • Logs fatal (unrecoverable) message that caused the process to crash.

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • error: Error

      an error object associated with this message.

    • message: string

      a human-readable message to log.

    • Rest ...args: any[]

      arguments to parameterize the message.

    Returns void

Protected formatAndWrite

  • formatAndWrite(level: LogLevel, correlationId: string, error: Error, message: string, ...args: any[]): void
  • Formats the log message and writes it to the logger destination.

    Parameters

    • level: LogLevel

      a log level.

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • error: Error

      an error object associated with this message.

    • message: string

      a human-readable message to log.

    • Rest ...args: any[]

      arguments to parameterize the message.

    Returns void

getLevel

  • Gets the maximum log level. Messages with higher log level are filtered out.

    Returns LogLevel

    the maximum log level.

getSource

  • getSource(): string
  • Gets the source (context) name.

    Returns string

    the source (context) name.

info

  • info(correlationId: string, message: string, ...args: any[]): void
  • Logs an important information message

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • message: string

      a human-readable message to log.

    • Rest ...args: any[]

      arguments to parameterize the message.

    Returns void

log

  • log(level: LogLevel, correlationId: string, error: Error, message: string, ...args: any[]): void
  • Logs a message at specified log level.

    Parameters

    • level: LogLevel

      a log level.

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • error: Error

      an error object associated with this message.

    • message: string

      a human-readable message to log.

    • Rest ...args: any[]

      arguments to parameterize the message.

    Returns void

setLevel

  • Set the maximum log level.

    Parameters

    • value: LogLevel

      a new maximum log level.

    Returns void

setReferences

  • setReferences(references: IReferences): void
  • Sets references to dependent components.

    Parameters

    • references: IReferences

      references to locate the component dependencies.

    Returns void

setSource

  • setSource(value: string): void
  • Sets the source (context) name.

    Parameters

    • value: string

      a new source (context) name.

    Returns void

trace

  • trace(correlationId: string, message: string, ...args: any[]): void
  • Logs a low-level debug information for troubleshooting.

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • message: string

      a human-readable message to log.

    • Rest ...args: any[]

      arguments to parameterize the message.

    Returns void

warn

  • warn(correlationId: string, message: string, ...args: any[]): void
  • Logs a warning that may or may not have a negative impact.

    Parameters

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • message: string

      a human-readable message to log.

    • Rest ...args: any[]

      arguments to parameterize the message.

    Returns void

Protected Abstract write

  • write(level: LogLevel, correlationId: string, error: Error, message: string): void
  • Writes a log message to the logger destination.

    Parameters

    • level: LogLevel

      a log level.

    • correlationId: string

      (optional) transaction id to trace execution through call chain.

    • error: Error

      an error object associated with this message.

    • message: string

      a human-readable message to log.

    Returns void

Generated using TypeDoc