@spinajs/log 2.0.481 → 2.0.482
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 +28 -0
- package/lib/cjs/perf/LogMetricSink.d.ts.map +1 -0
- package/lib/cjs/perf/LogMetricSink.js +120 -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 +28 -0
- package/lib/mjs/perf/LogMetricSink.d.ts.map +1 -0
- package/lib/mjs/perf/LogMetricSink.js +117 -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 +25 -15
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.CountLogRetentionStrategy = void 0;
|
|
10
|
+
const di_1 = require("@spinajs/di");
|
|
11
|
+
const retention_strategy_js_1 = require("../retention-strategy.js");
|
|
12
|
+
const util_js_1 = require("./util.js");
|
|
13
|
+
/**
|
|
14
|
+
* Keeps the newest N archives ( `maxArchiveFiles`, from the logger.file config
|
|
15
|
+
* defaults ) and deletes the oldest, ordered by modification time.
|
|
16
|
+
*/
|
|
17
|
+
let CountLogRetentionStrategy = class CountLogRetentionStrategy extends retention_strategy_js_1.LogRetentionStrategy {
|
|
18
|
+
async prune(ctx) {
|
|
19
|
+
const keep = ctx.options.maxArchiveFiles;
|
|
20
|
+
// newest last ( ascending by ModifiedTime )
|
|
21
|
+
const archives = await (0, util_js_1.listArchives)(ctx);
|
|
22
|
+
if (archives.length <= keep) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const toDelete = archives.slice(0, archives.length - keep);
|
|
26
|
+
for (const a of toDelete) {
|
|
27
|
+
try {
|
|
28
|
+
this.Logger.trace(`Deleting archive ${a.path} ( over count limit ${keep} )`);
|
|
29
|
+
await ctx.archiveFs.rm(a.path);
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
this.Logger.warn(`Cannot delete archive ${a.path}: ${err.message}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
exports.CountLogRetentionStrategy = CountLogRetentionStrategy;
|
|
38
|
+
exports.CountLogRetentionStrategy = CountLogRetentionStrategy = __decorate([
|
|
39
|
+
(0, di_1.Injectable)(retention_strategy_js_1.LogRetentionStrategy),
|
|
40
|
+
(0, di_1.NewInstance)()
|
|
41
|
+
], CountLogRetentionStrategy);
|
|
42
|
+
//# sourceMappingURL=CountLogRetentionStrategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CountLogRetentionStrategy.js","sourceRoot":"","sources":["../../../../src/archive/strategies/CountLogRetentionStrategy.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oCAAsD;AACtD,oEAAgE;AAEhE,uCAAyC;AAEzC;;;GAGG;AAGI,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,4CAAoB;IAC1D,KAAK,CAAC,KAAK,CAAC,GAAuB;QACxC,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC;QAEzC,4CAA4C;QAC5C,MAAM,QAAQ,GAAG,MAAM,IAAA,sBAAY,EAAC,GAAG,CAAC,CAAC;QAEzC,IAAI,QAAQ,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;YAC5B,OAAO;QACT,CAAC;QAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;QAE3D,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;YACzB,IAAI,CAAC;gBACH,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,IAAI,uBAAuB,IAAI,IAAI,CAAC,CAAC;gBAC7E,MAAM,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YACjC,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC,IAAI,KAAM,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;YACjF,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAA;AAtBY,8DAAyB;oCAAzB,yBAAyB;IAFrC,IAAA,eAAU,EAAC,4CAAoB,CAAC;IAChC,IAAA,gBAAW,GAAE;GACD,yBAAyB,CAsBrC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CronJob } from "cron";
|
|
2
|
+
import { LogArchiveStrategy } from "../archive-strategy.js";
|
|
3
|
+
import { ILogArchiveContext } from "../context.js";
|
|
4
|
+
/**
|
|
5
|
+
* Rotates the active log file on a cron schedule taken from the `rotate`
|
|
6
|
+
* option ( 6-field with seconds supported, eg. '0 0 1 * * *' = 1am daily ).
|
|
7
|
+
* The expression is required - creation fails without it, like fs
|
|
8
|
+
* CronTempCleanupStrategy.
|
|
9
|
+
*/
|
|
10
|
+
export declare class CronLogArchiveStrategy extends LogArchiveStrategy {
|
|
11
|
+
protected cronJob: CronJob | null;
|
|
12
|
+
start(ctx: ILogArchiveContext): void;
|
|
13
|
+
stop(): void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=CronLogArchiveStrategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CronLogArchiveStrategy.d.ts","sourceRoot":"","sources":["../../../../src/archive/strategies/CronLogArchiveStrategy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD;;;;;GAKG;AACH,qBAEa,sBAAuB,SAAQ,kBAAkB;IAC5D,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAQ;IAElC,KAAK,CAAC,GAAG,EAAE,kBAAkB,GAAG,IAAI;IA0BpC,IAAI,IAAI,IAAI;CAMpB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.CronLogArchiveStrategy = void 0;
|
|
10
|
+
const di_1 = require("@spinajs/di");
|
|
11
|
+
const exceptions_1 = require("@spinajs/exceptions");
|
|
12
|
+
const cron_1 = require("cron");
|
|
13
|
+
const archive_strategy_js_1 = require("../archive-strategy.js");
|
|
14
|
+
/**
|
|
15
|
+
* Rotates the active log file on a cron schedule taken from the `rotate`
|
|
16
|
+
* option ( 6-field with seconds supported, eg. '0 0 1 * * *' = 1am daily ).
|
|
17
|
+
* The expression is required - creation fails without it, like fs
|
|
18
|
+
* CronTempCleanupStrategy.
|
|
19
|
+
*/
|
|
20
|
+
let CronLogArchiveStrategy = class CronLogArchiveStrategy extends archive_strategy_js_1.LogArchiveStrategy {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
this.cronJob = null;
|
|
24
|
+
}
|
|
25
|
+
start(ctx) {
|
|
26
|
+
if (!ctx.options.rotate) {
|
|
27
|
+
throw new exceptions_1.InvalidOption(`Log target ${ctx.options.path} uses CronLogArchiveStrategy but 'rotate' cron expression is not set`);
|
|
28
|
+
}
|
|
29
|
+
this.stop();
|
|
30
|
+
// CronJob ctor throws on invalid expression - wrap for a clearer error
|
|
31
|
+
try {
|
|
32
|
+
this.cronJob = new cron_1.CronJob(ctx.options.rotate, () => {
|
|
33
|
+
void this.triggerRotation(ctx);
|
|
34
|
+
}, null, true);
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
throw new exceptions_1.InvalidOption(`Log target ${ctx.options.path} has invalid rotate cron expression '${ctx.options.rotate}': ${err.message}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
stop() {
|
|
41
|
+
if (this.cronJob) {
|
|
42
|
+
this.cronJob.stop();
|
|
43
|
+
this.cronJob = null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
exports.CronLogArchiveStrategy = CronLogArchiveStrategy;
|
|
48
|
+
exports.CronLogArchiveStrategy = CronLogArchiveStrategy = __decorate([
|
|
49
|
+
(0, di_1.Injectable)(archive_strategy_js_1.LogArchiveStrategy),
|
|
50
|
+
(0, di_1.NewInstance)()
|
|
51
|
+
], CronLogArchiveStrategy);
|
|
52
|
+
//# sourceMappingURL=CronLogArchiveStrategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CronLogArchiveStrategy.js","sourceRoot":"","sources":["../../../../src/archive/strategies/CronLogArchiveStrategy.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oCAAsD;AACtD,oDAAoD;AACpD,+BAA+B;AAC/B,gEAA4D;AAG5D;;;;;GAKG;AAGI,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,wCAAkB;IAAvD;;QACK,YAAO,GAAmB,IAAI,CAAC;IAkC3C,CAAC;IAhCQ,KAAK,CAAC,GAAuB;QAClC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACxB,MAAM,IAAI,0BAAa,CACrB,cAAc,GAAG,CAAC,OAAO,CAAC,IAAI,sEAAsE,CACrG,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,IAAI,EAAE,CAAC;QAEZ,uEAAuE;QACvE,IAAI,CAAC;YACH,IAAI,CAAC,OAAO,GAAG,IAAI,cAAO,CACxB,GAAG,CAAC,OAAO,CAAC,MAAM,EAClB,GAAG,EAAE;gBACH,KAAK,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;YACjC,CAAC,EACD,IAAI,EACJ,IAAI,CACL,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,IAAI,0BAAa,CACrB,cAAc,GAAG,CAAC,OAAO,CAAC,IAAI,wCAAwC,GAAG,CAAC,OAAO,CAAC,MAAM,MAAO,GAAa,CAAC,OAAO,EAAE,CACvH,CAAC;QACJ,CAAC;IACH,CAAC;IAEM,IAAI;QACT,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YACpB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACtB,CAAC;IACH,CAAC;CACF,CAAA;AAnCY,wDAAsB;iCAAtB,sBAAsB;IAFlC,IAAA,eAAU,EAAC,wCAAkB,CAAC;IAC9B,IAAA,gBAAW,GAAE;GACD,sBAAsB,CAmClC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LogArchiveStrategy } from "../archive-strategy.js";
|
|
2
|
+
import { ILogArchiveContext } from "../context.js";
|
|
3
|
+
/**
|
|
4
|
+
* Rotates the active log file when its size exceeds `maxSize`, checked every
|
|
5
|
+
* `archiveInterval` seconds ( both resolved from the logger.file config
|
|
6
|
+
* defaults, overridable per target ).
|
|
7
|
+
*/
|
|
8
|
+
export declare class SizeLogArchiveStrategy extends LogArchiveStrategy {
|
|
9
|
+
protected timer: NodeJS.Timeout | null;
|
|
10
|
+
start(ctx: ILogArchiveContext): void;
|
|
11
|
+
stop(): void;
|
|
12
|
+
/**
|
|
13
|
+
* Rotates only when the active file exists AND is over the size limit. A
|
|
14
|
+
* missing active file ( nothing written yet ) is not an error.
|
|
15
|
+
*/
|
|
16
|
+
protected check(ctx: ILogArchiveContext): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=SizeLogArchiveStrategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SizeLogArchiveStrategy.d.ts","sourceRoot":"","sources":["../../../../src/archive/strategies/SizeLogArchiveStrategy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD;;;;GAIG;AACH,qBAEa,sBAAuB,SAAQ,kBAAkB;IAC5D,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAQ;IAEvC,KAAK,CAAC,GAAG,EAAE,kBAAkB,GAAG,IAAI;IAWpC,IAAI,IAAI,IAAI;IAOnB;;;OAGG;cACa,KAAK,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;CAkB9D"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.SizeLogArchiveStrategy = void 0;
|
|
10
|
+
const di_1 = require("@spinajs/di");
|
|
11
|
+
const archive_strategy_js_1 = require("../archive-strategy.js");
|
|
12
|
+
/**
|
|
13
|
+
* Rotates the active log file when its size exceeds `maxSize`, checked every
|
|
14
|
+
* `archiveInterval` seconds ( both resolved from the logger.file config
|
|
15
|
+
* defaults, overridable per target ).
|
|
16
|
+
*/
|
|
17
|
+
let SizeLogArchiveStrategy = class SizeLogArchiveStrategy extends archive_strategy_js_1.LogArchiveStrategy {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.timer = null;
|
|
21
|
+
}
|
|
22
|
+
start(ctx) {
|
|
23
|
+
// never leak a previous timer on repeated start
|
|
24
|
+
this.stop();
|
|
25
|
+
const interval = ctx.options.archiveInterval * 1000;
|
|
26
|
+
this.timer = setInterval(() => {
|
|
27
|
+
void this.check(ctx);
|
|
28
|
+
}, interval);
|
|
29
|
+
}
|
|
30
|
+
stop() {
|
|
31
|
+
if (this.timer) {
|
|
32
|
+
clearInterval(this.timer);
|
|
33
|
+
this.timer = null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Rotates only when the active file exists AND is over the size limit. A
|
|
38
|
+
* missing active file ( nothing written yet ) is not an error.
|
|
39
|
+
*/
|
|
40
|
+
async check(ctx) {
|
|
41
|
+
try {
|
|
42
|
+
if (!(await ctx.fs.exists(ctx.activePath))) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const stat = await ctx.fs.stat(ctx.activePath);
|
|
46
|
+
const maxSize = ctx.options.maxSize;
|
|
47
|
+
const size = stat.Size ?? 0;
|
|
48
|
+
if (size > maxSize) {
|
|
49
|
+
this.Logger.trace(`Active log ${ctx.activePath} size ${size} exceeds ${maxSize}, rotating`);
|
|
50
|
+
await this.triggerRotation(ctx);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
this.Logger.warn(`Size check for log target ${ctx.activePath} failed: ${err.message}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
exports.SizeLogArchiveStrategy = SizeLogArchiveStrategy;
|
|
59
|
+
exports.SizeLogArchiveStrategy = SizeLogArchiveStrategy = __decorate([
|
|
60
|
+
(0, di_1.Injectable)(archive_strategy_js_1.LogArchiveStrategy),
|
|
61
|
+
(0, di_1.NewInstance)()
|
|
62
|
+
], SizeLogArchiveStrategy);
|
|
63
|
+
//# sourceMappingURL=SizeLogArchiveStrategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SizeLogArchiveStrategy.js","sourceRoot":"","sources":["../../../../src/archive/strategies/SizeLogArchiveStrategy.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oCAAsD;AACtD,gEAA4D;AAG5D;;;;GAIG;AAGI,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,wCAAkB;IAAvD;;QACK,UAAK,GAA0B,IAAI,CAAC;IA0ChD,CAAC;IAxCQ,KAAK,CAAC,GAAuB;QAClC,gDAAgD;QAChD,IAAI,CAAC,IAAI,EAAE,CAAC;QAEZ,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;QAEpD,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;YAC5B,KAAK,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC,EAAE,QAAQ,CAAC,CAAC;IACf,CAAC;IAEM,IAAI;QACT,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QACpB,CAAC;IACH,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,KAAK,CAAC,GAAuB;QAC3C,IAAI,CAAC;YACH,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;gBAC3C,OAAO;YACT,CAAC;YAED,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAC/C,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC;YAEpC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC;YAC5B,IAAI,IAAI,GAAG,OAAO,EAAE,CAAC;gBACnB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,GAAG,CAAC,UAAU,SAAS,IAAI,YAAY,OAAO,YAAY,CAAC,CAAC;gBAC5F,MAAM,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,6BAA6B,GAAG,CAAC,UAAU,YAAa,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;QACpG,CAAC;IACH,CAAC;CACF,CAAA;AA3CY,wDAAsB;iCAAtB,sBAAsB;IAFlC,IAAA,eAAU,EAAC,wCAAkB,CAAC;IAC9B,IAAA,gBAAW,GAAE;GACD,sBAAsB,CA2ClC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { IStat } from "@spinajs/fs";
|
|
2
|
+
import { ILogArchiveContext } from "../context.js";
|
|
3
|
+
/**
|
|
4
|
+
* Prefix every archived file name gets. Only files under `archiveDir` starting
|
|
5
|
+
* with this prefix are considered archives ( so the active log dir, when it is
|
|
6
|
+
* the same directory as the archive dir, is not touched ).
|
|
7
|
+
*/
|
|
8
|
+
export declare const ARCHIVE_PREFIX = "archived_";
|
|
9
|
+
export interface IArchiveEntry {
|
|
10
|
+
/**
|
|
11
|
+
* Path of the archive relative to `archiveFs` base path.
|
|
12
|
+
*/
|
|
13
|
+
path: string;
|
|
14
|
+
stat: IStat;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Joins archive dir + file name with forward slashes. fs providers resolve
|
|
18
|
+
* paths against their base path and normalize separators, so a posix join keeps
|
|
19
|
+
* behaviour identical across platforms.
|
|
20
|
+
*/
|
|
21
|
+
export declare function archivePath(ctx: ILogArchiveContext, name: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Lists archive files in `ctx.archiveDir` on `ctx.archiveFs`, sorted ascending
|
|
24
|
+
* by modification time ( oldest first, newest last ). Only files carrying the
|
|
25
|
+
* archive prefix are returned; directories and unrelated files are ignored.
|
|
26
|
+
*/
|
|
27
|
+
export declare function listArchives(ctx: ILogArchiveContext): Promise<IArchiveEntry[]>;
|
|
28
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../src/archive/strategies/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD;;;;GAIG;AACH,eAAO,MAAM,cAAc,cAAc,CAAC;AAE1C,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,KAAK,CAAC;CACb;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAmCpF"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ARCHIVE_PREFIX = void 0;
|
|
4
|
+
exports.archivePath = archivePath;
|
|
5
|
+
exports.listArchives = listArchives;
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
/**
|
|
8
|
+
* Prefix every archived file name gets. Only files under `archiveDir` starting
|
|
9
|
+
* with this prefix are considered archives ( so the active log dir, when it is
|
|
10
|
+
* the same directory as the archive dir, is not touched ).
|
|
11
|
+
*/
|
|
12
|
+
exports.ARCHIVE_PREFIX = "archived_";
|
|
13
|
+
/**
|
|
14
|
+
* Joins archive dir + file name with forward slashes. fs providers resolve
|
|
15
|
+
* paths against their base path and normalize separators, so a posix join keeps
|
|
16
|
+
* behaviour identical across platforms.
|
|
17
|
+
*/
|
|
18
|
+
function archivePath(ctx, name) {
|
|
19
|
+
return ctx.archiveDir ? path_1.posix.join(ctx.archiveDir, name) : name;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Lists archive files in `ctx.archiveDir` on `ctx.archiveFs`, sorted ascending
|
|
23
|
+
* by modification time ( oldest first, newest last ). Only files carrying the
|
|
24
|
+
* archive prefix are returned; directories and unrelated files are ignored.
|
|
25
|
+
*/
|
|
26
|
+
async function listArchives(ctx) {
|
|
27
|
+
let names;
|
|
28
|
+
try {
|
|
29
|
+
names = await ctx.archiveFs.list(ctx.archiveDir || "/");
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// archive dir may not exist yet ( nothing rotated )
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
const entries = [];
|
|
36
|
+
for (const name of names) {
|
|
37
|
+
if (!name.startsWith(exports.ARCHIVE_PREFIX)) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const p = archivePath(ctx, name);
|
|
41
|
+
try {
|
|
42
|
+
const stat = await ctx.archiveFs.stat(p);
|
|
43
|
+
if (stat.IsDirectory) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
entries.push({ path: p, stat });
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// stat can fail on a file removed concurrently - skip it
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
entries.sort((a, b) => {
|
|
53
|
+
const at = a.stat.ModifiedTime?.toMillis() ?? 0;
|
|
54
|
+
const bt = b.stat.ModifiedTime?.toMillis() ?? 0;
|
|
55
|
+
return at - bt;
|
|
56
|
+
});
|
|
57
|
+
return entries;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../../src/archive/strategies/util.ts"],"names":[],"mappings":";;;AAwBA,kCAEC;AAOD,oCAmCC;AAnED,+BAA6B;AAG7B;;;;GAIG;AACU,QAAA,cAAc,GAAG,WAAW,CAAC;AAU1C;;;;GAIG;AACH,SAAgB,WAAW,CAAC,GAAuB,EAAE,IAAY;IAC/D,OAAO,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,YAAK,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAClE,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,YAAY,CAAC,GAAuB;IACxD,IAAI,KAAe,CAAC;IACpB,IAAI,CAAC;QACH,KAAK,GAAG,MAAM,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,CAAC;IAC1D,CAAC;IAAC,MAAM,CAAC;QACP,oDAAoD;QACpD,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,OAAO,GAAoB,EAAE,CAAC;IAEpC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,sBAAc,CAAC,EAAE,CAAC;YACrC,SAAS;QACX,CAAC;QAED,MAAM,CAAC,GAAG,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACzC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBACrB,SAAS;YACX,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QAClC,CAAC;QAAC,MAAM,CAAC;YACP,yDAAyD;QAC3D,CAAC;IACH,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACpB,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;QAChD,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;QAChD,OAAO,EAAE,GAAG,EAAE,CAAC;IACjB,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/bootstrap.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,YAAY,EAAM,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/bootstrap.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,YAAY,EAAM,MAAM,aAAa,CAAC;AAkC3D,qBACa,cAAe,SAAQ,YAAY;IACvC,SAAS,IAAI,IAAI;CAmCzB"}
|
package/lib/cjs/bootstrap.js
CHANGED
|
@@ -13,6 +13,8 @@ exports.LogBotstrapper = void 0;
|
|
|
13
13
|
const configuration_1 = require("@spinajs/configuration");
|
|
14
14
|
const di_1 = require("@spinajs/di");
|
|
15
15
|
const log_common_1 = require("@spinajs/log-common");
|
|
16
|
+
const context_js_1 = require("./context.js");
|
|
17
|
+
const perf_js_1 = require("./perf.js");
|
|
16
18
|
const log_configuration_js_1 = __importDefault(require("./schemas/log.configuration.js"));
|
|
17
19
|
const uncaughtExceptionHandler = (err) => {
|
|
18
20
|
// if we have configuration resolved, we can assume that logger can read configuration
|
|
@@ -38,15 +40,36 @@ const unhandledRejection = (reason, p) => {
|
|
|
38
40
|
console.error("Unhandled rejection: \n reason: " + reason.message + " \n stack:" + reason.stack);
|
|
39
41
|
}
|
|
40
42
|
};
|
|
43
|
+
// Guard so a double bootstrap ( eg. re-run in the same process ) does not
|
|
44
|
+
// register the beforeExit drain twice.
|
|
45
|
+
let beforeExitAttached = false;
|
|
41
46
|
let LogBotstrapper = class LogBotstrapper extends di_1.Bootstrapper {
|
|
42
47
|
bootstrap() {
|
|
43
48
|
di_1.DI.register(log_configuration_js_1.default).asValue("__configurationSchema__");
|
|
49
|
+
// Best-effort teardown drain: on a CLEAN process exit, force-flush every
|
|
50
|
+
// logger's targets so buffered File / Loki / OTLP entries are written out.
|
|
51
|
+
// beforeExit does NOT run on hard exits ( process.exit / signals / crashes ),
|
|
52
|
+
// so this only catches clean drains. Node-only ( guard mirrors
|
|
53
|
+
// internal-logger ); do not double-register.
|
|
54
|
+
if (!beforeExitAttached && typeof process !== "undefined" && typeof process.on === "function") {
|
|
55
|
+
beforeExitAttached = true;
|
|
56
|
+
process.on("beforeExit", () => {
|
|
57
|
+
void log_common_1.Log.flushAll();
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
// Feed the ambient async-context store into every log entry ( merged at
|
|
61
|
+
// lowest precedence by createLogMessageObject ). LogContext resolves the
|
|
62
|
+
// same DI-singleton AsyncLocalStorage the http module runs per action, so
|
|
63
|
+
// logs inherit requestId / realIp / ... for free.
|
|
64
|
+
(0, log_common_1.setLogContextProvider)(() => (0, context_js_1.scalarContext)(context_js_1.LogContext.active()));
|
|
65
|
+
// Wire the per-request perf accumulator onto the same async store.
|
|
66
|
+
(0, perf_js_1.wirePerfScope)();
|
|
44
67
|
// check if we run tests,
|
|
45
68
|
// hook for uncaughtException causes to not showing
|
|
46
69
|
// mocha errors in console
|
|
47
70
|
if (!process.env.TESTING) {
|
|
48
71
|
process.removeListener("uncaughtException", uncaughtExceptionHandler);
|
|
49
|
-
process.removeListener("unhandledRejection",
|
|
72
|
+
process.removeListener("unhandledRejection", unhandledRejection);
|
|
50
73
|
process.on("uncaughtException", uncaughtExceptionHandler);
|
|
51
74
|
process.on("unhandledRejection", unhandledRejection);
|
|
52
75
|
}
|
package/lib/cjs/bootstrap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/bootstrap.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0DAAuD;AACvD,oCAA2D;AAC3D,
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/bootstrap.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0DAAuD;AACvD,oCAA2D;AAC3D,oDAAiE;AACjE,6CAAyD;AACzD,uCAA0C;AAC1C,0FAAkE;AAElE,MAAM,wBAAwB,GAAG,CAAC,GAAU,EAAE,EAAE;IAC9C,sFAAsF;IACtF,wBAAwB;IACxB,wBAAwB;IACxB,IAAI,OAAE,CAAC,GAAG,CAAC,6BAAa,CAAC,EAAE,CAAC;QAC1B,MAAM,GAAG,GAAG,OAAE,CAAC,OAAO,CAAC,gBAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;QACzC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,6BAA6B,CAAC,CAAC;IAChD,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,kCAAkC,GAAG,GAAG,CAAC,OAAO,GAAG,YAAY,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC;IAC7F,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,MAAa,EAAE,CAAmB,EAAE,EAAE;IAChE,sFAAsF;IACtF,wBAAwB;IACxB,wBAAwB;IACxB,IAAI,OAAE,CAAC,GAAG,CAAC,6BAAa,CAAC,EAAE,CAAC;QAC1B,MAAM,GAAG,GAAG,OAAE,CAAC,OAAO,CAAC,gBAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;QACzC,GAAG,CAAC,KAAK,CAAC,MAAe,EAAE,mCAAmC,EAAE,CAAC,CAAC,CAAC;IACrE,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,kCAAkC,GAAG,MAAM,CAAC,OAAO,GAAG,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACnG,CAAC;AACH,CAAC,CAAC;AAEF,0EAA0E;AAC1E,uCAAuC;AACvC,IAAI,kBAAkB,GAAG,KAAK,CAAC;AAGxB,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,iBAAY;IACvC,SAAS;QACd,OAAE,CAAC,QAAQ,CAAC,8BAAoB,CAAC,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;QAErE,yEAAyE;QACzE,2EAA2E;QAC3E,8EAA8E;QAC9E,+DAA+D;QAC/D,6CAA6C;QAC7C,IAAI,CAAC,kBAAkB,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,OAAO,CAAC,EAAE,KAAK,UAAU,EAAE,CAAC;YAC9F,kBAAkB,GAAG,IAAI,CAAC;YAC1B,OAAO,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,EAAE;gBAC5B,KAAK,gBAAG,CAAC,QAAQ,EAAE,CAAC;YACtB,CAAC,CAAC,CAAC;QACL,CAAC;QAED,wEAAwE;QACxE,yEAAyE;QACzE,0EAA0E;QAC1E,kDAAkD;QAClD,IAAA,kCAAqB,EAAC,GAAG,EAAE,CAAC,IAAA,0BAAa,EAAC,uBAAU,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAEhE,mEAAmE;QACnE,IAAA,uBAAa,GAAE,CAAC;QAEhB,yBAAyB;QACzB,mDAAmD;QACnD,0BAA0B;QAC1B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;YACzB,OAAO,CAAC,cAAc,CAAC,mBAAmB,EAAE,wBAAwB,CAAC,CAAC;YACtE,OAAO,CAAC,cAAc,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,CAAC;YAEjE,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,wBAAwB,CAAC,CAAC;YAC1D,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;CACF,CAAA;AApCY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,eAAU,EAAC,iBAAY,CAAC;GACZ,cAAc,CAoC1B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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 declare function captureCallsite(): string;
|
|
26
|
+
//# sourceMappingURL=callsite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callsite.d.ts","sourceRoot":"","sources":["../../src/callsite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAmCxC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Best-effort caller-frame capture for the `${callsite}` layout variable.
|
|
4
|
+
*
|
|
5
|
+
* NLog gates stack-trace capture behind `StackTraceUsage` so that logging is
|
|
6
|
+
* zero-cost unless a target's layout actually references the caller. This
|
|
7
|
+
* mirrors that: {@link FrameworkLogger} only calls {@link captureCallsite}
|
|
8
|
+
* when some target's layout references `${callsite}`, so the `new Error()`
|
|
9
|
+
* ( the only cost here ) is never constructed otherwise.
|
|
10
|
+
*
|
|
11
|
+
* The parser is intentionally defensive - it must NEVER throw. Browser stack
|
|
12
|
+
* formats vary and V8's format is not guaranteed, so an unparseable stack just
|
|
13
|
+
* yields `""` rather than crashing a log call.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.captureCallsite = captureCallsite;
|
|
17
|
+
/**
|
|
18
|
+
* Walk the current stack and return the first frame OUTSIDE the log package -
|
|
19
|
+
* i.e. the user's call site - as `"basename:line"` ( e.g. `service.ts:42` ).
|
|
20
|
+
*
|
|
21
|
+
* Internal frames belonging to the logger itself ( `log.ts`, `callsite.ts`,
|
|
22
|
+
* the `log-common` package, `wrapWrite`, `createLogMessageObject` ) are skipped
|
|
23
|
+
* so the returned frame is the caller of `log.info(...)` / `log.error(...)`.
|
|
24
|
+
*
|
|
25
|
+
* Returns `""` when no frame can be parsed ( no stack, or an unrecognized
|
|
26
|
+
* stack format ). Best-effort by design.
|
|
27
|
+
*/
|
|
28
|
+
function captureCallsite() {
|
|
29
|
+
const stack = new Error().stack;
|
|
30
|
+
if (!stack) {
|
|
31
|
+
return "";
|
|
32
|
+
}
|
|
33
|
+
const lines = stack.split("\n");
|
|
34
|
+
for (const line of lines) {
|
|
35
|
+
// only real stack frames ( " at ..." ) - skip the leading "Error" line
|
|
36
|
+
// and any non-frame text.
|
|
37
|
+
if (!/\bat\b/.test(line)) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
// skip frames that live inside the logger's own code:
|
|
41
|
+
// - files log.ts / callsite.ts ( source ) or log.js / callsite.js ( built )
|
|
42
|
+
// - anything under a `log` or `log-common` package's src/ or lib/ tree
|
|
43
|
+
// - the internal helpers wrapWrite / createLogMessageObject
|
|
44
|
+
if (/[\\/]log(-common)?[\\/](src|lib)[\\/]|[\\/](log|callsite)\.(ts|js|mjs|cjs)\b|\bwrapWrite\b|\bcreateLogMessageObject\b|\bcaptureCallsite\b/.test(line)) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
// extract "path:line" from either:
|
|
48
|
+
// " at fn (path:line:col)" ( named frame )
|
|
49
|
+
// " at path:line:col" ( anonymous frame )
|
|
50
|
+
const m = line.match(/\(?([^()]+):(\d+):(\d+)\)?\s*$/);
|
|
51
|
+
if (m) {
|
|
52
|
+
// basename only - keeps rendered log lines short and stable across
|
|
53
|
+
// machines ( full absolute paths differ per checkout ).
|
|
54
|
+
const file = m[1].split(/[\\/]/).pop() ?? m[1];
|
|
55
|
+
return `${file}:${m[2]}`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return "";
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=callsite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callsite.js","sourceRoot":"","sources":["../../src/callsite.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AAaH,0CAmCC;AA9CD;;;;;;;;;;GAUG;AACH,SAAgB,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"}
|