@holz/pattern-filter 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +32 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # `@holz/pattern-filter`
2
+
3
+ `@holz/pattern-filter` is a library that allows you to conditionally filter out logs based on a set of patterns. It can be used in combination with other plugins like [`@holz/console-backend`](https://github.com/PsychoLlama/holz/tree/main/packages/holz-console-backend) or [`@holz/ansi-terminal-backend`](https://github.com/PsychoLlama/holz/tree/main/packages/holz-ansi-terminal-backend) to process and display filtered logs.
4
+
5
+ ## Usage
6
+
7
+ To use `@holz/pattern-filter`, you first need to import it and create a filter with `createPatternFilter()`:
8
+
9
+ ```typescript
10
+ import { createPatternFilter } from '@holz/pattern-filter';
11
+
12
+ const filter = createPatternFilter({
13
+ pattern: 'my-app*, library*, -library:chatty*',
14
+ processor: plugin,
15
+ });
16
+ ```
17
+
18
+ The `pattern` option is a comma-separated list of patterns that determine which logs to show and which to hide. In the example above, logs with origins that start with `'my-app'` or `'library'` will be shown, but logs with the origin `'library:chatty'` will be hidden.
19
+
20
+ The `processor` option is where you specify which plugin should process the filtered logs. This can be any Holz plugin.
21
+
22
+ ## Patterns
23
+
24
+ Patterns are strings that match against `log.origin`, which is a property of each log object. Origins are added when you call `logger.namepspace(...)`. The following syntax is supported:
25
+
26
+ - `*` matches zero or more characters.
27
+ - `-` at the beginning of a pattern negates it, so that logs with origins matching the pattern are hidden rather than shown.
28
+
29
+ For example:
30
+
31
+ - `my-app*` matches origins that start with `'my-app'`, such as `'my-app:home'` or `'my-app:login'`.
32
+ - `library*, -library:chatty*` matches origins that start with `'library'`, except for origins that start with `'library:chatty'`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@holz/pattern-filter",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Only print log messages that match a pattern",
5
5
  "type": "module",
6
6
  "main": "./dist/holz-pattern-filter.cjs",
@@ -40,7 +40,7 @@
40
40
  "test:types": "tsc"
41
41
  },
42
42
  "devDependencies": {
43
- "@holz/core": "^0.5.0",
43
+ "@holz/core": "^0.6.0",
44
44
  "@vitest/coverage-c8": "^0.28.5",
45
45
  "typescript": "^4.9.5",
46
46
  "vite": "^4.0.0",