Constructor
# new LogFilter()
Extends LoggedClass to supply a scoped logger and defines the contract required by LoggingFilter implementers that transform or drop log messages before emission.
Base class for message filters that plug 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
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
Returns a child logger dedicated to the filter, preventing recursive filter invocation when emitting diagnostic messages.
Scoped logger that excludes other filters from the chain.
Methods
# abstract filter(config, message, context) → {string}
Inspect the provided message and context to produce the value that will be forwarded to subsequent filters or emitters.
Transform or suppress a log message.
Parameters:
| Name | Type | Description |
|---|---|---|
config |
LoggingConfig
|
Active logging configuration. |
message |
string
|
Original log message payload. |
context |
Array.<string>
|
Context values attached to the message. |
Filtered message to pass to downstream processing.
string