@loglayer/plugin-filter
TypeScript icon, indicating that this package has built-in type declarations

2.1.0 • Public • Published

Log filtering plugin for LogLayer

NPM Version NPM Downloads TypeScript

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-filter

Usage

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

Package Sidebar

Install

npm i @loglayer/plugin-filter

Homepage

loglayer.dev

Weekly Downloads

365

Version

2.1.0

License

MIT

Unpacked Size

39.5 kB

Total Files

9

Last publish

Collaborators

  • theo.gravity