@loglayer/plugin-filter
v3.0.12
Published
Filter logs with LogLayer using string patterns, regular expressions, or JSON Queries.
Downloads
1,412
Maintainers
Readme
Log filtering plugin for LogLayer
A plugin for LogLayer that filters log messages. You can filter logs using string patterns, regular expressions, or JSON Queries.
Installation
npm install @loglayer/plugin-filterUsage
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"'],
});Configuration
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 |
Documentation
For more details, visit https://loglayer.dev/plugins/filter
