Class

LogFilter

LogFilter()

Constructor

# new LogFilter()

This class extends LoggedClass to supply a scoped logger, and defines the contract that is required by LoggingFilter implementers that transform or drop log messages before emission.

A base class for message filters that can be plugged into the logging pipeline.

sequenceDiagram participant Logger participant Filter as LogFilter participant Impl as ConcreteFilter participant Output Logger->>Filter: filter(config, message, context) Filter->>Impl: delegate to subclass implementation Impl-->>Filter: transformed message Filter-->>Output: return filtered message

View Source filters/LogFilter.ts, line 3

Example
class RedactSecretsFilter extends LogFilter {
  filter(config: LoggingConfig, message: string): string {
    return message.replace(/secret/gi, "***");
  }
}

const filter = new RedactSecretsFilter();
filter.filter({ ...DefaultLoggingConfig, verbose: 0 }, "secret token");

Members

# log

This method returns a child logger that is dedicated to the filter, which prevents recursive filter invocation when emitting diagnostic messages.

A scoped logger that excludes other filters from the chain.

View Source filters/LogFilter.ts, line 33

Methods

# abstract filter(config, message, context) → {string}

This method inspects the provided message and context to produce the value that will be forwarded to subsequent filters or emitters.

Transforms or suppresses a log message.

Parameters:
Name Type Description
config LoggingConfig

The active logging configuration.

message string

The original log message payload.

context Array.<string>

The context values that are attached to the message.

View Source filters/LogFilter.ts, line 58

The filtered message to pass to downstream processing.

string

# log() → {Logger}

This method returns a child logger that is dedicated to the filter, which prevents recursive filter invocation when emitting diagnostic messages.

A scoped logger that excludes other filters from the chain.

View Source filters/LogFilter.ts, line 47

A context-aware logger for the filter instance.

Logger