@loglayer/plugin-filter 3.0.4 → 3.0.5
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.
- package/dist/index.cjs +191 -154
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +39 -35
- package/dist/index.d.ts +39 -35
- package/dist/index.js +168 -155
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -1,162 +1,199 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
let __jsonquerylang_jsonquery = require("@jsonquerylang/jsonquery");
|
|
25
|
+
__jsonquerylang_jsonquery = __toESM(__jsonquerylang_jsonquery);
|
|
26
|
+
|
|
27
|
+
//#region src/FilterExecutor.ts
|
|
28
|
+
/**
|
|
29
|
+
* Core filtering logic implementation.
|
|
30
|
+
* Handles pattern matching and query-based filtering of log messages.
|
|
31
|
+
*
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
3
34
|
var FilterExecutor = class {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
*
|
|
128
|
-
* @param params - The log message parameters
|
|
129
|
-
* @returns true if the log should be allowed, false otherwise
|
|
130
|
-
*/
|
|
131
|
-
check(params) {
|
|
132
|
-
this.resetContext(params);
|
|
133
|
-
if (!_optionalChain([this, 'access', _10 => _10.config, 'access', _11 => _11.messages, 'optionalAccess', _12 => _12.length]) && !_optionalChain([this, 'access', _13 => _13.config, 'access', _14 => _14.queries, 'optionalAccess', _15 => _15.length])) {
|
|
134
|
-
this.context.debugItems.push("[filter-plugin] no filters defined, allowing message");
|
|
135
|
-
this.printDebugItems();
|
|
136
|
-
return true;
|
|
137
|
-
}
|
|
138
|
-
if (this.checkMessagePatterns()) {
|
|
139
|
-
this.printDebugItems();
|
|
140
|
-
return true;
|
|
141
|
-
}
|
|
142
|
-
const queryResult = this.checkQueries();
|
|
143
|
-
this.printDebugItems();
|
|
144
|
-
return queryResult;
|
|
145
|
-
}
|
|
35
|
+
config;
|
|
36
|
+
context;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a new FilterExecutor instance.
|
|
39
|
+
*
|
|
40
|
+
* @param config - The filter plugin configuration
|
|
41
|
+
*/
|
|
42
|
+
constructor(config) {
|
|
43
|
+
this.config = config;
|
|
44
|
+
this.context = {
|
|
45
|
+
message: "",
|
|
46
|
+
logLevel: "",
|
|
47
|
+
data: {},
|
|
48
|
+
debugItems: []
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Resets the context for a new log message check.
|
|
53
|
+
*
|
|
54
|
+
* @param params - The log message parameters
|
|
55
|
+
*/
|
|
56
|
+
resetContext(params) {
|
|
57
|
+
this.context = {
|
|
58
|
+
message: params.messages?.join(" ") || "",
|
|
59
|
+
logLevel: params.logLevel,
|
|
60
|
+
data: params.data || {},
|
|
61
|
+
debugItems: ["[filter-plugin] ================================="]
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Prints debug information if debug mode is enabled.
|
|
66
|
+
*/
|
|
67
|
+
printDebugItems() {
|
|
68
|
+
if (this.config.debug) for (const item of this.context.debugItems) console.log(item);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Checks if the current message matches any of the configured patterns.
|
|
72
|
+
* Supports both string and RegExp patterns.
|
|
73
|
+
*
|
|
74
|
+
* @returns true if any pattern matches, false otherwise
|
|
75
|
+
*/
|
|
76
|
+
checkMessagePatterns() {
|
|
77
|
+
if (!this.config.messages?.length) return false;
|
|
78
|
+
if (this.config.debug) this.context.debugItems.push(`[filter-plugin] message: ${this.context.message}`);
|
|
79
|
+
for (const pattern of this.config.messages) {
|
|
80
|
+
if (this.config.debug) this.context.debugItems.push(`[filter-plugin] pattern: ${pattern}`);
|
|
81
|
+
if (typeof pattern === "string" ? this.context.message.includes(pattern) : pattern.test(this.context.message)) {
|
|
82
|
+
this.context.debugItems.push("[filter-plugin] pattern match: true");
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
this.context.debugItems.push("[filter-plugin] pattern match: false");
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Checks if the current message matches any of the configured queries.
|
|
91
|
+
* Uses @jsonquerylang/jsonquery for query execution.
|
|
92
|
+
*
|
|
93
|
+
* @returns true if any query matches, false otherwise
|
|
94
|
+
*/
|
|
95
|
+
checkQueries() {
|
|
96
|
+
if (!this.config.queries?.length) return false;
|
|
97
|
+
const queryContext = {
|
|
98
|
+
level: this.context.logLevel,
|
|
99
|
+
message: this.context.message,
|
|
100
|
+
data: this.context.data
|
|
101
|
+
};
|
|
102
|
+
try {
|
|
103
|
+
for (const q of this.config.queries) {
|
|
104
|
+
const conditions = q.split(" or ").map((cond) => `filter(${cond.trim().replaceAll(`'`, `"`)})`);
|
|
105
|
+
const query = conditions.join(" or ");
|
|
106
|
+
if (this.config.debug) {
|
|
107
|
+
this.context.debugItems.push(`[filter-plugin] query: filter(${query})`);
|
|
108
|
+
this.context.debugItems.push(`[filter-plugin] input: ${JSON.stringify(queryContext)}`);
|
|
109
|
+
}
|
|
110
|
+
for (const condition of conditions) try {
|
|
111
|
+
const output = (0, __jsonquerylang_jsonquery.jsonquery)([queryContext], condition);
|
|
112
|
+
if (output.length > 0) {
|
|
113
|
+
if (this.config.debug) this.context.debugItems.push(`[filter-plugin] query match: ${output.length > 0}`);
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
} catch (e) {
|
|
117
|
+
console.error(`[filter-plugin] Error: ${e}`);
|
|
118
|
+
console.log(`[filter-plugin] query: ${condition}`);
|
|
119
|
+
console.log(`[filter-plugin] input: ${JSON.stringify(queryContext)}`);
|
|
120
|
+
}
|
|
121
|
+
if (this.config.debug) this.context.debugItems.push("[filter-plugin] query match: false");
|
|
122
|
+
}
|
|
123
|
+
return false;
|
|
124
|
+
} catch (e) {
|
|
125
|
+
console.error(`[filter-plugin] Error: ${e}`);
|
|
126
|
+
console.log(`[filter-plugin] queries: ${JSON.stringify(this.config.queries)}`);
|
|
127
|
+
console.log(`[filter-plugin] input: ${JSON.stringify(queryContext)}`);
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Checks if a log message should be allowed based on the configured filters.
|
|
133
|
+
*
|
|
134
|
+
* The filtering logic is:
|
|
135
|
+
* 1. If no filters defined, allow all logs
|
|
136
|
+
* 2. If message patterns match, allow the log
|
|
137
|
+
* 3. If queries match, allow the log
|
|
138
|
+
* 4. Otherwise, filter out the log
|
|
139
|
+
*
|
|
140
|
+
* @param params - The log message parameters
|
|
141
|
+
* @returns true if the log should be allowed, false otherwise
|
|
142
|
+
*/
|
|
143
|
+
check(params) {
|
|
144
|
+
this.resetContext(params);
|
|
145
|
+
if (!this.config.messages?.length && !this.config.queries?.length) {
|
|
146
|
+
this.context.debugItems.push("[filter-plugin] no filters defined, allowing message");
|
|
147
|
+
this.printDebugItems();
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
if (this.checkMessagePatterns()) {
|
|
151
|
+
this.printDebugItems();
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
const queryResult = this.checkQueries();
|
|
155
|
+
this.printDebugItems();
|
|
156
|
+
return queryResult;
|
|
157
|
+
}
|
|
146
158
|
};
|
|
147
159
|
|
|
148
|
-
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/plugin.ts
|
|
162
|
+
/**
|
|
163
|
+
* Creates a new filter plugin instance.
|
|
164
|
+
*
|
|
165
|
+
* The filter plugin allows filtering log messages based on:
|
|
166
|
+
* - String patterns
|
|
167
|
+
* - Regular expressions
|
|
168
|
+
* - JSON queries
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```typescript
|
|
172
|
+
* // Filter error messages
|
|
173
|
+
* const filter = filterPlugin({
|
|
174
|
+
* messages: ['error'],
|
|
175
|
+
* });
|
|
176
|
+
*
|
|
177
|
+
* // Filter by log level
|
|
178
|
+
* const levelFilter = filterPlugin({
|
|
179
|
+
* queries: ['.level == "error" or .level == "warn"'],
|
|
180
|
+
* });
|
|
181
|
+
* ```
|
|
182
|
+
*
|
|
183
|
+
* @param config - The filter plugin configuration
|
|
184
|
+
* @returns A LogLayer plugin instance
|
|
185
|
+
*/
|
|
149
186
|
function filterPlugin(config) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
187
|
+
const executor = new FilterExecutor(config);
|
|
188
|
+
return {
|
|
189
|
+
id: config.id,
|
|
190
|
+
disabled: config.disabled,
|
|
191
|
+
shouldSendToLogger: (params) => {
|
|
192
|
+
return executor.check(params);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
158
195
|
}
|
|
159
196
|
|
|
160
|
-
|
|
197
|
+
//#endregion
|
|
161
198
|
exports.filterPlugin = filterPlugin;
|
|
162
199
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../src/FilterExecutor.ts","../src/plugin.ts"],"sourcesContent":["import { jsonquery } from \"@jsonquerylang/jsonquery\";\nimport type { PluginShouldSendToLoggerParams } from \"@loglayer/plugin\";\nimport type { filterPluginParams } from \"./types.js\";\n\n/**\n * Internal context for the filter execution.\n * Contains the current log message details and debug information.\n */\ninterface FilterContext {\n /** The combined log message */\n message: string;\n /** The log level */\n logLevel: string;\n /** Additional log data */\n data: Record<string, any>;\n /** Debug messages for troubleshooting */\n debugItems: string[];\n}\n\n/**\n * Core filtering logic implementation.\n * Handles pattern matching and query-based filtering of log messages.\n *\n * @internal\n */\nexport class FilterExecutor {\n private readonly config: filterPluginParams;\n private context: FilterContext;\n\n /**\n * Creates a new FilterExecutor instance.\n *\n * @param config - The filter plugin configuration\n */\n constructor(config: filterPluginParams) {\n this.config = config;\n this.context = {\n message: \"\",\n logLevel: \"\",\n data: {},\n debugItems: [],\n };\n }\n\n /**\n * Resets the context for a new log message check.\n *\n * @param params - The log message parameters\n */\n private resetContext(params: PluginShouldSendToLoggerParams): void {\n this.context = {\n message: params.messages?.join(\" \") || \"\",\n logLevel: params.logLevel,\n data: params.data || {},\n debugItems: [\"[filter-plugin] =================================\"],\n };\n }\n\n /**\n * Prints debug information if debug mode is enabled.\n */\n private printDebugItems(): void {\n if (this.config.debug) {\n for (const item of this.context.debugItems) {\n console.log(item);\n }\n }\n }\n\n /**\n * Checks if the current message matches any of the configured patterns.\n * Supports both string and RegExp patterns.\n *\n * @returns true if any pattern matches, false otherwise\n */\n private checkMessagePatterns(): boolean {\n if (!this.config.messages?.length) {\n return false;\n }\n\n if (this.config.debug) {\n this.context.debugItems.push(`[filter-plugin] message: ${this.context.message}`);\n }\n\n for (const pattern of this.config.messages) {\n if (this.config.debug) {\n this.context.debugItems.push(`[filter-plugin] pattern: ${pattern}`);\n }\n\n const matches =\n typeof pattern === \"string\" ? this.context.message.includes(pattern) : pattern.test(this.context.message);\n\n if (matches) {\n this.context.debugItems.push(\"[filter-plugin] pattern match: true\");\n return true;\n }\n\n this.context.debugItems.push(\"[filter-plugin] pattern match: false\");\n }\n\n return false;\n }\n\n /**\n * Checks if the current message matches any of the configured queries.\n * Uses @jsonquerylang/jsonquery for query execution.\n *\n * @returns true if any query matches, false otherwise\n */\n private checkQueries(): boolean {\n if (!this.config.queries?.length) {\n return false;\n }\n\n const queryContext = {\n level: this.context.logLevel,\n message: this.context.message,\n data: this.context.data,\n };\n\n try {\n // Process each query individually and return true if any match\n for (const q of this.config.queries) {\n // Split OR conditions and wrap each in filter()\n const conditions = q.split(\" or \").map((cond) => `filter(${cond.trim().replaceAll(`'`, `\"`)})`);\n const query = conditions.join(\" or \");\n\n if (this.config.debug) {\n this.context.debugItems.push(`[filter-plugin] query: filter(${query})`);\n this.context.debugItems.push(`[filter-plugin] input: ${JSON.stringify(queryContext)}`);\n }\n\n // Try each condition separately\n for (const condition of conditions) {\n try {\n const output = jsonquery([queryContext], condition) as Array<any>;\n if (output.length > 0) {\n if (this.config.debug) {\n this.context.debugItems.push(`[filter-plugin] query match: ${output.length > 0}`);\n }\n return true;\n }\n } catch (e) {\n console.error(`[filter-plugin] Error: ${e}`);\n console.log(`[filter-plugin] query: ${condition}`);\n console.log(`[filter-plugin] input: ${JSON.stringify(queryContext)}`);\n // Continue trying other conditions\n }\n }\n\n if (this.config.debug) {\n this.context.debugItems.push(\"[filter-plugin] query match: false\");\n }\n }\n\n return false;\n } catch (e) {\n console.error(`[filter-plugin] Error: ${e}`);\n console.log(`[filter-plugin] queries: ${JSON.stringify(this.config.queries)}`);\n console.log(`[filter-plugin] input: ${JSON.stringify(queryContext)}`);\n return false;\n }\n }\n\n /**\n * Checks if a log message should be allowed based on the configured filters.\n *\n * The filtering logic is:\n * 1. If no filters defined, allow all logs\n * 2. If message patterns match, allow the log\n * 3. If queries match, allow the log\n * 4. Otherwise, filter out the log\n *\n * @param params - The log message parameters\n * @returns true if the log should be allowed, false otherwise\n */\n check(params: PluginShouldSendToLoggerParams): boolean {\n this.resetContext(params);\n\n // If no filters defined at all, allow everything\n if (!this.config.messages?.length && !this.config.queries?.length) {\n this.context.debugItems.push(\"[filter-plugin] no filters defined, allowing message\");\n this.printDebugItems();\n return true;\n }\n\n // Check message patterns first\n if (this.checkMessagePatterns()) {\n this.printDebugItems();\n return true;\n }\n\n // Then check queries if message patterns didn't match\n const queryResult = this.checkQueries();\n this.printDebugItems();\n return queryResult;\n }\n}\n","import type { LogLayerPlugin, PluginShouldSendToLoggerParams } from \"@loglayer/plugin\";\nimport { FilterExecutor } from \"./FilterExecutor.js\";\nimport type { filterPluginParams } from \"./types.js\";\n\n/**\n * Creates a new filter plugin instance.\n *\n * The filter plugin allows filtering log messages based on:\n * - String patterns\n * - Regular expressions\n * - JSON queries\n *\n * @example\n * ```typescript\n * // Filter error messages\n * const filter = filterPlugin({\n * messages: ['error'],\n * });\n *\n * // Filter by log level\n * const levelFilter = filterPlugin({\n * queries: ['.level == \"error\" or .level == \"warn\"'],\n * });\n * ```\n *\n * @param config - The filter plugin configuration\n * @returns A LogLayer plugin instance\n */\nexport function filterPlugin(config: filterPluginParams): LogLayerPlugin {\n const executor = new FilterExecutor(config);\n\n return {\n id: config.id,\n disabled: config.disabled,\n shouldSendToLogger: (params: PluginShouldSendToLoggerParams) => {\n return executor.check(params);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,IAAa,iBAAb,MAA4B;CAC1B,AAAiB;CACjB,AAAQ;;;;;;CAOR,YAAY,QAA4B;AACtC,OAAK,SAAS;AACd,OAAK,UAAU;GACb,SAAS;GACT,UAAU;GACV,MAAM,EAAE;GACR,YAAY,EAAE;GACf;;;;;;;CAQH,AAAQ,aAAa,QAA8C;AACjE,OAAK,UAAU;GACb,SAAS,OAAO,UAAU,KAAK,IAAI,IAAI;GACvC,UAAU,OAAO;GACjB,MAAM,OAAO,QAAQ,EAAE;GACvB,YAAY,CAAC,oDAAoD;GAClE;;;;;CAMH,AAAQ,kBAAwB;AAC9B,MAAI,KAAK,OAAO,MACd,MAAK,MAAM,QAAQ,KAAK,QAAQ,WAC9B,SAAQ,IAAI,KAAK;;;;;;;;CAWvB,AAAQ,uBAAgC;AACtC,MAAI,CAAC,KAAK,OAAO,UAAU,OACzB,QAAO;AAGT,MAAI,KAAK,OAAO,MACd,MAAK,QAAQ,WAAW,KAAK,4BAA4B,KAAK,QAAQ,UAAU;AAGlF,OAAK,MAAM,WAAW,KAAK,OAAO,UAAU;AAC1C,OAAI,KAAK,OAAO,MACd,MAAK,QAAQ,WAAW,KAAK,4BAA4B,UAAU;AAMrE,OAFE,OAAO,YAAY,WAAW,KAAK,QAAQ,QAAQ,SAAS,QAAQ,GAAG,QAAQ,KAAK,KAAK,QAAQ,QAAQ,EAE9F;AACX,SAAK,QAAQ,WAAW,KAAK,sCAAsC;AACnE,WAAO;;AAGT,QAAK,QAAQ,WAAW,KAAK,uCAAuC;;AAGtE,SAAO;;;;;;;;CAST,AAAQ,eAAwB;AAC9B,MAAI,CAAC,KAAK,OAAO,SAAS,OACxB,QAAO;EAGT,MAAM,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;;AAIT,MAAI,KAAK,sBAAsB,EAAE;AAC/B,QAAK,iBAAiB;AACtB,UAAO;;EAIT,MAAM,cAAc,KAAK,cAAc;AACvC,OAAK,iBAAiB;AACtB,SAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACvKX,SAAgB,aAAa,QAA4C;CACvE,MAAM,WAAW,IAAI,eAAe,OAAO;AAE3C,QAAO;EACL,IAAI,OAAO;EACX,UAAU,OAAO;EACjB,qBAAqB,WAA2C;AAC9D,UAAO,SAAS,MAAM,OAAO;;EAEhC"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LogLayerPlugin, LogLayerPluginParams } from "@loglayer/plugin";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* Configuration parameters for the filter plugin.
|
|
@@ -14,40 +16,41 @@ import { LogLayerPluginParams, LogLayerPlugin } from '@loglayer/plugin';
|
|
|
14
16
|
* ```
|
|
15
17
|
*/
|
|
16
18
|
interface filterPluginParams extends LogLayerPluginParams {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Array of string patterns or regular expressions to match against log messages.
|
|
21
|
+
* If any pattern matches, the log will be allowed.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* messages: ['error', /warning\d+/]
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
messages?: Array<string | RegExp>;
|
|
29
|
+
/**
|
|
30
|
+
* Array of JSON queries to filter logs.
|
|
31
|
+
* If any query matches, the log will be allowed.
|
|
32
|
+
* Uses @jsonquerylang/jsonquery syntax.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* queries: ['.level == "error"', '.data.userId == "123"']
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
queries?: Array<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Enable debug mode to see detailed information about the filtering process.
|
|
42
|
+
* When enabled, the plugin will log:
|
|
43
|
+
* - Message content
|
|
44
|
+
* - Pattern matching results
|
|
45
|
+
* - Query execution details
|
|
46
|
+
* - Final filtering decision
|
|
47
|
+
*
|
|
48
|
+
* @default false
|
|
49
|
+
*/
|
|
50
|
+
debug?: boolean;
|
|
49
51
|
}
|
|
50
|
-
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/plugin.d.ts
|
|
51
54
|
/**
|
|
52
55
|
* Creates a new filter plugin instance.
|
|
53
56
|
*
|
|
@@ -73,5 +76,6 @@ interface filterPluginParams extends LogLayerPluginParams {
|
|
|
73
76
|
* @returns A LogLayer plugin instance
|
|
74
77
|
*/
|
|
75
78
|
declare function filterPlugin(config: filterPluginParams): LogLayerPlugin;
|
|
76
|
-
|
|
79
|
+
//#endregion
|
|
77
80
|
export { filterPlugin, type filterPluginParams };
|
|
81
|
+
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LogLayerPlugin, LogLayerPluginParams } from "@loglayer/plugin";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* Configuration parameters for the filter plugin.
|
|
@@ -14,40 +16,41 @@ import { LogLayerPluginParams, LogLayerPlugin } from '@loglayer/plugin';
|
|
|
14
16
|
* ```
|
|
15
17
|
*/
|
|
16
18
|
interface filterPluginParams extends LogLayerPluginParams {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Array of string patterns or regular expressions to match against log messages.
|
|
21
|
+
* If any pattern matches, the log will be allowed.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* messages: ['error', /warning\d+/]
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
messages?: Array<string | RegExp>;
|
|
29
|
+
/**
|
|
30
|
+
* Array of JSON queries to filter logs.
|
|
31
|
+
* If any query matches, the log will be allowed.
|
|
32
|
+
* Uses @jsonquerylang/jsonquery syntax.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* queries: ['.level == "error"', '.data.userId == "123"']
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
queries?: Array<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Enable debug mode to see detailed information about the filtering process.
|
|
42
|
+
* When enabled, the plugin will log:
|
|
43
|
+
* - Message content
|
|
44
|
+
* - Pattern matching results
|
|
45
|
+
* - Query execution details
|
|
46
|
+
* - Final filtering decision
|
|
47
|
+
*
|
|
48
|
+
* @default false
|
|
49
|
+
*/
|
|
50
|
+
debug?: boolean;
|
|
49
51
|
}
|
|
50
|
-
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/plugin.d.ts
|
|
51
54
|
/**
|
|
52
55
|
* Creates a new filter plugin instance.
|
|
53
56
|
*
|
|
@@ -73,5 +76,6 @@ interface filterPluginParams extends LogLayerPluginParams {
|
|
|
73
76
|
* @returns A LogLayer plugin instance
|
|
74
77
|
*/
|
|
75
78
|
declare function filterPlugin(config: filterPluginParams): LogLayerPlugin;
|
|
76
|
-
|
|
79
|
+
//#endregion
|
|
77
80
|
export { filterPlugin, type filterPluginParams };
|
|
81
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,162 +1,175 @@
|
|
|
1
|
-
// src/FilterExecutor.ts
|
|
2
1
|
import { jsonquery } from "@jsonquerylang/jsonquery";
|
|
2
|
+
|
|
3
|
+
//#region src/FilterExecutor.ts
|
|
4
|
+
/**
|
|
5
|
+
* Core filtering logic implementation.
|
|
6
|
+
* Handles pattern matching and query-based filtering of log messages.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
3
10
|
var FilterExecutor = class {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
*
|
|
128
|
-
* @param params - The log message parameters
|
|
129
|
-
* @returns true if the log should be allowed, false otherwise
|
|
130
|
-
*/
|
|
131
|
-
check(params) {
|
|
132
|
-
this.resetContext(params);
|
|
133
|
-
if (!this.config.messages?.length && !this.config.queries?.length) {
|
|
134
|
-
this.context.debugItems.push("[filter-plugin] no filters defined, allowing message");
|
|
135
|
-
this.printDebugItems();
|
|
136
|
-
return true;
|
|
137
|
-
}
|
|
138
|
-
if (this.checkMessagePatterns()) {
|
|
139
|
-
this.printDebugItems();
|
|
140
|
-
return true;
|
|
141
|
-
}
|
|
142
|
-
const queryResult = this.checkQueries();
|
|
143
|
-
this.printDebugItems();
|
|
144
|
-
return queryResult;
|
|
145
|
-
}
|
|
11
|
+
config;
|
|
12
|
+
context;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new FilterExecutor instance.
|
|
15
|
+
*
|
|
16
|
+
* @param config - The filter plugin configuration
|
|
17
|
+
*/
|
|
18
|
+
constructor(config) {
|
|
19
|
+
this.config = config;
|
|
20
|
+
this.context = {
|
|
21
|
+
message: "",
|
|
22
|
+
logLevel: "",
|
|
23
|
+
data: {},
|
|
24
|
+
debugItems: []
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Resets the context for a new log message check.
|
|
29
|
+
*
|
|
30
|
+
* @param params - The log message parameters
|
|
31
|
+
*/
|
|
32
|
+
resetContext(params) {
|
|
33
|
+
this.context = {
|
|
34
|
+
message: params.messages?.join(" ") || "",
|
|
35
|
+
logLevel: params.logLevel,
|
|
36
|
+
data: params.data || {},
|
|
37
|
+
debugItems: ["[filter-plugin] ================================="]
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Prints debug information if debug mode is enabled.
|
|
42
|
+
*/
|
|
43
|
+
printDebugItems() {
|
|
44
|
+
if (this.config.debug) for (const item of this.context.debugItems) console.log(item);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Checks if the current message matches any of the configured patterns.
|
|
48
|
+
* Supports both string and RegExp patterns.
|
|
49
|
+
*
|
|
50
|
+
* @returns true if any pattern matches, false otherwise
|
|
51
|
+
*/
|
|
52
|
+
checkMessagePatterns() {
|
|
53
|
+
if (!this.config.messages?.length) return false;
|
|
54
|
+
if (this.config.debug) this.context.debugItems.push(`[filter-plugin] message: ${this.context.message}`);
|
|
55
|
+
for (const pattern of this.config.messages) {
|
|
56
|
+
if (this.config.debug) this.context.debugItems.push(`[filter-plugin] pattern: ${pattern}`);
|
|
57
|
+
if (typeof pattern === "string" ? this.context.message.includes(pattern) : pattern.test(this.context.message)) {
|
|
58
|
+
this.context.debugItems.push("[filter-plugin] pattern match: true");
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
this.context.debugItems.push("[filter-plugin] pattern match: false");
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Checks if the current message matches any of the configured queries.
|
|
67
|
+
* Uses @jsonquerylang/jsonquery for query execution.
|
|
68
|
+
*
|
|
69
|
+
* @returns true if any query matches, false otherwise
|
|
70
|
+
*/
|
|
71
|
+
checkQueries() {
|
|
72
|
+
if (!this.config.queries?.length) return false;
|
|
73
|
+
const queryContext = {
|
|
74
|
+
level: this.context.logLevel,
|
|
75
|
+
message: this.context.message,
|
|
76
|
+
data: this.context.data
|
|
77
|
+
};
|
|
78
|
+
try {
|
|
79
|
+
for (const q of this.config.queries) {
|
|
80
|
+
const conditions = q.split(" or ").map((cond) => `filter(${cond.trim().replaceAll(`'`, `"`)})`);
|
|
81
|
+
const query = conditions.join(" or ");
|
|
82
|
+
if (this.config.debug) {
|
|
83
|
+
this.context.debugItems.push(`[filter-plugin] query: filter(${query})`);
|
|
84
|
+
this.context.debugItems.push(`[filter-plugin] input: ${JSON.stringify(queryContext)}`);
|
|
85
|
+
}
|
|
86
|
+
for (const condition of conditions) try {
|
|
87
|
+
const output = jsonquery([queryContext], condition);
|
|
88
|
+
if (output.length > 0) {
|
|
89
|
+
if (this.config.debug) this.context.debugItems.push(`[filter-plugin] query match: ${output.length > 0}`);
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
} catch (e) {
|
|
93
|
+
console.error(`[filter-plugin] Error: ${e}`);
|
|
94
|
+
console.log(`[filter-plugin] query: ${condition}`);
|
|
95
|
+
console.log(`[filter-plugin] input: ${JSON.stringify(queryContext)}`);
|
|
96
|
+
}
|
|
97
|
+
if (this.config.debug) this.context.debugItems.push("[filter-plugin] query match: false");
|
|
98
|
+
}
|
|
99
|
+
return false;
|
|
100
|
+
} catch (e) {
|
|
101
|
+
console.error(`[filter-plugin] Error: ${e}`);
|
|
102
|
+
console.log(`[filter-plugin] queries: ${JSON.stringify(this.config.queries)}`);
|
|
103
|
+
console.log(`[filter-plugin] input: ${JSON.stringify(queryContext)}`);
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Checks if a log message should be allowed based on the configured filters.
|
|
109
|
+
*
|
|
110
|
+
* The filtering logic is:
|
|
111
|
+
* 1. If no filters defined, allow all logs
|
|
112
|
+
* 2. If message patterns match, allow the log
|
|
113
|
+
* 3. If queries match, allow the log
|
|
114
|
+
* 4. Otherwise, filter out the log
|
|
115
|
+
*
|
|
116
|
+
* @param params - The log message parameters
|
|
117
|
+
* @returns true if the log should be allowed, false otherwise
|
|
118
|
+
*/
|
|
119
|
+
check(params) {
|
|
120
|
+
this.resetContext(params);
|
|
121
|
+
if (!this.config.messages?.length && !this.config.queries?.length) {
|
|
122
|
+
this.context.debugItems.push("[filter-plugin] no filters defined, allowing message");
|
|
123
|
+
this.printDebugItems();
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
if (this.checkMessagePatterns()) {
|
|
127
|
+
this.printDebugItems();
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
const queryResult = this.checkQueries();
|
|
131
|
+
this.printDebugItems();
|
|
132
|
+
return queryResult;
|
|
133
|
+
}
|
|
146
134
|
};
|
|
147
135
|
|
|
148
|
-
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/plugin.ts
|
|
138
|
+
/**
|
|
139
|
+
* Creates a new filter plugin instance.
|
|
140
|
+
*
|
|
141
|
+
* The filter plugin allows filtering log messages based on:
|
|
142
|
+
* - String patterns
|
|
143
|
+
* - Regular expressions
|
|
144
|
+
* - JSON queries
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```typescript
|
|
148
|
+
* // Filter error messages
|
|
149
|
+
* const filter = filterPlugin({
|
|
150
|
+
* messages: ['error'],
|
|
151
|
+
* });
|
|
152
|
+
*
|
|
153
|
+
* // Filter by log level
|
|
154
|
+
* const levelFilter = filterPlugin({
|
|
155
|
+
* queries: ['.level == "error" or .level == "warn"'],
|
|
156
|
+
* });
|
|
157
|
+
* ```
|
|
158
|
+
*
|
|
159
|
+
* @param config - The filter plugin configuration
|
|
160
|
+
* @returns A LogLayer plugin instance
|
|
161
|
+
*/
|
|
149
162
|
function filterPlugin(config) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
163
|
+
const executor = new FilterExecutor(config);
|
|
164
|
+
return {
|
|
165
|
+
id: config.id,
|
|
166
|
+
disabled: config.disabled,
|
|
167
|
+
shouldSendToLogger: (params) => {
|
|
168
|
+
return executor.check(params);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
158
171
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
};
|
|
172
|
+
|
|
173
|
+
//#endregion
|
|
174
|
+
export { filterPlugin };
|
|
162
175
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/FilterExecutor.ts","../src/plugin.ts"],"sourcesContent":["import { jsonquery } from \"@jsonquerylang/jsonquery\";\nimport type { PluginShouldSendToLoggerParams } from \"@loglayer/plugin\";\nimport type { filterPluginParams } from \"./types.js\";\n\n/**\n * Internal context for the filter execution.\n * Contains the current log message details and debug information.\n */\ninterface FilterContext {\n /** The combined log message */\n message: string;\n /** The log level */\n logLevel: string;\n /** Additional log data */\n data: Record<string, any>;\n /** Debug messages for troubleshooting */\n debugItems: string[];\n}\n\n/**\n * Core filtering logic implementation.\n * Handles pattern matching and query-based filtering of log messages.\n *\n * @internal\n */\nexport class FilterExecutor {\n private readonly config: filterPluginParams;\n private context: FilterContext;\n\n /**\n * Creates a new FilterExecutor instance.\n *\n * @param config - The filter plugin configuration\n */\n constructor(config: filterPluginParams) {\n this.config = config;\n this.context = {\n message: \"\",\n logLevel: \"\",\n data: {},\n debugItems: [],\n };\n }\n\n /**\n * Resets the context for a new log message check.\n *\n * @param params - The log message parameters\n */\n private resetContext(params: PluginShouldSendToLoggerParams): void {\n this.context = {\n message: params.messages?.join(\" \") || \"\",\n logLevel: params.logLevel,\n data: params.data || {},\n debugItems: [\"[filter-plugin] =================================\"],\n };\n }\n\n /**\n * Prints debug information if debug mode is enabled.\n */\n private printDebugItems(): void {\n if (this.config.debug) {\n for (const item of this.context.debugItems) {\n console.log(item);\n }\n }\n }\n\n /**\n * Checks if the current message matches any of the configured patterns.\n * Supports both string and RegExp patterns.\n *\n * @returns true if any pattern matches, false otherwise\n */\n private checkMessagePatterns(): boolean {\n if (!this.config.messages?.length) {\n return false;\n }\n\n if (this.config.debug) {\n this.context.debugItems.push(`[filter-plugin] message: ${this.context.message}`);\n }\n\n for (const pattern of this.config.messages) {\n if (this.config.debug) {\n this.context.debugItems.push(`[filter-plugin] pattern: ${pattern}`);\n }\n\n const matches =\n typeof pattern === \"string\" ? this.context.message.includes(pattern) : pattern.test(this.context.message);\n\n if (matches) {\n this.context.debugItems.push(\"[filter-plugin] pattern match: true\");\n return true;\n }\n\n this.context.debugItems.push(\"[filter-plugin] pattern match: false\");\n }\n\n return false;\n }\n\n /**\n * Checks if the current message matches any of the configured queries.\n * Uses @jsonquerylang/jsonquery for query execution.\n *\n * @returns true if any query matches, false otherwise\n */\n private checkQueries(): boolean {\n if (!this.config.queries?.length) {\n return false;\n }\n\n const queryContext = {\n level: this.context.logLevel,\n message: this.context.message,\n data: this.context.data,\n };\n\n try {\n // Process each query individually and return true if any match\n for (const q of this.config.queries) {\n // Split OR conditions and wrap each in filter()\n const conditions = q.split(\" or \").map((cond) => `filter(${cond.trim().replaceAll(`'`, `\"`)})`);\n const query = conditions.join(\" or \");\n\n if (this.config.debug) {\n this.context.debugItems.push(`[filter-plugin] query: filter(${query})`);\n this.context.debugItems.push(`[filter-plugin] input: ${JSON.stringify(queryContext)}`);\n }\n\n // Try each condition separately\n for (const condition of conditions) {\n try {\n const output = jsonquery([queryContext], condition) as Array<any>;\n if (output.length > 0) {\n if (this.config.debug) {\n this.context.debugItems.push(`[filter-plugin] query match: ${output.length > 0}`);\n }\n return true;\n }\n } catch (e) {\n console.error(`[filter-plugin] Error: ${e}`);\n console.log(`[filter-plugin] query: ${condition}`);\n console.log(`[filter-plugin] input: ${JSON.stringify(queryContext)}`);\n // Continue trying other conditions\n }\n }\n\n if (this.config.debug) {\n this.context.debugItems.push(\"[filter-plugin] query match: false\");\n }\n }\n\n return false;\n } catch (e) {\n console.error(`[filter-plugin] Error: ${e}`);\n console.log(`[filter-plugin] queries: ${JSON.stringify(this.config.queries)}`);\n console.log(`[filter-plugin] input: ${JSON.stringify(queryContext)}`);\n return false;\n }\n }\n\n /**\n * Checks if a log message should be allowed based on the configured filters.\n *\n * The filtering logic is:\n * 1. If no filters defined, allow all logs\n * 2. If message patterns match, allow the log\n * 3. If queries match, allow the log\n * 4. Otherwise, filter out the log\n *\n * @param params - The log message parameters\n * @returns true if the log should be allowed, false otherwise\n */\n check(params: PluginShouldSendToLoggerParams): boolean {\n this.resetContext(params);\n\n // If no filters defined at all, allow everything\n if (!this.config.messages?.length && !this.config.queries?.length) {\n this.context.debugItems.push(\"[filter-plugin] no filters defined, allowing message\");\n this.printDebugItems();\n return true;\n }\n\n // Check message patterns first\n if (this.checkMessagePatterns()) {\n this.printDebugItems();\n return true;\n }\n\n // Then check queries if message patterns didn't match\n const queryResult = this.checkQueries();\n this.printDebugItems();\n return queryResult;\n }\n}\n","import type { LogLayerPlugin, PluginShouldSendToLoggerParams } from \"@loglayer/plugin\";\nimport { FilterExecutor } from \"./FilterExecutor.js\";\nimport type { filterPluginParams } from \"./types.js\";\n\n/**\n * Creates a new filter plugin instance.\n *\n * The filter plugin allows filtering log messages based on:\n * - String patterns\n * - Regular expressions\n * - JSON queries\n *\n * @example\n * ```typescript\n * // Filter error messages\n * const filter = filterPlugin({\n * messages: ['error'],\n * });\n *\n * // Filter by log level\n * const levelFilter = filterPlugin({\n * queries: ['.level == \"error\" or .level == \"warn\"'],\n * });\n * ```\n *\n * @param config - The filter plugin configuration\n * @returns A LogLayer plugin instance\n */\nexport function filterPlugin(config: filterPluginParams): LogLayerPlugin {\n const executor = new FilterExecutor(config);\n\n return {\n id: config.id,\n disabled: config.disabled,\n shouldSendToLogger: (params: PluginShouldSendToLoggerParams) => {\n return executor.check(params);\n },\n };\n}\n"],"mappings":";AAAA,SAAS,iBAAiB;AAyBnB,IAAM,iBAAN,MAAqB;AAAA,EACT;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOR,YAAY,QAA4B;AACtC,SAAK,SAAS;AACd,SAAK,UAAU;AAAA,MACb,SAAS;AAAA,MACT,UAAU;AAAA,MACV,MAAM,CAAC;AAAA,MACP,YAAY,CAAC;AAAA,IACf;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOQ,aAAa,QAA8C;AACjE,SAAK,UAAU;AAAA,MACb,SAAS,OAAO,UAAU,KAAK,GAAG,KAAK;AAAA,MACvC,UAAU,OAAO;AAAA,MACjB,MAAM,OAAO,QAAQ,CAAC;AAAA,MACtB,YAAY,CAAC,mDAAmD;AAAA,IAClE;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKQ,kBAAwB;AAC9B,QAAI,KAAK,OAAO,OAAO;AACrB,iBAAW,QAAQ,KAAK,QAAQ,YAAY;AAC1C,gBAAQ,IAAI,IAAI;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQQ,uBAAgC;AACtC,QA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AAI,OAAO;AAAA,IACX,UAAU,OAAO;AAAA,IACjB,oBAAoB,CAAC,WAA2C;AAC9D,aAAO,SAAS,MAAM,MAAM;AAAA,IAC9B;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/FilterExecutor.ts","../src/plugin.ts"],"sourcesContent":["import { jsonquery } from \"@jsonquerylang/jsonquery\";\nimport type { PluginShouldSendToLoggerParams } from \"@loglayer/plugin\";\nimport type { filterPluginParams } from \"./types.js\";\n\n/**\n * Internal context for the filter execution.\n * Contains the current log message details and debug information.\n */\ninterface FilterContext {\n /** The combined log message */\n message: string;\n /** The log level */\n logLevel: string;\n /** Additional log data */\n data: Record<string, any>;\n /** Debug messages for troubleshooting */\n debugItems: string[];\n}\n\n/**\n * Core filtering logic implementation.\n * Handles pattern matching and query-based filtering of log messages.\n *\n * @internal\n */\nexport class FilterExecutor {\n private readonly config: filterPluginParams;\n private context: FilterContext;\n\n /**\n * Creates a new FilterExecutor instance.\n *\n * @param config - The filter plugin configuration\n */\n constructor(config: filterPluginParams) {\n this.config = config;\n this.context = {\n message: \"\",\n logLevel: \"\",\n data: {},\n debugItems: [],\n };\n }\n\n /**\n * Resets the context for a new log message check.\n *\n * @param params - The log message parameters\n */\n private resetContext(params: PluginShouldSendToLoggerParams): void {\n this.context = {\n message: params.messages?.join(\" \") || \"\",\n logLevel: params.logLevel,\n data: params.data || {},\n debugItems: [\"[filter-plugin] =================================\"],\n };\n }\n\n /**\n * Prints debug information if debug mode is enabled.\n */\n private printDebugItems(): void {\n if (this.config.debug) {\n for (const item of this.context.debugItems) {\n console.log(item);\n }\n }\n }\n\n /**\n * Checks if the current message matches any of the configured patterns.\n * Supports both string and RegExp patterns.\n *\n * @returns true if any pattern matches, false otherwise\n */\n private checkMessagePatterns(): boolean {\n if (!this.config.messages?.length) {\n return false;\n }\n\n if (this.config.debug) {\n this.context.debugItems.push(`[filter-plugin] message: ${this.context.message}`);\n }\n\n for (const pattern of this.config.messages) {\n if (this.config.debug) {\n this.context.debugItems.push(`[filter-plugin] pattern: ${pattern}`);\n }\n\n const matches =\n typeof pattern === \"string\" ? this.context.message.includes(pattern) : pattern.test(this.context.message);\n\n if (matches) {\n this.context.debugItems.push(\"[filter-plugin] pattern match: true\");\n return true;\n }\n\n this.context.debugItems.push(\"[filter-plugin] pattern match: false\");\n }\n\n return false;\n }\n\n /**\n * Checks if the current message matches any of the configured queries.\n * Uses @jsonquerylang/jsonquery for query execution.\n *\n * @returns true if any query matches, false otherwise\n */\n private checkQueries(): boolean {\n if (!this.config.queries?.length) {\n return false;\n }\n\n const queryContext = {\n level: this.context.logLevel,\n message: this.context.message,\n data: this.context.data,\n };\n\n try {\n // Process each query individually and return true if any match\n for (const q of this.config.queries) {\n // Split OR conditions and wrap each in filter()\n const conditions = q.split(\" or \").map((cond) => `filter(${cond.trim().replaceAll(`'`, `\"`)})`);\n const query = conditions.join(\" or \");\n\n if (this.config.debug) {\n this.context.debugItems.push(`[filter-plugin] query: filter(${query})`);\n this.context.debugItems.push(`[filter-plugin] input: ${JSON.stringify(queryContext)}`);\n }\n\n // Try each condition separately\n for (const condition of conditions) {\n try {\n const output = jsonquery([queryContext], condition) as Array<any>;\n if (output.length > 0) {\n if (this.config.debug) {\n this.context.debugItems.push(`[filter-plugin] query match: ${output.length > 0}`);\n }\n return true;\n }\n } catch (e) {\n console.error(`[filter-plugin] Error: ${e}`);\n console.log(`[filter-plugin] query: ${condition}`);\n console.log(`[filter-plugin] input: ${JSON.stringify(queryContext)}`);\n // Continue trying other conditions\n }\n }\n\n if (this.config.debug) {\n this.context.debugItems.push(\"[filter-plugin] query match: false\");\n }\n }\n\n return false;\n } catch (e) {\n console.error(`[filter-plugin] Error: ${e}`);\n console.log(`[filter-plugin] queries: ${JSON.stringify(this.config.queries)}`);\n console.log(`[filter-plugin] input: ${JSON.stringify(queryContext)}`);\n return false;\n }\n }\n\n /**\n * Checks if a log message should be allowed based on the configured filters.\n *\n * The filtering logic is:\n * 1. If no filters defined, allow all logs\n * 2. If message patterns match, allow the log\n * 3. If queries match, allow the log\n * 4. Otherwise, filter out the log\n *\n * @param params - The log message parameters\n * @returns true if the log should be allowed, false otherwise\n */\n check(params: PluginShouldSendToLoggerParams): boolean {\n this.resetContext(params);\n\n // If no filters defined at all, allow everything\n if (!this.config.messages?.length && !this.config.queries?.length) {\n this.context.debugItems.push(\"[filter-plugin] no filters defined, allowing message\");\n this.printDebugItems();\n return true;\n }\n\n // Check message patterns first\n if (this.checkMessagePatterns()) {\n this.printDebugItems();\n return true;\n }\n\n // Then check queries if message patterns didn't match\n const queryResult = this.checkQueries();\n this.printDebugItems();\n return queryResult;\n }\n}\n","import type { LogLayerPlugin, PluginShouldSendToLoggerParams } from \"@loglayer/plugin\";\nimport { FilterExecutor } from \"./FilterExecutor.js\";\nimport type { filterPluginParams } from \"./types.js\";\n\n/**\n * Creates a new filter plugin instance.\n *\n * The filter plugin allows filtering log messages based on:\n * - String patterns\n * - Regular expressions\n * - JSON queries\n *\n * @example\n * ```typescript\n * // Filter error messages\n * const filter = filterPlugin({\n * messages: ['error'],\n * });\n *\n * // Filter by log level\n * const levelFilter = filterPlugin({\n * queries: ['.level == \"error\" or .level == \"warn\"'],\n * });\n * ```\n *\n * @param config - The filter plugin configuration\n * @returns A LogLayer plugin instance\n */\nexport function filterPlugin(config: filterPluginParams): LogLayerPlugin {\n const executor = new FilterExecutor(config);\n\n return {\n id: config.id,\n disabled: config.disabled,\n shouldSendToLogger: (params: PluginShouldSendToLoggerParams) => {\n return executor.check(params);\n },\n };\n}\n"],"mappings":";;;;;;;;;AAyBA,IAAa,iBAAb,MAA4B;CAC1B,AAAiB;CACjB,AAAQ;;;;;;CAOR,YAAY,QAA4B;AACtC,OAAK,SAAS;AACd,OAAK,UAAU;GACb,SAAS;GACT,UAAU;GACV,MAAM,EAAE;GACR,YAAY,EAAE;GACf;;;;;;;CAQH,AAAQ,aAAa,QAA8C;AACjE,OAAK,UAAU;GACb,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@loglayer/plugin-filter",
|
|
3
3
|
"description": "Filter logs with LogLayer using string patterns, regular expressions, or JSON Queries.",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.5",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -33,16 +33,16 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@jsonquerylang/jsonquery": "5.0.4",
|
|
36
|
-
"@loglayer/plugin": "2.1.
|
|
37
|
-
"@loglayer/shared": "2.5.
|
|
36
|
+
"@loglayer/plugin": "2.1.6",
|
|
37
|
+
"@loglayer/shared": "2.5.3"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@types/node": "24.
|
|
41
|
-
"
|
|
40
|
+
"@types/node": "24.7.2",
|
|
41
|
+
"tsdown": "0.15.7",
|
|
42
42
|
"typescript": "5.9.3",
|
|
43
43
|
"vitest": "3.2.4",
|
|
44
|
-
"
|
|
45
|
-
"
|
|
44
|
+
"@internal/tsconfig": "2.1.0",
|
|
45
|
+
"loglayer": "6.9.1"
|
|
46
46
|
},
|
|
47
47
|
"bugs": "https://github.com/loglayer/loglayer/issues",
|
|
48
48
|
"engines": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
],
|
|
54
54
|
"homepage": "https://loglayer.dev",
|
|
55
55
|
"scripts": {
|
|
56
|
-
"build": "
|
|
56
|
+
"build": "tsdown src/index.ts",
|
|
57
57
|
"test": "vitest --run",
|
|
58
58
|
"clean": "rm -rf .turbo node_modules dist",
|
|
59
59
|
"lint": "biome check --no-errors-on-unmatched --write --unsafe src",
|