ConsoleLogger

Logger that writes log messages to console.

Extends: Logger

Description

The ConsoleLogger class provides a logger that writes log messages to console.

Important points

  • Errors are written to standard err stream and all other messages to standard out stream.

Configuration parameters

  • 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

Instance methods

write

Writes a log message to the logger destination.

public write(level: LogLevel, context: IContext, error: Error, message: string): void

  • level: LogLevel - a log level.
  • context: IContext - (optional) a context to trace execution through call chain.
  • error: Error - an error object associated with this message.
  • message: string - a human-readable message to log.

Examples

let logger = new ConsoleLogger();
logger.setLevel(LogLevel.debug);

logger.error(new Context(), ex, "Error occured: %s", ex.message);
logger.debug(new Context(), "Everything is OK.");

See also