# 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.
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.
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. |
The filtered message to pass to downstream processing.
string