CapturingLogger targets testing jivs. It captures all qualifying logged objects and makes them available for unit tests to evaluate.

Use either its containsLog() or findMessage() methods to search for a log that matches the criteria.

It respects the minLevel set in the constructor and supports the overrideMinLevelWhen() overrides.

It is often used together with ConsoleLoggerService to capture logs. Just pass the ConsoleLoggerService into the constructor.

Hierarchy (view full)

Constructors

Properties

captured: CapturedLogDetails[] = []

Accessors

  • get chainedLogger(): null | ILoggerService
  • Reference to another ILogger implementation that gets called after the console's logging. Optional. Will only be called if this logger instance has level >= minLevel or an override. Its own MinLevel will be changed to Debug because this logger expects chainedLogger to output all log entries. However, you can set the minLevel on chainedLogger after this assignment to control what it outputs.

    Returns null | ILoggerService

  • set chainedLogger(logger): void
  • Reference to another ILogger implementation that gets called after the console's logging. Optional. Will only be called if this logger instance has level >= minLevel or an override. Its own MinLevel will be changed to Debug because this logger expects chainedLogger to output all log entries. However, you can set the minLevel on chainedLogger after this assignment to control what it outputs.

    Parameters

    Returns void

Methods

  • Looks for a log that contains any of the criteria in the parameters. All criteria must match for a log to be found.

    Parameters

    • messageSegment: null | string | RegExp

      a string or RegExp to match against the message. When null, it is not used. When string, it is a partial case insensitivie match.

    • Optional logLevel: null | LoggingLevel

      the log level to match. When null/undefined, it is not used.

    • Optional category: null | string

      the category to match. When null/undefined, it is not used.

    • Optional more: FindMoreCapturedLogDetails

      additional filters to apply: type, feature, identity, hasData, data.

    Returns boolean

    true when a matching log is found, false otherwise.

  • Looks through all captures in order found. If any contain all matching values, it is returned. messageSegment and sourceSegment allow a partial match (case insensitive). Null parameters are not used for searching.

    Parameters

    • messageSegment: null | string | RegExp

      a string or RegExp to match against the message. When null, it is not used. When string, it is a partial case insensitivie match.

    • Optional logLevel: null | LoggingLevel

      the log level to match. When null/undefined, it is not used.

    • Optional category: null | string

      the category to match. When null/undefined, it is not used.

    • Optional more: FindMoreCapturedLogDetails

      additional filters to apply: type, feature, identity, hasData, data.

    Returns null | CapturedLogDetails

    the first matching capture or null if none found.

Generated using TypeDoc v0.25.12