A plugin for LogLayer that filters log messages. You can filter logs using string patterns, regular expressions, or JSON Queries.
npm install @loglayer/plugin-filter
import { filterPlugin } from '@loglayer/plugin-filter';
// Create a filter that only allows error messages
const filter = filterPlugin({
// checks the assembled message using an includes()
messages: ['error'],
});
// Checks the level of the log
const levelFilter = filterPlugin({
queries: ['.level == "error" or .level == "warn"'],
});
The plugin accepts the following configuration options:
Option | Type | Description |
---|---|---|
messages |
Array<string | RegExp> |
Optional. Array of string patterns or regular expressions to match against log messages |
queries |
string[] |
Optional. Array of JSON queries to filter logs. A JSON Query filter() is applied, which each item being part of an OR condition |
debug |
boolean |
Optional. Enable debug mode for troubleshooting |
disabled |
boolean |
Optional. Disable the plugin |
For more details, visit https://loglayer.dev/plugins/filter