@spinajs/log 2.0.481 → 2.0.484
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/README.md +744 -0
- package/lib/cjs/archive/LogArchiveService.d.ts +75 -0
- package/lib/cjs/archive/LogArchiveService.d.ts.map +1 -0
- package/lib/cjs/archive/LogArchiveService.js +189 -0
- package/lib/cjs/archive/LogArchiveService.js.map +1 -0
- package/lib/cjs/archive/archive-strategy.d.ts +32 -0
- package/lib/cjs/archive/archive-strategy.d.ts.map +1 -0
- package/lib/cjs/archive/archive-strategy.js +43 -0
- package/lib/cjs/archive/archive-strategy.js.map +1 -0
- package/lib/cjs/archive/context.d.ts +50 -0
- package/lib/cjs/archive/context.d.ts.map +1 -0
- package/lib/cjs/archive/context.js +3 -0
- package/lib/cjs/archive/context.js.map +1 -0
- package/lib/cjs/archive/index.d.ts +10 -0
- package/lib/cjs/archive/index.d.ts.map +1 -0
- package/lib/cjs/archive/index.js +26 -0
- package/lib/cjs/archive/index.js.map +1 -0
- package/lib/cjs/archive/retention-strategy.d.ts +26 -0
- package/lib/cjs/archive/retention-strategy.d.ts.map +1 -0
- package/lib/cjs/archive/retention-strategy.js +42 -0
- package/lib/cjs/archive/retention-strategy.js.map +1 -0
- package/lib/cjs/archive/strategies/AgeLogRetentionStrategy.d.ts +10 -0
- package/lib/cjs/archive/strategies/AgeLogRetentionStrategy.d.ts.map +1 -0
- package/lib/cjs/archive/strategies/AgeLogRetentionStrategy.js +46 -0
- package/lib/cjs/archive/strategies/AgeLogRetentionStrategy.js.map +1 -0
- package/lib/cjs/archive/strategies/CountLogRetentionStrategy.d.ts +10 -0
- package/lib/cjs/archive/strategies/CountLogRetentionStrategy.d.ts.map +1 -0
- package/lib/cjs/archive/strategies/CountLogRetentionStrategy.js +42 -0
- package/lib/cjs/archive/strategies/CountLogRetentionStrategy.js.map +1 -0
- package/lib/cjs/archive/strategies/CronLogArchiveStrategy.d.ts +15 -0
- package/lib/cjs/archive/strategies/CronLogArchiveStrategy.d.ts.map +1 -0
- package/lib/cjs/archive/strategies/CronLogArchiveStrategy.js +52 -0
- package/lib/cjs/archive/strategies/CronLogArchiveStrategy.js.map +1 -0
- package/lib/cjs/archive/strategies/SizeLogArchiveStrategy.d.ts +18 -0
- package/lib/cjs/archive/strategies/SizeLogArchiveStrategy.d.ts.map +1 -0
- package/lib/cjs/archive/strategies/SizeLogArchiveStrategy.js +63 -0
- package/lib/cjs/archive/strategies/SizeLogArchiveStrategy.js.map +1 -0
- package/lib/cjs/archive/strategies/util.d.ts +28 -0
- package/lib/cjs/archive/strategies/util.d.ts.map +1 -0
- package/lib/cjs/archive/strategies/util.js +59 -0
- package/lib/cjs/archive/strategies/util.js.map +1 -0
- package/lib/cjs/bootstrap.d.ts.map +1 -1
- package/lib/cjs/bootstrap.js +24 -1
- package/lib/cjs/bootstrap.js.map +1 -1
- package/lib/cjs/callsite.d.ts +26 -0
- package/lib/cjs/callsite.d.ts.map +1 -0
- package/lib/cjs/callsite.js +60 -0
- package/lib/cjs/callsite.js.map +1 -0
- package/lib/cjs/config/log.d.ts +96 -0
- package/lib/cjs/config/log.d.ts.map +1 -0
- package/lib/cjs/config/log.js +75 -0
- package/lib/cjs/config/log.js.map +1 -0
- package/lib/cjs/context.browser.d.ts +46 -0
- package/lib/cjs/context.browser.d.ts.map +1 -0
- package/lib/cjs/context.browser.js +85 -0
- package/lib/cjs/context.browser.js.map +1 -0
- package/lib/cjs/context.d.ts +61 -0
- package/lib/cjs/context.d.ts.map +1 -0
- package/lib/cjs/context.js +92 -0
- package/lib/cjs/context.js.map +1 -0
- package/lib/cjs/filters/LevelFilter.d.ts +24 -0
- package/lib/cjs/filters/LevelFilter.d.ts.map +1 -0
- package/lib/cjs/filters/LevelFilter.js +39 -0
- package/lib/cjs/filters/LevelFilter.js.map +1 -0
- package/lib/cjs/filters/MatchFilter.d.ts +30 -0
- package/lib/cjs/filters/MatchFilter.d.ts.map +1 -0
- package/lib/cjs/filters/MatchFilter.js +65 -0
- package/lib/cjs/filters/MatchFilter.js.map +1 -0
- package/lib/cjs/filters/RateLimitFilter.d.ts +37 -0
- package/lib/cjs/filters/RateLimitFilter.d.ts.map +1 -0
- package/lib/cjs/filters/RateLimitFilter.js +70 -0
- package/lib/cjs/filters/RateLimitFilter.js.map +1 -0
- package/lib/cjs/filters/index.d.ts +4 -0
- package/lib/cjs/filters/index.d.ts.map +1 -0
- package/lib/cjs/filters/index.js +20 -0
- package/lib/cjs/filters/index.js.map +1 -0
- package/lib/cjs/index.browser.d.ts +14 -0
- package/lib/cjs/index.browser.d.ts.map +1 -0
- package/lib/cjs/index.browser.js +46 -0
- package/lib/cjs/index.browser.js.map +1 -0
- package/lib/cjs/index.d.ts +8 -0
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js +8 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/log.d.ts +60 -1
- package/lib/cjs/log.d.ts.map +1 -1
- package/lib/cjs/log.js +294 -32
- package/lib/cjs/log.js.map +1 -1
- package/lib/cjs/perf/LogMetricSink.d.ts +55 -0
- package/lib/cjs/perf/LogMetricSink.d.ts.map +1 -0
- package/lib/cjs/perf/LogMetricSink.js +154 -0
- package/lib/cjs/perf/LogMetricSink.js.map +1 -0
- package/lib/cjs/perf/measure.d.ts +9 -0
- package/lib/cjs/perf/measure.d.ts.map +1 -0
- package/lib/cjs/perf/measure.js +21 -0
- package/lib/cjs/perf/measure.js.map +1 -0
- package/lib/cjs/perf.d.ts +9 -0
- package/lib/cjs/perf.d.ts.map +1 -0
- package/lib/cjs/perf.js +18 -0
- package/lib/cjs/perf.js.map +1 -0
- package/lib/cjs/schemas/log.configuration.d.ts +151 -18
- package/lib/cjs/schemas/log.configuration.d.ts.map +1 -1
- package/lib/cjs/schemas/log.configuration.js +154 -21
- package/lib/cjs/schemas/log.configuration.js.map +1 -1
- package/lib/cjs/targets/BrowserConsoleTarget.d.ts +48 -0
- package/lib/cjs/targets/BrowserConsoleTarget.d.ts.map +1 -0
- package/lib/cjs/targets/BrowserConsoleTarget.js +48 -0
- package/lib/cjs/targets/BrowserConsoleTarget.js.map +1 -0
- package/lib/cjs/targets/ColoredConsoleTarget.d.ts.map +1 -1
- package/lib/cjs/targets/ColoredConsoleTarget.js +21 -12
- package/lib/cjs/targets/ColoredConsoleTarget.js.map +1 -1
- package/lib/cjs/targets/FileTarget.d.ts +96 -20
- package/lib/cjs/targets/FileTarget.d.ts.map +1 -1
- package/lib/cjs/targets/FileTarget.js +188 -225
- package/lib/cjs/targets/FileTarget.js.map +1 -1
- package/lib/cjs/targets/JsonFileTarget.d.ts +19 -0
- package/lib/cjs/targets/JsonFileTarget.d.ts.map +1 -0
- package/lib/cjs/targets/JsonFileTarget.js +44 -0
- package/lib/cjs/targets/JsonFileTarget.js.map +1 -0
- package/lib/cjs/targets/JsonTarget.d.ts +27 -0
- package/lib/cjs/targets/JsonTarget.d.ts.map +1 -0
- package/lib/cjs/targets/JsonTarget.js +46 -0
- package/lib/cjs/targets/JsonTarget.js.map +1 -0
- package/lib/cjs/targets/MemoryTarget.d.ts +33 -0
- package/lib/cjs/targets/MemoryTarget.d.ts.map +1 -0
- package/lib/cjs/targets/MemoryTarget.js +63 -0
- package/lib/cjs/targets/MemoryTarget.js.map +1 -0
- package/lib/cjs/targets/index.d.ts +7 -0
- package/lib/cjs/targets/index.d.ts.map +1 -1
- package/lib/cjs/targets/index.js +7 -0
- package/lib/cjs/targets/index.js.map +1 -1
- package/lib/cjs/targets/wrappers/AutoFlushTarget.d.ts +37 -0
- package/lib/cjs/targets/wrappers/AutoFlushTarget.d.ts.map +1 -0
- package/lib/cjs/targets/wrappers/AutoFlushTarget.js +48 -0
- package/lib/cjs/targets/wrappers/AutoFlushTarget.js.map +1 -0
- package/lib/cjs/targets/wrappers/FallbackGroupTarget.d.ts +45 -0
- package/lib/cjs/targets/wrappers/FallbackGroupTarget.d.ts.map +1 -0
- package/lib/cjs/targets/wrappers/FallbackGroupTarget.js +94 -0
- package/lib/cjs/targets/wrappers/FallbackGroupTarget.js.map +1 -0
- package/lib/cjs/targets/wrappers/RetryingTarget.d.ts +44 -0
- package/lib/cjs/targets/wrappers/RetryingTarget.d.ts.map +1 -0
- package/lib/cjs/targets/wrappers/RetryingTarget.js +61 -0
- package/lib/cjs/targets/wrappers/RetryingTarget.js.map +1 -0
- package/lib/cjs/targets/wrappers/SplitGroupTarget.d.ts +30 -0
- package/lib/cjs/targets/wrappers/SplitGroupTarget.d.ts.map +1 -0
- package/lib/cjs/targets/wrappers/SplitGroupTarget.js +52 -0
- package/lib/cjs/targets/wrappers/SplitGroupTarget.js.map +1 -0
- package/lib/cjs/traceparent.d.ts +63 -0
- package/lib/cjs/traceparent.d.ts.map +1 -0
- package/lib/cjs/traceparent.js +107 -0
- package/lib/cjs/traceparent.js.map +1 -0
- package/lib/mjs/archive/LogArchiveService.d.ts +75 -0
- package/lib/mjs/archive/LogArchiveService.d.ts.map +1 -0
- package/lib/mjs/archive/LogArchiveService.js +186 -0
- package/lib/mjs/archive/LogArchiveService.js.map +1 -0
- package/lib/mjs/archive/archive-strategy.d.ts +32 -0
- package/lib/mjs/archive/archive-strategy.d.ts.map +1 -0
- package/lib/mjs/archive/archive-strategy.js +39 -0
- package/lib/mjs/archive/archive-strategy.js.map +1 -0
- package/lib/mjs/archive/context.d.ts +50 -0
- package/lib/mjs/archive/context.d.ts.map +1 -0
- package/lib/mjs/archive/context.js +2 -0
- package/lib/mjs/archive/context.js.map +1 -0
- package/lib/mjs/archive/index.d.ts +10 -0
- package/lib/mjs/archive/index.d.ts.map +1 -0
- package/lib/mjs/archive/index.js +10 -0
- package/lib/mjs/archive/index.js.map +1 -0
- package/lib/mjs/archive/retention-strategy.d.ts +26 -0
- package/lib/mjs/archive/retention-strategy.d.ts.map +1 -0
- package/lib/mjs/archive/retention-strategy.js +38 -0
- package/lib/mjs/archive/retention-strategy.js.map +1 -0
- package/lib/mjs/archive/strategies/AgeLogRetentionStrategy.d.ts +10 -0
- package/lib/mjs/archive/strategies/AgeLogRetentionStrategy.d.ts.map +1 -0
- package/lib/mjs/archive/strategies/AgeLogRetentionStrategy.js +43 -0
- package/lib/mjs/archive/strategies/AgeLogRetentionStrategy.js.map +1 -0
- package/lib/mjs/archive/strategies/CountLogRetentionStrategy.d.ts +10 -0
- package/lib/mjs/archive/strategies/CountLogRetentionStrategy.d.ts.map +1 -0
- package/lib/mjs/archive/strategies/CountLogRetentionStrategy.js +39 -0
- package/lib/mjs/archive/strategies/CountLogRetentionStrategy.js.map +1 -0
- package/lib/mjs/archive/strategies/CronLogArchiveStrategy.d.ts +15 -0
- package/lib/mjs/archive/strategies/CronLogArchiveStrategy.d.ts.map +1 -0
- package/lib/mjs/archive/strategies/CronLogArchiveStrategy.js +49 -0
- package/lib/mjs/archive/strategies/CronLogArchiveStrategy.js.map +1 -0
- package/lib/mjs/archive/strategies/SizeLogArchiveStrategy.d.ts +18 -0
- package/lib/mjs/archive/strategies/SizeLogArchiveStrategy.d.ts.map +1 -0
- package/lib/mjs/archive/strategies/SizeLogArchiveStrategy.js +60 -0
- package/lib/mjs/archive/strategies/SizeLogArchiveStrategy.js.map +1 -0
- package/lib/mjs/archive/strategies/util.d.ts +28 -0
- package/lib/mjs/archive/strategies/util.d.ts.map +1 -0
- package/lib/mjs/archive/strategies/util.js +54 -0
- package/lib/mjs/archive/strategies/util.js.map +1 -0
- package/lib/mjs/bootstrap.d.ts.map +1 -1
- package/lib/mjs/bootstrap.js +25 -2
- package/lib/mjs/bootstrap.js.map +1 -1
- package/lib/mjs/callsite.d.ts +26 -0
- package/lib/mjs/callsite.d.ts.map +1 -0
- package/lib/mjs/callsite.js +57 -0
- package/lib/mjs/callsite.js.map +1 -0
- package/lib/mjs/config/log.d.ts +96 -0
- package/lib/mjs/config/log.d.ts.map +1 -0
- package/lib/mjs/config/log.js +72 -0
- package/lib/mjs/config/log.js.map +1 -0
- package/lib/mjs/context.browser.d.ts +46 -0
- package/lib/mjs/context.browser.d.ts.map +1 -0
- package/lib/mjs/context.browser.js +81 -0
- package/lib/mjs/context.browser.js.map +1 -0
- package/lib/mjs/context.d.ts +61 -0
- package/lib/mjs/context.d.ts.map +1 -0
- package/lib/mjs/context.js +88 -0
- package/lib/mjs/context.js.map +1 -0
- package/lib/mjs/filters/LevelFilter.d.ts +24 -0
- package/lib/mjs/filters/LevelFilter.d.ts.map +1 -0
- package/lib/mjs/filters/LevelFilter.js +36 -0
- package/lib/mjs/filters/LevelFilter.js.map +1 -0
- package/lib/mjs/filters/MatchFilter.d.ts +30 -0
- package/lib/mjs/filters/MatchFilter.d.ts.map +1 -0
- package/lib/mjs/filters/MatchFilter.js +62 -0
- package/lib/mjs/filters/MatchFilter.js.map +1 -0
- package/lib/mjs/filters/RateLimitFilter.d.ts +37 -0
- package/lib/mjs/filters/RateLimitFilter.d.ts.map +1 -0
- package/lib/mjs/filters/RateLimitFilter.js +67 -0
- package/lib/mjs/filters/RateLimitFilter.js.map +1 -0
- package/lib/mjs/filters/index.d.ts +4 -0
- package/lib/mjs/filters/index.d.ts.map +1 -0
- package/lib/mjs/filters/index.js +4 -0
- package/lib/mjs/filters/index.js.map +1 -0
- package/lib/mjs/index.browser.d.ts +14 -0
- package/lib/mjs/index.browser.d.ts.map +1 -0
- package/lib/mjs/index.browser.js +30 -0
- package/lib/mjs/index.browser.js.map +1 -0
- package/lib/mjs/index.d.ts +8 -0
- package/lib/mjs/index.d.ts.map +1 -1
- package/lib/mjs/index.js +8 -0
- package/lib/mjs/index.js.map +1 -1
- package/lib/mjs/log.d.ts +60 -1
- package/lib/mjs/log.d.ts.map +1 -1
- package/lib/mjs/log.js +295 -33
- package/lib/mjs/log.js.map +1 -1
- package/lib/mjs/perf/LogMetricSink.d.ts +55 -0
- package/lib/mjs/perf/LogMetricSink.d.ts.map +1 -0
- package/lib/mjs/perf/LogMetricSink.js +151 -0
- package/lib/mjs/perf/LogMetricSink.js.map +1 -0
- package/lib/mjs/perf/measure.d.ts +9 -0
- package/lib/mjs/perf/measure.d.ts.map +1 -0
- package/lib/mjs/perf/measure.js +18 -0
- package/lib/mjs/perf/measure.js.map +1 -0
- package/lib/mjs/perf.d.ts +9 -0
- package/lib/mjs/perf.d.ts.map +1 -0
- package/lib/mjs/perf.js +15 -0
- package/lib/mjs/perf.js.map +1 -0
- package/lib/mjs/schemas/log.configuration.d.ts +151 -18
- package/lib/mjs/schemas/log.configuration.d.ts.map +1 -1
- package/lib/mjs/schemas/log.configuration.js +154 -21
- package/lib/mjs/schemas/log.configuration.js.map +1 -1
- package/lib/mjs/targets/BrowserConsoleTarget.d.ts +48 -0
- package/lib/mjs/targets/BrowserConsoleTarget.d.ts.map +1 -0
- package/lib/mjs/targets/BrowserConsoleTarget.js +45 -0
- package/lib/mjs/targets/BrowserConsoleTarget.js.map +1 -0
- package/lib/mjs/targets/ColoredConsoleTarget.d.ts.map +1 -1
- package/lib/mjs/targets/ColoredConsoleTarget.js +21 -9
- package/lib/mjs/targets/ColoredConsoleTarget.js.map +1 -1
- package/lib/mjs/targets/FileTarget.d.ts +96 -20
- package/lib/mjs/targets/FileTarget.d.ts.map +1 -1
- package/lib/mjs/targets/FileTarget.js +191 -192
- package/lib/mjs/targets/FileTarget.js.map +1 -1
- package/lib/mjs/targets/JsonFileTarget.d.ts +19 -0
- package/lib/mjs/targets/JsonFileTarget.d.ts.map +1 -0
- package/lib/mjs/targets/JsonFileTarget.js +41 -0
- package/lib/mjs/targets/JsonFileTarget.js.map +1 -0
- package/lib/mjs/targets/JsonTarget.d.ts +27 -0
- package/lib/mjs/targets/JsonTarget.d.ts.map +1 -0
- package/lib/mjs/targets/JsonTarget.js +43 -0
- package/lib/mjs/targets/JsonTarget.js.map +1 -0
- package/lib/mjs/targets/MemoryTarget.d.ts +33 -0
- package/lib/mjs/targets/MemoryTarget.d.ts.map +1 -0
- package/lib/mjs/targets/MemoryTarget.js +60 -0
- package/lib/mjs/targets/MemoryTarget.js.map +1 -0
- package/lib/mjs/targets/index.d.ts +7 -0
- package/lib/mjs/targets/index.d.ts.map +1 -1
- package/lib/mjs/targets/index.js +7 -0
- package/lib/mjs/targets/index.js.map +1 -1
- package/lib/mjs/targets/wrappers/AutoFlushTarget.d.ts +37 -0
- package/lib/mjs/targets/wrappers/AutoFlushTarget.d.ts.map +1 -0
- package/lib/mjs/targets/wrappers/AutoFlushTarget.js +45 -0
- package/lib/mjs/targets/wrappers/AutoFlushTarget.js.map +1 -0
- package/lib/mjs/targets/wrappers/FallbackGroupTarget.d.ts +45 -0
- package/lib/mjs/targets/wrappers/FallbackGroupTarget.d.ts.map +1 -0
- package/lib/mjs/targets/wrappers/FallbackGroupTarget.js +91 -0
- package/lib/mjs/targets/wrappers/FallbackGroupTarget.js.map +1 -0
- package/lib/mjs/targets/wrappers/RetryingTarget.d.ts +44 -0
- package/lib/mjs/targets/wrappers/RetryingTarget.d.ts.map +1 -0
- package/lib/mjs/targets/wrappers/RetryingTarget.js +58 -0
- package/lib/mjs/targets/wrappers/RetryingTarget.js.map +1 -0
- package/lib/mjs/targets/wrappers/SplitGroupTarget.d.ts +30 -0
- package/lib/mjs/targets/wrappers/SplitGroupTarget.d.ts.map +1 -0
- package/lib/mjs/targets/wrappers/SplitGroupTarget.js +49 -0
- package/lib/mjs/targets/wrappers/SplitGroupTarget.js.map +1 -0
- package/lib/mjs/traceparent.d.ts +63 -0
- package/lib/mjs/traceparent.d.ts.map +1 -0
- package/lib/mjs/traceparent.js +100 -0
- package/lib/mjs/traceparent.js.map +1 -0
- package/lib/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/tsconfig.mjs.tsbuildinfo +1 -1
- package/package.json +26 -15
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Best-effort caller-frame capture for the `${callsite}` layout variable.
|
|
3
|
+
*
|
|
4
|
+
* NLog gates stack-trace capture behind `StackTraceUsage` so that logging is
|
|
5
|
+
* zero-cost unless a target's layout actually references the caller. This
|
|
6
|
+
* mirrors that: {@link FrameworkLogger} only calls {@link captureCallsite}
|
|
7
|
+
* when some target's layout references `${callsite}`, so the `new Error()`
|
|
8
|
+
* ( the only cost here ) is never constructed otherwise.
|
|
9
|
+
*
|
|
10
|
+
* The parser is intentionally defensive - it must NEVER throw. Browser stack
|
|
11
|
+
* formats vary and V8's format is not guaranteed, so an unparseable stack just
|
|
12
|
+
* yields `""` rather than crashing a log call.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Walk the current stack and return the first frame OUTSIDE the log package -
|
|
16
|
+
* i.e. the user's call site - as `"basename:line"` ( e.g. `service.ts:42` ).
|
|
17
|
+
*
|
|
18
|
+
* Internal frames belonging to the logger itself ( `log.ts`, `callsite.ts`,
|
|
19
|
+
* the `log-common` package, `wrapWrite`, `createLogMessageObject` ) are skipped
|
|
20
|
+
* so the returned frame is the caller of `log.info(...)` / `log.error(...)`.
|
|
21
|
+
*
|
|
22
|
+
* Returns `""` when no frame can be parsed ( no stack, or an unrecognized
|
|
23
|
+
* stack format ). Best-effort by design.
|
|
24
|
+
*/
|
|
25
|
+
export function captureCallsite() {
|
|
26
|
+
const stack = new Error().stack;
|
|
27
|
+
if (!stack) {
|
|
28
|
+
return "";
|
|
29
|
+
}
|
|
30
|
+
const lines = stack.split("\n");
|
|
31
|
+
for (const line of lines) {
|
|
32
|
+
// only real stack frames ( " at ..." ) - skip the leading "Error" line
|
|
33
|
+
// and any non-frame text.
|
|
34
|
+
if (!/\bat\b/.test(line)) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
// skip frames that live inside the logger's own code:
|
|
38
|
+
// - files log.ts / callsite.ts ( source ) or log.js / callsite.js ( built )
|
|
39
|
+
// - anything under a `log` or `log-common` package's src/ or lib/ tree
|
|
40
|
+
// - the internal helpers wrapWrite / createLogMessageObject
|
|
41
|
+
if (/[\\/]log(-common)?[\\/](src|lib)[\\/]|[\\/](log|callsite)\.(ts|js|mjs|cjs)\b|\bwrapWrite\b|\bcreateLogMessageObject\b|\bcaptureCallsite\b/.test(line)) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
// extract "path:line" from either:
|
|
45
|
+
// " at fn (path:line:col)" ( named frame )
|
|
46
|
+
// " at path:line:col" ( anonymous frame )
|
|
47
|
+
const m = line.match(/\(?([^()]+):(\d+):(\d+)\)?\s*$/);
|
|
48
|
+
if (m) {
|
|
49
|
+
// basename only - keeps rendered log lines short and stable across
|
|
50
|
+
// machines ( full absolute paths differ per checkout ).
|
|
51
|
+
const file = m[1].split(/[\\/]/).pop() ?? m[1];
|
|
52
|
+
return `${file}:${m[2]}`;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return "";
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=callsite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callsite.js","sourceRoot":"","sources":["../../src/callsite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC;IAChC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAChC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,0EAA0E;QAC1E,0BAA0B;QAC1B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,SAAS;QACX,CAAC;QAED,sDAAsD;QACtD,6EAA6E;QAC7E,wEAAwE;QACxE,6DAA6D;QAC7D,IAAI,2IAA2I,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3J,SAAS;QACX,CAAC;QAED,mCAAmC;QACnC,kDAAkD;QAClD,sDAAsD;QACtD,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACvD,IAAI,CAAC,EAAE,CAAC;YACN,mEAAmE;YACnE,wDAAwD;YACxD,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YAC/C,OAAO,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default configuration shipped with @spinajs/log ( Node only ).
|
|
3
|
+
*
|
|
4
|
+
* Everything the log package can be tuned with lives here, so the configuration
|
|
5
|
+
* module surfaces a single, discoverable list of what can be changed:
|
|
6
|
+
*
|
|
7
|
+
* 1. a DEFAULT fs provider `fs-log-default` rooted at the working process
|
|
8
|
+
* directory, so FileTarget works without any user fs configuration,
|
|
9
|
+
* 2. `logger.file` - the default FileTarget options ( buffer / rotation /
|
|
10
|
+
* retention tunables ). FileTarget merges these UNDER any per-target
|
|
11
|
+
* `options`, and a user project config ( loaded last ) overrides them - the
|
|
12
|
+
* same override chain every other spinajs package uses.
|
|
13
|
+
*
|
|
14
|
+
* Config files are merged with array concatenation, so the provider entry is
|
|
15
|
+
* APPENDED to any providers the user configures.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Canonical default FileTarget options. This is the SINGLE source of truth for
|
|
19
|
+
* every log tunable - change a default HERE, never inline in the target or a
|
|
20
|
+
* strategy. It is exported ( not just embedded in the config below ) so the
|
|
21
|
+
* FileTarget can fall back to the exact same values when the config file is not
|
|
22
|
+
* discovered ( eg. isolated unit tests ), and so tests share one definition.
|
|
23
|
+
*/
|
|
24
|
+
export declare const LOG_FILE_DEFAULTS: {
|
|
25
|
+
/** fs provider holding the active log file. */
|
|
26
|
+
fs: string;
|
|
27
|
+
/** Zip the archived file when it is moved to the archive. */
|
|
28
|
+
compress: boolean;
|
|
29
|
+
/** Rotate the active log once it grows past this many bytes ( 1 MB ). */
|
|
30
|
+
maxSize: number;
|
|
31
|
+
/** Flush the in-memory buffer after this many messages. */
|
|
32
|
+
maxBufferSize: number;
|
|
33
|
+
/** Hard cap on buffered messages; oldest are dropped past this so a down sink cannot OOM. */
|
|
34
|
+
maxQueueSize: number;
|
|
35
|
+
/** Periodic flush tick in milliseconds, so a partial buffer is not held. */
|
|
36
|
+
flushInterval: number;
|
|
37
|
+
/** How often ( seconds ) SizeLogArchiveStrategy checks the active log size. */
|
|
38
|
+
archiveInterval: number;
|
|
39
|
+
/** Rotation trigger strategy ( decides WHEN to archive ). */
|
|
40
|
+
archiveStrategy: string;
|
|
41
|
+
/** Retention strategies applied in order after each rotation. */
|
|
42
|
+
retentionStrategies: string[];
|
|
43
|
+
/** Archives to keep ( CountLogRetentionStrategy ), oldest deleted first. */
|
|
44
|
+
maxArchiveFiles: number;
|
|
45
|
+
/** Max archive age in seconds ( AgeLogRetentionStrategy ), 7 days. */
|
|
46
|
+
maxAge: number;
|
|
47
|
+
};
|
|
48
|
+
declare const log: {
|
|
49
|
+
fs: {
|
|
50
|
+
defaultProvider: string;
|
|
51
|
+
providers: {
|
|
52
|
+
name: string;
|
|
53
|
+
service: string;
|
|
54
|
+
basePath: string;
|
|
55
|
+
}[];
|
|
56
|
+
};
|
|
57
|
+
logger: {
|
|
58
|
+
file: {
|
|
59
|
+
/** fs provider holding the active log file. */
|
|
60
|
+
fs: string;
|
|
61
|
+
/** Zip the archived file when it is moved to the archive. */
|
|
62
|
+
compress: boolean;
|
|
63
|
+
/** Rotate the active log once it grows past this many bytes ( 1 MB ). */
|
|
64
|
+
maxSize: number;
|
|
65
|
+
/** Flush the in-memory buffer after this many messages. */
|
|
66
|
+
maxBufferSize: number;
|
|
67
|
+
/** Hard cap on buffered messages; oldest are dropped past this so a down sink cannot OOM. */
|
|
68
|
+
maxQueueSize: number;
|
|
69
|
+
/** Periodic flush tick in milliseconds, so a partial buffer is not held. */
|
|
70
|
+
flushInterval: number;
|
|
71
|
+
/** How often ( seconds ) SizeLogArchiveStrategy checks the active log size. */
|
|
72
|
+
archiveInterval: number;
|
|
73
|
+
/** Rotation trigger strategy ( decides WHEN to archive ). */
|
|
74
|
+
archiveStrategy: string;
|
|
75
|
+
/** Retention strategies applied in order after each rotation. */
|
|
76
|
+
retentionStrategies: string[];
|
|
77
|
+
/** Archives to keep ( CountLogRetentionStrategy ), oldest deleted first. */
|
|
78
|
+
maxArchiveFiles: number;
|
|
79
|
+
/** Max archive age in seconds ( AgeLogRetentionStrategy ), 7 days. */
|
|
80
|
+
maxAge: number;
|
|
81
|
+
};
|
|
82
|
+
perf: {
|
|
83
|
+
enabled: boolean;
|
|
84
|
+
thresholds: {
|
|
85
|
+
"orm.query": number;
|
|
86
|
+
"http.request": number;
|
|
87
|
+
default: number;
|
|
88
|
+
};
|
|
89
|
+
overThresholdLevel: string;
|
|
90
|
+
underThresholdLevel: string;
|
|
91
|
+
logCounters: boolean;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
export default log;
|
|
96
|
+
//# sourceMappingURL=log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../src/config/log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB;IAC5B,+CAA+C;;IAG/C,6DAA6D;;IAG7D,yEAAyE;;IAGzE,2DAA2D;;IAG3D,6FAA6F;;IAG7F,4EAA4E;;IAG5E,+EAA+E;;IAG/E,6DAA6D;;IAG7D,iEAAiE;;IAGjE,4EAA4E;;IAG5E,sEAAsE;;CAEvE,CAAC;AAEF,QAAA,MAAM,GAAG;;;;;;;;;;;YAlCP,+CAA+C;;YAG/C,6DAA6D;;YAG7D,yEAAyE;;YAGzE,2DAA2D;;YAG3D,6FAA6F;;YAG7F,4EAA4E;;YAG5E,+EAA+E;;YAG/E,6DAA6D;;YAG7D,iEAAiE;;YAGjE,4EAA4E;;YAG5E,sEAAsE;;;;;;;;;;;;;;;CAyBvE,CAAC;AAEF,eAAe,GAAG,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default configuration shipped with @spinajs/log ( Node only ).
|
|
3
|
+
*
|
|
4
|
+
* Everything the log package can be tuned with lives here, so the configuration
|
|
5
|
+
* module surfaces a single, discoverable list of what can be changed:
|
|
6
|
+
*
|
|
7
|
+
* 1. a DEFAULT fs provider `fs-log-default` rooted at the working process
|
|
8
|
+
* directory, so FileTarget works without any user fs configuration,
|
|
9
|
+
* 2. `logger.file` - the default FileTarget options ( buffer / rotation /
|
|
10
|
+
* retention tunables ). FileTarget merges these UNDER any per-target
|
|
11
|
+
* `options`, and a user project config ( loaded last ) overrides them - the
|
|
12
|
+
* same override chain every other spinajs package uses.
|
|
13
|
+
*
|
|
14
|
+
* Config files are merged with array concatenation, so the provider entry is
|
|
15
|
+
* APPENDED to any providers the user configures.
|
|
16
|
+
*/
|
|
17
|
+
const DEFAULT_FS_PROVIDER = "fs-log-default";
|
|
18
|
+
/**
|
|
19
|
+
* Canonical default FileTarget options. This is the SINGLE source of truth for
|
|
20
|
+
* every log tunable - change a default HERE, never inline in the target or a
|
|
21
|
+
* strategy. It is exported ( not just embedded in the config below ) so the
|
|
22
|
+
* FileTarget can fall back to the exact same values when the config file is not
|
|
23
|
+
* discovered ( eg. isolated unit tests ), and so tests share one definition.
|
|
24
|
+
*/
|
|
25
|
+
export const LOG_FILE_DEFAULTS = {
|
|
26
|
+
/** fs provider holding the active log file. */
|
|
27
|
+
fs: DEFAULT_FS_PROVIDER,
|
|
28
|
+
/** Zip the archived file when it is moved to the archive. */
|
|
29
|
+
compress: false,
|
|
30
|
+
/** Rotate the active log once it grows past this many bytes ( 1 MB ). */
|
|
31
|
+
maxSize: 1024 * 1024,
|
|
32
|
+
/** Flush the in-memory buffer after this many messages. */
|
|
33
|
+
maxBufferSize: 100,
|
|
34
|
+
/** Hard cap on buffered messages; oldest are dropped past this so a down sink cannot OOM. */
|
|
35
|
+
maxQueueSize: 100000,
|
|
36
|
+
/** Periodic flush tick in milliseconds, so a partial buffer is not held. */
|
|
37
|
+
flushInterval: 1000,
|
|
38
|
+
/** How often ( seconds ) SizeLogArchiveStrategy checks the active log size. */
|
|
39
|
+
archiveInterval: 60,
|
|
40
|
+
/** Rotation trigger strategy ( decides WHEN to archive ). */
|
|
41
|
+
archiveStrategy: "SizeLogArchiveStrategy",
|
|
42
|
+
/** Retention strategies applied in order after each rotation. */
|
|
43
|
+
retentionStrategies: ["CountLogRetentionStrategy"],
|
|
44
|
+
/** Archives to keep ( CountLogRetentionStrategy ), oldest deleted first. */
|
|
45
|
+
maxArchiveFiles: 5,
|
|
46
|
+
/** Max archive age in seconds ( AgeLogRetentionStrategy ), 7 days. */
|
|
47
|
+
maxAge: 7 * 24 * 60 * 60,
|
|
48
|
+
};
|
|
49
|
+
const log = {
|
|
50
|
+
fs: {
|
|
51
|
+
defaultProvider: DEFAULT_FS_PROVIDER,
|
|
52
|
+
providers: [
|
|
53
|
+
{
|
|
54
|
+
name: DEFAULT_FS_PROVIDER,
|
|
55
|
+
service: "fsNative",
|
|
56
|
+
basePath: process.cwd(),
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
logger: {
|
|
61
|
+
file: LOG_FILE_DEFAULTS,
|
|
62
|
+
perf: {
|
|
63
|
+
enabled: true,
|
|
64
|
+
thresholds: { "orm.query": 200, "http.request": 1000, default: 0 },
|
|
65
|
+
overThresholdLevel: "warn",
|
|
66
|
+
underThresholdLevel: "trace",
|
|
67
|
+
logCounters: false,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
export default log;
|
|
72
|
+
//# sourceMappingURL=log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../src/config/log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,+CAA+C;IAC/C,EAAE,EAAE,mBAAmB;IAEvB,6DAA6D;IAC7D,QAAQ,EAAE,KAAK;IAEf,yEAAyE;IACzE,OAAO,EAAE,IAAI,GAAG,IAAI;IAEpB,2DAA2D;IAC3D,aAAa,EAAE,GAAG;IAElB,6FAA6F;IAC7F,YAAY,EAAE,MAAM;IAEpB,4EAA4E;IAC5E,aAAa,EAAE,IAAI;IAEnB,+EAA+E;IAC/E,eAAe,EAAE,EAAE;IAEnB,6DAA6D;IAC7D,eAAe,EAAE,wBAAwB;IAEzC,iEAAiE;IACjE,mBAAmB,EAAE,CAAC,2BAA2B,CAAC;IAElD,4EAA4E;IAC5E,eAAe,EAAE,CAAC;IAElB,sEAAsE;IACtE,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE;CACzB,CAAC;AAEF,MAAM,GAAG,GAAG;IACV,EAAE,EAAE;QACF,eAAe,EAAE,mBAAmB;QACpC,SAAS,EAAE;YACT;gBACE,IAAI,EAAE,mBAAmB;gBACzB,OAAO,EAAE,UAAU;gBACnB,QAAQ,EAAE,OAAO,CAAC,GAAG,EAAE;aACxB;SACF;KACF;IACD,MAAM,EAAE;QACN,IAAI,EAAE,iBAAiB;QACvB,IAAI,EAAE;YACJ,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE;YAClE,kBAAkB,EAAE,MAAM;YAC1B,mBAAmB,EAAE,OAAO;YAC5B,WAAW,EAAE,KAAK;SACnB;KACF;CACF,CAAC;AAEF,eAAe,GAAG,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser fallback for {@link LogContext}. The browser has no
|
|
3
|
+
* `node:async_hooks` / AsyncLocalStorage, so this keeps a single module-level
|
|
4
|
+
* `current` object and swaps it synchronously around `with`.
|
|
5
|
+
*
|
|
6
|
+
* LIMITATION: there is NO async isolation here. `with` only holds the context
|
|
7
|
+
* for the synchronous portion of `fn`; anything that runs after an `await` or a
|
|
8
|
+
* deferred callback ( unless wrapped with {@link LogContextImpl.bind} ) will not
|
|
9
|
+
* see it. This mirrors the Node API surface so callers write the same code, but
|
|
10
|
+
* on the browser ambient context is best-effort and synchronous only.
|
|
11
|
+
*/
|
|
12
|
+
declare class LogContextImpl {
|
|
13
|
+
private current;
|
|
14
|
+
/**
|
|
15
|
+
* The current ambient store.
|
|
16
|
+
*/
|
|
17
|
+
active(): Record<string, unknown>;
|
|
18
|
+
/**
|
|
19
|
+
* Synchronously set the context to `{ ...current, ...vars }` for the duration
|
|
20
|
+
* of `fn`, restoring the previous value afterwards. No async isolation.
|
|
21
|
+
*/
|
|
22
|
+
with<T>(vars: Record<string, unknown>, fn: () => T): T;
|
|
23
|
+
/**
|
|
24
|
+
* Mutate the current store in place ( late-bound values ).
|
|
25
|
+
*/
|
|
26
|
+
set(key: string, value: unknown): void;
|
|
27
|
+
/**
|
|
28
|
+
* Capture the current store and restore it around each invocation of the
|
|
29
|
+
* returned function.
|
|
30
|
+
*/
|
|
31
|
+
bind<A extends unknown[], R>(fn: (...a: A) => R): (...a: A) => R;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Shared ambient log context ( browser, synchronous fallback ).
|
|
35
|
+
*/
|
|
36
|
+
export declare const LogContext: LogContextImpl;
|
|
37
|
+
/**
|
|
38
|
+
* Projects only primitive scalar values ( string / number / boolean / bigint )
|
|
39
|
+
* from an ambient-context object, dropping objects, arrays, Dates, functions,
|
|
40
|
+
* null and undefined. Ambient context is meant for correlation ids ( requestId,
|
|
41
|
+
* traceId, ... ) that belong on every log line; structured payloads should be
|
|
42
|
+
* passed explicitly per call ( log.info({ obj }, ... ) ), not via ambient context.
|
|
43
|
+
*/
|
|
44
|
+
export declare function scalarContext(ctx: Record<string, unknown>): Record<string, unknown>;
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=context.browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.browser.d.ts","sourceRoot":"","sources":["../../src/context.browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,cAAM,cAAc;IAClB,OAAO,CAAC,OAAO,CAA+B;IAE9C;;OAEG;IACI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAIxC;;;OAGG;IACI,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;IAU7D;;OAEG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAI7C;;;OAGG;IACI,IAAI,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC;CAYxE;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,gBAAuB,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASnF"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser fallback for {@link LogContext}. The browser has no
|
|
3
|
+
* `node:async_hooks` / AsyncLocalStorage, so this keeps a single module-level
|
|
4
|
+
* `current` object and swaps it synchronously around `with`.
|
|
5
|
+
*
|
|
6
|
+
* LIMITATION: there is NO async isolation here. `with` only holds the context
|
|
7
|
+
* for the synchronous portion of `fn`; anything that runs after an `await` or a
|
|
8
|
+
* deferred callback ( unless wrapped with {@link LogContextImpl.bind} ) will not
|
|
9
|
+
* see it. This mirrors the Node API surface so callers write the same code, but
|
|
10
|
+
* on the browser ambient context is best-effort and synchronous only.
|
|
11
|
+
*/
|
|
12
|
+
class LogContextImpl {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.current = {};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The current ambient store.
|
|
18
|
+
*/
|
|
19
|
+
active() {
|
|
20
|
+
return this.current;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Synchronously set the context to `{ ...current, ...vars }` for the duration
|
|
24
|
+
* of `fn`, restoring the previous value afterwards. No async isolation.
|
|
25
|
+
*/
|
|
26
|
+
with(vars, fn) {
|
|
27
|
+
const previous = this.current;
|
|
28
|
+
this.current = { ...previous, ...vars };
|
|
29
|
+
try {
|
|
30
|
+
return fn();
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
this.current = previous;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Mutate the current store in place ( late-bound values ).
|
|
38
|
+
*/
|
|
39
|
+
set(key, value) {
|
|
40
|
+
this.current[key] = value;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Capture the current store and restore it around each invocation of the
|
|
44
|
+
* returned function.
|
|
45
|
+
*/
|
|
46
|
+
bind(fn) {
|
|
47
|
+
const captured = this.current;
|
|
48
|
+
return (...args) => {
|
|
49
|
+
const previous = this.current;
|
|
50
|
+
this.current = captured;
|
|
51
|
+
try {
|
|
52
|
+
return fn(...args);
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
this.current = previous;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Shared ambient log context ( browser, synchronous fallback ).
|
|
62
|
+
*/
|
|
63
|
+
export const LogContext = new LogContextImpl();
|
|
64
|
+
/**
|
|
65
|
+
* Projects only primitive scalar values ( string / number / boolean / bigint )
|
|
66
|
+
* from an ambient-context object, dropping objects, arrays, Dates, functions,
|
|
67
|
+
* null and undefined. Ambient context is meant for correlation ids ( requestId,
|
|
68
|
+
* traceId, ... ) that belong on every log line; structured payloads should be
|
|
69
|
+
* passed explicitly per call ( log.info({ obj }, ... ) ), not via ambient context.
|
|
70
|
+
*/
|
|
71
|
+
export function scalarContext(ctx) {
|
|
72
|
+
const out = {};
|
|
73
|
+
for (const [k, v] of Object.entries(ctx)) {
|
|
74
|
+
const t = typeof v;
|
|
75
|
+
if (t === "string" || t === "number" || t === "boolean" || t === "bigint") {
|
|
76
|
+
out[k] = v;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=context.browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.browser.js","sourceRoot":"","sources":["../../src/context.browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,cAAc;IAApB;QACU,YAAO,GAA4B,EAAE,CAAC;IA8ChD,CAAC;IA5CC;;OAEG;IACI,MAAM;QACX,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;OAGG;IACI,IAAI,CAAI,IAA6B,EAAE,EAAW;QACvD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,QAAQ,EAAE,GAAG,IAAI,EAAE,CAAC;QACxC,IAAI,CAAC;YACH,OAAO,EAAE,EAAE,CAAC;QACd,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC;QAC1B,CAAC;IACH,CAAC;IAED;;OAEG;IACI,GAAG,CAAC,GAAW,EAAE,KAAc;QACpC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACI,IAAI,CAAyB,EAAkB;QACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC;QAC9B,OAAO,CAAC,GAAG,IAAO,EAAK,EAAE;YACvB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC;YAC9B,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC;YACxB,IAAI,CAAC;gBACH,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;YACrB,CAAC;oBAAS,CAAC;gBACT,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC;YAC1B,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,cAAc,EAAE,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,GAA4B;IACxD,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACzC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC;QACnB,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC1E,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACb,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ambient log context backed by `node:async_hooks` AsyncLocalStorage.
|
|
3
|
+
*
|
|
4
|
+
* It deliberately resolves the SAME DI-singleton AsyncLocalStorage instance the
|
|
5
|
+
* @spinajs/http module runs per action ( `als.run(req.storage, ...)` ). Because
|
|
6
|
+
* that instance is a shared DI singleton, any log emitted anywhere inside a
|
|
7
|
+
* request automatically inherits the request store ( requestId, realIp, ... )
|
|
8
|
+
* with zero threading — the log package wires `setLogContextProvider(() =>
|
|
9
|
+
* LogContext.active())` so `createLogMessageObject` merges it at lowest
|
|
10
|
+
* precedence.
|
|
11
|
+
*
|
|
12
|
+
* The store type is a plain `Record<string, unknown>` — a superset of http's
|
|
13
|
+
* `IActionLocalStoregeContext` — so log stays independent of http.
|
|
14
|
+
*/
|
|
15
|
+
declare class LogContextImpl {
|
|
16
|
+
/**
|
|
17
|
+
* Resolve the shared AsyncLocalStorage from DI. Resolved as a bare concrete
|
|
18
|
+
* class it is a shared singleton, so this is the very instance http drives per
|
|
19
|
+
* action. We deliberately do NOT cache the reference: DI returns the same
|
|
20
|
+
* singleton on every call ( cheap lookup ), and NOT caching keeps LogContext
|
|
21
|
+
* consistent with the current DI instance even if the container is reset /
|
|
22
|
+
* re-registered ( a stale cached reference would silently diverge — e.g. after
|
|
23
|
+
* a `DI.clearCache()` the store written via a freshly-resolved instance would
|
|
24
|
+
* be invisible here ).
|
|
25
|
+
*/
|
|
26
|
+
private storage;
|
|
27
|
+
/**
|
|
28
|
+
* The current ambient store, or an empty object when outside any context.
|
|
29
|
+
*/
|
|
30
|
+
active(): Record<string, unknown>;
|
|
31
|
+
/**
|
|
32
|
+
* Run `fn` with `vars` merged ( copy-on-write ) onto the current store, so
|
|
33
|
+
* nesting accumulates and http's already-set fields ( eg. requestId ) survive.
|
|
34
|
+
*/
|
|
35
|
+
with<T>(vars: Record<string, unknown>, fn: () => T): T;
|
|
36
|
+
/**
|
|
37
|
+
* Mutate the current store in place ( late-bound values ). No-op when called
|
|
38
|
+
* outside any active context.
|
|
39
|
+
*/
|
|
40
|
+
set(key: string, value: unknown): void;
|
|
41
|
+
/**
|
|
42
|
+
* Capture the current store and re-attach it whenever the returned function is
|
|
43
|
+
* invoked. Use to carry context across detached callbacks / EventEmitter
|
|
44
|
+
* handlers that would otherwise lose it.
|
|
45
|
+
*/
|
|
46
|
+
bind<A extends unknown[], R>(fn: (...a: A) => R): (...a: A) => R;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Shared ambient log context. See {@link LogContextImpl}.
|
|
50
|
+
*/
|
|
51
|
+
export declare const LogContext: LogContextImpl;
|
|
52
|
+
/**
|
|
53
|
+
* Projects only primitive scalar values ( string / number / boolean / bigint )
|
|
54
|
+
* from an ambient-context object, dropping objects, arrays, Dates, functions,
|
|
55
|
+
* null and undefined. Ambient context is meant for correlation ids ( requestId,
|
|
56
|
+
* traceId, ... ) that belong on every log line; structured payloads should be
|
|
57
|
+
* passed explicitly per call ( log.info({ obj }, ... ) ), not via ambient context.
|
|
58
|
+
*/
|
|
59
|
+
export declare function scalarContext(ctx: Record<string, unknown>): Record<string, unknown>;
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;GAaG;AACH,cAAM,cAAc;IAClB;;;;;;;;;OASG;IACH,OAAO,CAAC,OAAO;IAIf;;OAEG;IACI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAIxC;;;OAGG;IACI,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;IAI7D;;;OAGG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAO7C;;;;OAIG;IACI,IAAI,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC;CAOxE;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,gBAAuB,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASnF"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { DI } from "@spinajs/di";
|
|
3
|
+
/**
|
|
4
|
+
* Ambient log context backed by `node:async_hooks` AsyncLocalStorage.
|
|
5
|
+
*
|
|
6
|
+
* It deliberately resolves the SAME DI-singleton AsyncLocalStorage instance the
|
|
7
|
+
* @spinajs/http module runs per action ( `als.run(req.storage, ...)` ). Because
|
|
8
|
+
* that instance is a shared DI singleton, any log emitted anywhere inside a
|
|
9
|
+
* request automatically inherits the request store ( requestId, realIp, ... )
|
|
10
|
+
* with zero threading — the log package wires `setLogContextProvider(() =>
|
|
11
|
+
* LogContext.active())` so `createLogMessageObject` merges it at lowest
|
|
12
|
+
* precedence.
|
|
13
|
+
*
|
|
14
|
+
* The store type is a plain `Record<string, unknown>` — a superset of http's
|
|
15
|
+
* `IActionLocalStoregeContext` — so log stays independent of http.
|
|
16
|
+
*/
|
|
17
|
+
class LogContextImpl {
|
|
18
|
+
/**
|
|
19
|
+
* Resolve the shared AsyncLocalStorage from DI. Resolved as a bare concrete
|
|
20
|
+
* class it is a shared singleton, so this is the very instance http drives per
|
|
21
|
+
* action. We deliberately do NOT cache the reference: DI returns the same
|
|
22
|
+
* singleton on every call ( cheap lookup ), and NOT caching keeps LogContext
|
|
23
|
+
* consistent with the current DI instance even if the container is reset /
|
|
24
|
+
* re-registered ( a stale cached reference would silently diverge — e.g. after
|
|
25
|
+
* a `DI.clearCache()` the store written via a freshly-resolved instance would
|
|
26
|
+
* be invisible here ).
|
|
27
|
+
*/
|
|
28
|
+
storage() {
|
|
29
|
+
return DI.resolve(AsyncLocalStorage);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The current ambient store, or an empty object when outside any context.
|
|
33
|
+
*/
|
|
34
|
+
active() {
|
|
35
|
+
return this.storage().getStore() ?? {};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Run `fn` with `vars` merged ( copy-on-write ) onto the current store, so
|
|
39
|
+
* nesting accumulates and http's already-set fields ( eg. requestId ) survive.
|
|
40
|
+
*/
|
|
41
|
+
with(vars, fn) {
|
|
42
|
+
return this.storage().run({ ...this.active(), ...vars }, fn);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Mutate the current store in place ( late-bound values ). No-op when called
|
|
46
|
+
* outside any active context.
|
|
47
|
+
*/
|
|
48
|
+
set(key, value) {
|
|
49
|
+
const store = this.storage().getStore();
|
|
50
|
+
if (store) {
|
|
51
|
+
store[key] = value;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Capture the current store and re-attach it whenever the returned function is
|
|
56
|
+
* invoked. Use to carry context across detached callbacks / EventEmitter
|
|
57
|
+
* handlers that would otherwise lose it.
|
|
58
|
+
*/
|
|
59
|
+
bind(fn) {
|
|
60
|
+
const store = this.storage().getStore();
|
|
61
|
+
if (!store) {
|
|
62
|
+
return fn;
|
|
63
|
+
}
|
|
64
|
+
return (...args) => this.storage().run(store, () => fn(...args));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Shared ambient log context. See {@link LogContextImpl}.
|
|
69
|
+
*/
|
|
70
|
+
export const LogContext = new LogContextImpl();
|
|
71
|
+
/**
|
|
72
|
+
* Projects only primitive scalar values ( string / number / boolean / bigint )
|
|
73
|
+
* from an ambient-context object, dropping objects, arrays, Dates, functions,
|
|
74
|
+
* null and undefined. Ambient context is meant for correlation ids ( requestId,
|
|
75
|
+
* traceId, ... ) that belong on every log line; structured payloads should be
|
|
76
|
+
* passed explicitly per call ( log.info({ obj }, ... ) ), not via ambient context.
|
|
77
|
+
*/
|
|
78
|
+
export function scalarContext(ctx) {
|
|
79
|
+
const out = {};
|
|
80
|
+
for (const [k, v] of Object.entries(ctx)) {
|
|
81
|
+
const t = typeof v;
|
|
82
|
+
if (t === "string" || t === "number" || t === "boolean" || t === "bigint") {
|
|
83
|
+
out[k] = v;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC;;;;;;;;;;;;;GAaG;AACH,MAAM,cAAc;IAClB;;;;;;;;;OASG;IACK,OAAO;QACb,OAAO,EAAE,CAAC,OAAO,CAAC,iBAAiB,CAA+C,CAAC;IACrF,CAAC;IAED;;OAEG;IACI,MAAM;QACX,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC;IACzC,CAAC;IAED;;;OAGG;IACI,IAAI,CAAI,IAA6B,EAAE,EAAW;QACvD,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED;;;OAGG;IACI,GAAG,CAAC,GAAW,EAAE,KAAc;QACpC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC;QACxC,IAAI,KAAK,EAAE,CAAC;YACV,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACrB,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,IAAI,CAAyB,EAAkB;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC;QACxC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,CAAC,GAAG,IAAO,EAAK,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACzE,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,cAAc,EAAE,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,GAA4B;IACxD,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACzC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC;QACnB,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC1E,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACb,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ILogEntry, ILogFilterOptions, LogFilter, LogLevel, StrToLogLevel } from "@spinajs/log-common";
|
|
2
|
+
type LevelName = keyof typeof StrToLogLevel;
|
|
3
|
+
/**
|
|
4
|
+
* Options for {@link LevelFilter}.
|
|
5
|
+
*/
|
|
6
|
+
export interface ILevelFilterOptions extends ILogFilterOptions {
|
|
7
|
+
/** Lowest level to keep ( inclusive ). Entries below are dropped. */
|
|
8
|
+
min?: LevelName;
|
|
9
|
+
/** Highest level to keep ( inclusive ). Entries above are dropped. */
|
|
10
|
+
max?: LevelName;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Level-window filter. Keeps an entry only when its numeric {@link LogLevel} is
|
|
14
|
+
* within `[min, max]` ( both inclusive, both optional ), otherwise drops it.
|
|
15
|
+
* Useful for routing eg. only warn..error to a given target via a filter.
|
|
16
|
+
*/
|
|
17
|
+
export declare class LevelFilter extends LogFilter {
|
|
18
|
+
protected min: LogLevel;
|
|
19
|
+
protected max: LogLevel;
|
|
20
|
+
constructor(options?: ILevelFilterOptions);
|
|
21
|
+
apply(entry: ILogEntry): ILogEntry | null;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=LevelFilter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LevelFilter.d.ts","sourceRoot":"","sources":["../../../src/filters/LevelFilter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGvG,KAAK,SAAS,GAAG,MAAM,OAAO,aAAa,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC5D,qEAAqE;IACrE,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,sEAAsE;IACtE,GAAG,CAAC,EAAE,SAAS,CAAC;CACjB;AAED;;;;GAIG;AACH,qBAEa,WAAY,SAAQ,SAAS;IACxC,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC;IACxB,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC;gBAEZ,OAAO,CAAC,EAAE,mBAAmB;IAMlC,KAAK,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI;CAMjD"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { LogFilter, LogLevel, StrToLogLevel } from "@spinajs/log-common";
|
|
11
|
+
import { Injectable, NewInstance } from "@spinajs/di";
|
|
12
|
+
/**
|
|
13
|
+
* Level-window filter. Keeps an entry only when its numeric {@link LogLevel} is
|
|
14
|
+
* within `[min, max]` ( both inclusive, both optional ), otherwise drops it.
|
|
15
|
+
* Useful for routing eg. only warn..error to a given target via a filter.
|
|
16
|
+
*/
|
|
17
|
+
let LevelFilter = class LevelFilter extends LogFilter {
|
|
18
|
+
constructor(options) {
|
|
19
|
+
super(options);
|
|
20
|
+
this.min = options?.min !== undefined ? StrToLogLevel[options.min] : LogLevel.Trace;
|
|
21
|
+
this.max = options?.max !== undefined ? StrToLogLevel[options.max] : LogLevel.Security;
|
|
22
|
+
}
|
|
23
|
+
apply(entry) {
|
|
24
|
+
if (entry.Level < this.min || entry.Level > this.max) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return entry;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
LevelFilter = __decorate([
|
|
31
|
+
Injectable("LevelFilter"),
|
|
32
|
+
NewInstance(),
|
|
33
|
+
__metadata("design:paramtypes", [Object])
|
|
34
|
+
], LevelFilter);
|
|
35
|
+
export { LevelFilter };
|
|
36
|
+
//# sourceMappingURL=LevelFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LevelFilter.js","sourceRoot":"","sources":["../../../src/filters/LevelFilter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAgC,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACvG,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AActD;;;;GAIG;AAGI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,SAAS;IAIxC,YAAY,OAA6B;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,OAAO,EAAE,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;QACpF,IAAI,CAAC,GAAG,GAAG,OAAO,EAAE,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;IACzF,CAAC;IAEM,KAAK,CAAC,KAAgB;QAC3B,IAAI,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,IAAI,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACrD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AAhBY,WAAW;IAFvB,UAAU,CAAC,aAAa,CAAC;IACzB,WAAW,EAAE;;GACD,WAAW,CAgBvB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ILogEntry, ILogFilterOptions, LogFilter } from "@spinajs/log-common";
|
|
2
|
+
/**
|
|
3
|
+
* Options for {@link MatchFilter}.
|
|
4
|
+
*/
|
|
5
|
+
export interface IMatchFilterOptions extends ILogFilterOptions {
|
|
6
|
+
/** Regex source tested against the chosen field. Required. */
|
|
7
|
+
pattern: string;
|
|
8
|
+
/** Variable field to test. Default "message". */
|
|
9
|
+
field?: string;
|
|
10
|
+
/** "keep" ( default ) keeps on match, drops otherwise; "drop" drops on match. */
|
|
11
|
+
mode?: "keep" | "drop";
|
|
12
|
+
/** RegExp flags ( eg. "i" ). */
|
|
13
|
+
flags?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Regex keep/drop filter. Builds a RegExp from `pattern`/`flags` and tests it
|
|
17
|
+
* against `String(entry.Variables[field])` ( field defaults to "message" ).
|
|
18
|
+
* In "keep" mode the entry is kept only on a match; in "drop" mode it is
|
|
19
|
+
* dropped on a match. An invalid pattern degrades to a no-op ( pass-through )
|
|
20
|
+
* and warns ONCE so a bad config never silently swallows or drops everything.
|
|
21
|
+
*/
|
|
22
|
+
export declare class MatchFilter extends LogFilter {
|
|
23
|
+
protected regex: RegExp | null;
|
|
24
|
+
protected field: string;
|
|
25
|
+
protected mode: "keep" | "drop";
|
|
26
|
+
protected warned: boolean;
|
|
27
|
+
constructor(options?: IMatchFilterOptions);
|
|
28
|
+
apply(entry: ILogEntry): ILogEntry | null;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=MatchFilter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MatchFilter.d.ts","sourceRoot":"","sources":["../../../src/filters/MatchFilter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAG9E;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC5D,8DAA8D;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,qBAEa,WAAY,SAAQ,SAAS;IACxC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAQ;IACtC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAChC,SAAS,CAAC,MAAM,UAAS;gBAEb,OAAO,CAAC,EAAE,mBAAmB;IAqBlC,KAAK,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI;CAejD"}
|