@trebired/logger 0.1.1 → 1.1.3
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/CHANGELOG.md +17 -1
- package/README.md +51 -12
- package/dist/constants.d.ts +2 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +4 -1
- package/dist/constants.js.map +1 -1
- package/dist/core/create_log.d.ts.map +1 -1
- package/dist/core/create_log.js +28 -30
- package/dist/core/create_log.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/storage/names.d.ts +5 -2
- package/dist/storage/names.d.ts.map +1 -1
- package/dist/storage/names.js +13 -5
- package/dist/storage/names.js.map +1 -1
- package/dist/storage/options.d.ts.map +1 -1
- package/dist/storage/options.js +3 -1
- package/dist/storage/options.js.map +1 -1
- package/dist/storage/query.d.ts +8 -3
- package/dist/storage/query.d.ts.map +1 -1
- package/dist/storage/query.js +156 -28
- package/dist/storage/query.js.map +1 -1
- package/dist/storage/retention.d.ts.map +1 -1
- package/dist/storage/retention.js +54 -2
- package/dist/storage/retention.js.map +1 -1
- package/dist/storage/walk.d.ts.map +1 -1
- package/dist/storage/walk.js +82 -9
- package/dist/storage/walk.js.map +1 -1
- package/dist/storage/write.d.ts +2 -0
- package/dist/storage/write.d.ts.map +1 -1
- package/dist/storage/write.js +15 -2
- package/dist/storage/write.js.map +1 -1
- package/dist/types.d.ts +47 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,22 @@ All notable changes to `@trebired/logger` will be documented here.
|
|
|
4
4
|
|
|
5
5
|
This project follows semantic versioning once published.
|
|
6
6
|
|
|
7
|
+
## 1.1.3
|
|
8
|
+
|
|
9
|
+
- Added optional `partition` storage folders so one logger dir can keep separate deployments, sessions, environments, or other caller-defined log trees.
|
|
10
|
+
- Added `maxPartitions` retention cleanup and changed retention defaults so logs are kept forever unless a deletion number is configured.
|
|
11
|
+
- Added `metadata.total` and `metadata.partitions` summaries to saved-log query results.
|
|
12
|
+
- Replaced the old query API names with `getAllLogs()`, `getAllLogsAcrossPartitions()`, and `getLogsForDir()`.
|
|
13
|
+
- Removed support for `getAll()` and `getEntriesForDir()`.
|
|
14
|
+
|
|
15
|
+
## 1.1.2
|
|
16
|
+
|
|
17
|
+
- Changed saved-log query helpers to return `{ logs, levels, metadata }` instead of a bare log array.
|
|
18
|
+
- Added top-level level configuration metadata to query results, including custom logger levels.
|
|
19
|
+
- Added a continuous dummy logger demo that writes to the OS temp directory and exits cleanly on interrupt.
|
|
20
|
+
- Documented that the demo supports Linux and macOS; microslop Windows is not supported.
|
|
21
|
+
- Removed configurable `defaultGroup`; the implicit group is now always hardcoded to `"default"`.
|
|
22
|
+
|
|
7
23
|
## 0.1.0
|
|
8
24
|
|
|
9
25
|
- Added top-level `timeZone` support for saved filenames and console timestamps.
|
|
@@ -17,4 +33,4 @@ This project follows semantic versioning once published.
|
|
|
17
33
|
- Added async queued file writing with `flush()`, `close()`, and `getStats()`.
|
|
18
34
|
- Added group-based JSONL storage with ISO-style filenames.
|
|
19
35
|
- Added retention cleanup, max-size rolling, optional gzip compression, redaction, serializers, sampling, request middleware, stream events, and query helpers.
|
|
20
|
-
- Initial public release.
|
|
36
|
+
- Initial public release.
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Structured backend logging for Bun and Node.js applications that want readable console output and durable local logs without running a separate logging stack.
|
|
4
4
|
|
|
5
|
-
`@trebired/logger` writes JSONL logs into group-based folders, supports custom weighted levels,
|
|
5
|
+
`@trebired/logger` writes JSONL logs into group-based folders, supports optional partitioned storage, custom weighted levels, queued file writes, redaction, rolling files, request-scoped loggers, and local query helpers.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -31,6 +31,7 @@ Most loggers either write to stdout and expect an external collector, or provide
|
|
|
31
31
|
|
|
32
32
|
- structured JSONL entries
|
|
33
33
|
- one directory tree per log group
|
|
34
|
+
- optional partition folders above group trees
|
|
34
35
|
- async queued file writes by default
|
|
35
36
|
- custom weighted log levels
|
|
36
37
|
- local querying by group, level, day, and hour
|
|
@@ -55,6 +56,16 @@ Each line is a JSON object:
|
|
|
55
56
|
{"recorded_at":"2026-05-03T13:00:00.000Z","level":"info","group":"app.start","message":"ready","origin":{"source":"app","instance":null},"metadata":{"port":3000}}
|
|
56
57
|
```
|
|
57
58
|
|
|
59
|
+
If you want an extra top-level separation layer, set `partition` and the logger writes one more folder layer. This is useful for deployments, releases, environments, sessions, tenants, workers, import batches, or any other caller-defined bucket:
|
|
60
|
+
|
|
61
|
+
```txt
|
|
62
|
+
/var/log/my-app/
|
|
63
|
+
blue-2026-05-16/
|
|
64
|
+
app/
|
|
65
|
+
start/
|
|
66
|
+
2026-05-03-13-0000-info.jsonl
|
|
67
|
+
```
|
|
68
|
+
|
|
58
69
|
## Core API
|
|
59
70
|
|
|
60
71
|
```ts
|
|
@@ -64,7 +75,6 @@ const log = createLog({
|
|
|
64
75
|
console: true,
|
|
65
76
|
timeZone: "America/New_York",
|
|
66
77
|
source: "api",
|
|
67
|
-
defaultGroup: "default",
|
|
68
78
|
});
|
|
69
79
|
|
|
70
80
|
log.debug("app.boot", "config loaded");
|
|
@@ -77,7 +87,7 @@ log.error("app.runtime", "uncaught error");
|
|
|
77
87
|
|
|
78
88
|
`save` defaults to `true` when `dir` is provided. If no `dir` is provided, the logger can still emit console output and live stream events.
|
|
79
89
|
|
|
80
|
-
|
|
90
|
+
If you log without passing a group, the logger always uses `"default"`.
|
|
81
91
|
|
|
82
92
|
`@trebired/logger` runs on both Bun and Node.js. It may print one-time package notices for runtime-specific guidance or important future package messages. For example, when it detects Node.js, it recommends Bun for best startup and file I/O performance. Pass `quiet: true` to suppress package notices:
|
|
83
93
|
|
|
@@ -117,6 +127,7 @@ import { createLog } from "@trebired/logger";
|
|
|
117
127
|
|
|
118
128
|
const log = createLog({
|
|
119
129
|
dir: "/var/log/my-app",
|
|
130
|
+
partition: "blue-2026-05-16",
|
|
120
131
|
save: true,
|
|
121
132
|
console: {
|
|
122
133
|
enabled: true,
|
|
@@ -129,7 +140,6 @@ const log = createLog({
|
|
|
129
140
|
quiet: true,
|
|
130
141
|
timeZone: "America/New_York",
|
|
131
142
|
source: "api",
|
|
132
|
-
defaultGroup: "default",
|
|
133
143
|
levels: {
|
|
134
144
|
debug: { weight: 10, label: "DEBUG", color: "#94a3b8" },
|
|
135
145
|
info: { weight: 20, label: "INFO", color: "#38bdf8" },
|
|
@@ -148,10 +158,12 @@ const log = createLog({
|
|
|
148
158
|
},
|
|
149
159
|
retention: {
|
|
150
160
|
enabled: true,
|
|
151
|
-
maxAgeDays: 7,
|
|
152
161
|
maxFileSize: "20mb",
|
|
153
162
|
compressOldFiles: false,
|
|
154
163
|
cleanupIntervalMs: 60_000,
|
|
164
|
+
// deletion is opt-in:
|
|
165
|
+
maxAgeDays: 30,
|
|
166
|
+
maxPartitions: 5,
|
|
155
167
|
},
|
|
156
168
|
redact: {
|
|
157
169
|
includeDefaultSensitiveKeys: true,
|
|
@@ -242,8 +254,7 @@ const log = createLog({
|
|
|
242
254
|
|
|
243
255
|
Defaults:
|
|
244
256
|
|
|
245
|
-
- retention
|
|
246
|
-
- `maxAgeDays: 7`
|
|
257
|
+
- logs are kept forever unless you set a retention number
|
|
247
258
|
- `maxFileSize: "20mb"`
|
|
248
259
|
- `compressOldFiles: false`
|
|
249
260
|
|
|
@@ -251,7 +262,9 @@ Defaults:
|
|
|
251
262
|
const log = createLog({
|
|
252
263
|
dir: "/var/log/my-app",
|
|
253
264
|
retention: {
|
|
265
|
+
// only delete when you set one or both of these:
|
|
254
266
|
maxAgeDays: 30,
|
|
267
|
+
maxPartitions: 5,
|
|
255
268
|
maxFileSize: "100mb",
|
|
256
269
|
compressOldFiles: true,
|
|
257
270
|
cleanupIntervalMs: 60 * 60 * 1000,
|
|
@@ -259,6 +272,8 @@ const log = createLog({
|
|
|
259
272
|
});
|
|
260
273
|
```
|
|
261
274
|
|
|
275
|
+
`maxAgeDays` deletes old files by age. `maxPartitions` keeps only the newest partition folders by last write time. A partition can represent deployments, sessions, environments, release versions, or any other caller-defined grouping. If you omit both, the logger stores logs indefinitely.
|
|
276
|
+
|
|
262
277
|
When a file exceeds the configured size, the logger rolls to the next sequence inside the same group and hour:
|
|
263
278
|
|
|
264
279
|
```txt
|
|
@@ -317,20 +332,42 @@ app.get("/", (req, res) => {
|
|
|
317
332
|
|
|
318
333
|
## Query Saved Logs
|
|
319
334
|
|
|
335
|
+
Old query names are not supported anymore. Use `getLogsForDir()`, `getAllLogs()`, and `getAllLogsAcrossPartitions()`. Do not use `getEntriesForDir()` or `getAll()`.
|
|
336
|
+
|
|
320
337
|
```ts
|
|
321
|
-
import {
|
|
338
|
+
import { getLogsForDir } from "@trebired/logger";
|
|
322
339
|
|
|
323
|
-
const
|
|
340
|
+
const result = await getLogsForDir("/var/log/my-app", {
|
|
324
341
|
level: "error",
|
|
325
342
|
groupKey: "app.runtime",
|
|
326
343
|
limit: 100,
|
|
327
344
|
});
|
|
345
|
+
|
|
346
|
+
console.log(result.logs);
|
|
347
|
+
console.log(result.levels.error.color);
|
|
348
|
+
console.log(result.metadata.count);
|
|
349
|
+
console.log(result.metadata.total);
|
|
328
350
|
```
|
|
329
351
|
|
|
330
|
-
|
|
352
|
+
The main instance query method is `getAllLogs()`:
|
|
331
353
|
|
|
332
354
|
```ts
|
|
333
|
-
const recent = await log.
|
|
355
|
+
const recent = await log.getAllLogs({ groupKey: "billing.invoice", limit: 50 });
|
|
356
|
+
console.log(recent.logs);
|
|
357
|
+
console.log(recent.levels);
|
|
358
|
+
console.log(recent.metadata.total);
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
If you use partition folders and want a merged read across every partition:
|
|
362
|
+
|
|
363
|
+
```ts
|
|
364
|
+
const merged = await log.getAllLogsAcrossPartitions({
|
|
365
|
+
groupKey: "billing.invoice",
|
|
366
|
+
limit: 100,
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
console.log(merged.logs);
|
|
370
|
+
console.log(merged.metadata.partitions.items);
|
|
334
371
|
```
|
|
335
372
|
|
|
336
373
|
## Sampling
|
|
@@ -359,10 +396,12 @@ logStream.on("log", (entry, context) => {
|
|
|
359
396
|
|
|
360
397
|
```sh
|
|
361
398
|
bun install
|
|
399
|
+
bun run demo
|
|
362
400
|
bun test
|
|
363
401
|
bun run typecheck
|
|
364
402
|
bun run build
|
|
365
|
-
bun run bench
|
|
366
403
|
```
|
|
367
404
|
|
|
405
|
+
`bun run demo` starts a small dummy system that keeps logging until interrupted. It exercises grouped and scoped loggers, custom levels, redaction, request middleware, live stream events, local querying, and write stats. It writes throwaway logs under the OS temp directory, such as `/tmp/@trebired-logger/dummy` on Linux and macOS. Microslop Windows is not supported.
|
|
406
|
+
|
|
368
407
|
The npm package exports compiled files from `dist`. Publishing runs `typecheck`, tests, and `build` through `prepublishOnly`.
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { LogLevelConfig } from "./types.js";
|
|
2
2
|
declare const TOP_LEVEL = "top-level";
|
|
3
|
+
declare const PARTITION_MARKER_FILE = ".trebired-partition.json";
|
|
3
4
|
declare const DEFAULT_LEVELS: Record<string, LogLevelConfig>;
|
|
4
5
|
declare const RESERVED_METADATA_KEYS: Set<string>;
|
|
5
6
|
declare const DEFAULT_SENSITIVE_KEYS: Set<string>;
|
|
6
|
-
export { DEFAULT_LEVELS, DEFAULT_SENSITIVE_KEYS, RESERVED_METADATA_KEYS, TOP_LEVEL };
|
|
7
|
+
export { DEFAULT_LEVELS, DEFAULT_SENSITIVE_KEYS, PARTITION_MARKER_FILE, RESERVED_METADATA_KEYS, TOP_LEVEL };
|
|
7
8
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,QAAA,MAAM,SAAS,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,QAAA,MAAM,SAAS,cAAc,CAAC;AAC9B,QAAA,MAAM,qBAAqB,6BAA6B,CAAC;AAEzD,QAAA,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAOjD,CAAC;AAEH,QAAA,MAAM,sBAAsB,aAuB1B,CAAC;AAEH,QAAA,MAAM,sBAAsB,aAY1B,CAAC;AAEH,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const TOP_LEVEL = "top-level";
|
|
2
|
+
const PARTITION_MARKER_FILE = ".trebired-partition.json";
|
|
2
3
|
const DEFAULT_LEVELS = Object.freeze({
|
|
3
4
|
debug: { weight: 10, label: "DEBUG", color: "#b7c063", stream: "stdout", showStack: false, bold: false },
|
|
4
5
|
info: { weight: 20, label: "INFO", color: "#2958ea", stream: "stdout", showStack: false, bold: false },
|
|
@@ -12,6 +13,8 @@ const RESERVED_METADATA_KEYS = new Set([
|
|
|
12
13
|
"configKey",
|
|
13
14
|
"config_key",
|
|
14
15
|
"deployment_type",
|
|
16
|
+
"deployment",
|
|
17
|
+
"partition",
|
|
15
18
|
"group",
|
|
16
19
|
"groupKey",
|
|
17
20
|
"group_label",
|
|
@@ -42,5 +45,5 @@ const DEFAULT_SENSITIVE_KEYS = new Set([
|
|
|
42
45
|
"token",
|
|
43
46
|
"access_token",
|
|
44
47
|
]);
|
|
45
|
-
export { DEFAULT_LEVELS, DEFAULT_SENSITIVE_KEYS, RESERVED_METADATA_KEYS, TOP_LEVEL };
|
|
48
|
+
export { DEFAULT_LEVELS, DEFAULT_SENSITIVE_KEYS, PARTITION_MARKER_FILE, RESERVED_METADATA_KEYS, TOP_LEVEL };
|
|
46
49
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,MAAM,SAAS,GAAG,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,MAAM,SAAS,GAAG,WAAW,CAAC;AAC9B,MAAM,qBAAqB,GAAG,0BAA0B,CAAC;AAEzD,MAAM,cAAc,GAAmC,MAAM,CAAC,MAAM,CAAC;IACnE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;IACxG,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;IACtG,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;IAC5G,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE;IACrG,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;IACtG,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE;CACvG,CAAC,CAAC;AAEH,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC;IACrC,eAAe;IACf,WAAW;IACX,YAAY;IACZ,iBAAiB;IACjB,YAAY;IACZ,WAAW;IACX,OAAO;IACP,UAAU;IACV,aAAa;IACb,YAAY;IACZ,KAAK;IACL,eAAe;IACf,SAAS;IACT,UAAU;IACV,MAAM;IACN,aAAa;IACb,YAAY;IACZ,aAAa;IACb,QAAQ;IACR,WAAW;IACX,UAAU;IACV,WAAW;CACZ,CAAC,CAAC;AAEH,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC;IACrC,SAAS;IACT,QAAQ;IACR,eAAe;IACf,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,KAAK;IACL,eAAe;IACf,QAAQ;IACR,OAAO;IACP,cAAc;CACf,CAAC,CAAC;AAEH,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create_log.d.ts","sourceRoot":"","sources":["../../src/core/create_log.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create_log.d.ts","sourceRoot":"","sources":["../../src/core/create_log.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,gBAAgB,EAAY,WAAW,EAAa,MAAM,aAAa,CAAC;AAmDtF,iBAAS,SAAS,CAAC,OAAO,GAAE,gBAAqB,GAAG,WAAW,CAuJ9D;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/core/create_log.js
CHANGED
|
@@ -5,13 +5,15 @@ import { minLevelWeight, normalizeLevel, normalizeLevels } from "../levels/index
|
|
|
5
5
|
import { prepareMetadata } from "../metadata/process.js";
|
|
6
6
|
import { buildRequestMiddleware } from "../middleware/request.js";
|
|
7
7
|
import { logStream } from "../stream/index.js";
|
|
8
|
-
import {
|
|
8
|
+
import { normalizePartitionKey } from "../storage/names.js";
|
|
9
|
+
import { getLogsForDir } from "../storage/query.js";
|
|
9
10
|
import { normalizeRetentionOptions, normalizeWriteOptions } from "../storage/options.js";
|
|
10
11
|
import { FileWriter } from "../storage/write.js";
|
|
11
12
|
import { normalizeTimeZone } from "../utils/datetime.js";
|
|
12
13
|
import { maybeShowNodeRuntimeNotice } from "../utils/runtime.js";
|
|
13
14
|
import { asObject, toString } from "../utils/values.js";
|
|
14
15
|
let packageGreetingShown = false;
|
|
16
|
+
const DEFAULT_GROUP = "default";
|
|
15
17
|
function safeResolveDir(value) {
|
|
16
18
|
const raw = toString(value);
|
|
17
19
|
return raw ? path.resolve(raw) : "";
|
|
@@ -55,25 +57,6 @@ function shouldKeepSample(entry, sample) {
|
|
|
55
57
|
}
|
|
56
58
|
return true;
|
|
57
59
|
}
|
|
58
|
-
function maybeShowPackageGreeting(quiet, consoleOptions, timeZone) {
|
|
59
|
-
if (quiet === true || packageGreetingShown)
|
|
60
|
-
return;
|
|
61
|
-
packageGreetingShown = true;
|
|
62
|
-
const entry = {
|
|
63
|
-
recorded_at: new Date().toISOString(),
|
|
64
|
-
level: "success",
|
|
65
|
-
group: "logger.loader",
|
|
66
|
-
message: "@trebired/logger initialized",
|
|
67
|
-
origin: buildOrigin("@trebired/logger"),
|
|
68
|
-
};
|
|
69
|
-
const levelConfig = {
|
|
70
|
-
weight: 25,
|
|
71
|
-
label: "SUCCESS",
|
|
72
|
-
color: "#22c55e",
|
|
73
|
-
bold: true,
|
|
74
|
-
};
|
|
75
|
-
writeConsole("stdout", formatConsole(entry, levelConfig, { ...consoleOptions, enabled: true }, timeZone));
|
|
76
|
-
}
|
|
77
60
|
function createLog(options = {}) {
|
|
78
61
|
const cfg = options && typeof options === "object" ? options : {};
|
|
79
62
|
maybeShowNodeRuntimeNotice(cfg.quiet);
|
|
@@ -81,13 +64,13 @@ function createLog(options = {}) {
|
|
|
81
64
|
const threshold = minLevelWeight(cfg.minLevel, levels);
|
|
82
65
|
const consoleOptions = normalizeConsoleOptions(cfg.console);
|
|
83
66
|
const timeZone = normalizeTimeZone(cfg.timeZone);
|
|
84
|
-
maybeShowPackageGreeting(cfg.quiet, consoleOptions, timeZone);
|
|
85
67
|
const defaultSource = toString(cfg.source) || "app";
|
|
86
|
-
const
|
|
68
|
+
const partition = normalizePartitionKey(cfg.partition);
|
|
87
69
|
let loggingEnabled = true;
|
|
88
70
|
let closed = false;
|
|
89
71
|
const writer = new FileWriter({
|
|
90
72
|
dir: safeResolveDir(cfg.dir),
|
|
73
|
+
partition,
|
|
91
74
|
save: typeof cfg.save === "boolean" ? cfg.save : Boolean(toString(cfg.dir)),
|
|
92
75
|
write: normalizeWriteOptions(cfg.write),
|
|
93
76
|
retention: normalizeRetentionOptions(cfg.retention),
|
|
@@ -104,7 +87,7 @@ function createLog(options = {}) {
|
|
|
104
87
|
const rawMetadata = asObject(metadataInput);
|
|
105
88
|
const recordedAt = toString(rawMetadata.__recorded_at) || new Date().toISOString();
|
|
106
89
|
const metadata = prepareMetadata(rawMetadata, cfg.serializers, cfg.redact);
|
|
107
|
-
const group = normGroup(groupInput ||
|
|
90
|
+
const group = normGroup(groupInput || DEFAULT_GROUP).key;
|
|
108
91
|
const message = typeof messageInput === "string" ? messageInput : String(messageInput ?? "");
|
|
109
92
|
const originSource = originInput && originInput.source ? originInput.source : defaultSource;
|
|
110
93
|
const originInstance = originInput && Object.prototype.hasOwnProperty.call(originInput, "instance") ? originInput.instance : null;
|
|
@@ -114,6 +97,7 @@ function createLog(options = {}) {
|
|
|
114
97
|
group,
|
|
115
98
|
message,
|
|
116
99
|
origin: buildOrigin(originSource, originInstance),
|
|
100
|
+
partition: partition || null,
|
|
117
101
|
};
|
|
118
102
|
if (Object.keys(metadata).length)
|
|
119
103
|
entry.metadata = metadata;
|
|
@@ -129,12 +113,12 @@ function createLog(options = {}) {
|
|
|
129
113
|
}
|
|
130
114
|
function logWith(level) {
|
|
131
115
|
return function levelLogger() {
|
|
132
|
-
const parsed = parseCallArguments(arguments,
|
|
116
|
+
const parsed = parseCallArguments(arguments, DEFAULT_GROUP);
|
|
133
117
|
emit(level, parsed.group, parsed.message, parsed.metadata);
|
|
134
118
|
};
|
|
135
119
|
}
|
|
136
120
|
function bindGroup(groupName, originInput) {
|
|
137
|
-
const boundGroup = normGroup(groupName ||
|
|
121
|
+
const boundGroup = normGroup(groupName || DEFAULT_GROUP).key;
|
|
138
122
|
const grouped = {};
|
|
139
123
|
for (const level of Object.keys(levels)) {
|
|
140
124
|
grouped[level] = (message, metadata) => emit(level, boundGroup, message, metadata, originInput);
|
|
@@ -151,14 +135,14 @@ function createLog(options = {}) {
|
|
|
151
135
|
}
|
|
152
136
|
const api = {
|
|
153
137
|
group(groupName) {
|
|
154
|
-
return bindGroup(groupName ||
|
|
138
|
+
return bindGroup(groupName || DEFAULT_GROUP);
|
|
155
139
|
},
|
|
156
140
|
withScope(source, groupName, instance) {
|
|
157
141
|
const originInput = {
|
|
158
142
|
source: toString(source) || defaultSource,
|
|
159
143
|
instance: instance == null ? null : String(instance),
|
|
160
144
|
};
|
|
161
|
-
return bindGroup(groupName ||
|
|
145
|
+
return bindGroup(groupName || DEFAULT_GROUP, originInput);
|
|
162
146
|
},
|
|
163
147
|
setEnabled(flag) {
|
|
164
148
|
loggingEnabled = Boolean(flag);
|
|
@@ -172,7 +156,7 @@ function createLog(options = {}) {
|
|
|
172
156
|
requestLogger: buildRequestMiddleware(null, cfg.request),
|
|
173
157
|
logError(error, metadata, source) {
|
|
174
158
|
const meta = asObject(metadata);
|
|
175
|
-
const groupName = toString(meta.group) ||
|
|
159
|
+
const groupName = toString(meta.group) || DEFAULT_GROUP;
|
|
176
160
|
const originSource = toString(source) || defaultSource;
|
|
177
161
|
if (error instanceof Error) {
|
|
178
162
|
emit("error", groupName, error.message, { ...meta, stack: error.stack }, { source: originSource });
|
|
@@ -180,9 +164,19 @@ function createLog(options = {}) {
|
|
|
180
164
|
}
|
|
181
165
|
emit("error", groupName, String(error), meta, { source: originSource });
|
|
182
166
|
},
|
|
183
|
-
async
|
|
167
|
+
async getAllLogs(options) {
|
|
184
168
|
await writer.flush();
|
|
185
|
-
return
|
|
169
|
+
return getLogsForDir(writer.getDir(), {
|
|
170
|
+
...(options || {}),
|
|
171
|
+
partition: Object.prototype.hasOwnProperty.call(options || {}, "partition")
|
|
172
|
+
? options?.partition
|
|
173
|
+
: partition || undefined,
|
|
174
|
+
levels,
|
|
175
|
+
});
|
|
176
|
+
},
|
|
177
|
+
async getAllLogsAcrossPartitions(options) {
|
|
178
|
+
await writer.flush();
|
|
179
|
+
return getLogsForDir(writer.getDir(), { ...(options || {}), acrossPartitions: true, levels });
|
|
186
180
|
},
|
|
187
181
|
flush() {
|
|
188
182
|
return writer.flush();
|
|
@@ -200,6 +194,10 @@ function createLog(options = {}) {
|
|
|
200
194
|
api.requestLogger = buildRequestMiddleware(api, cfg.request);
|
|
201
195
|
for (const level of Object.keys(levels))
|
|
202
196
|
api[level] = logWith(level);
|
|
197
|
+
if (cfg.quiet !== true && !packageGreetingShown) {
|
|
198
|
+
packageGreetingShown = true;
|
|
199
|
+
api.success("logger.loader", "@trebired/logger initialized");
|
|
200
|
+
}
|
|
203
201
|
return api;
|
|
204
202
|
}
|
|
205
203
|
export { createLog };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create_log.js","sourceRoot":"","sources":["../../src/core/create_log.ts"],"names":[],"m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QAC3B,CAAC;KACF,CAAC;IAEF,GAAG,CAAC,aAAa,GAAG,sBAAsB,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAE7D,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,GAAG,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAErE,IAAI,GAAG,CAAC,KAAK,KAAK,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAChD,oBAAoB,GAAG,IAAI,CAAC;QAC5B,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,8BAA8B,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { TOP_LEVEL, DEFAULT_LEVELS as defaultLevels } from "./constants.js";
|
|
2
2
|
export { createLog } from "./core/create_log.js";
|
|
3
3
|
export { normalizeLevels } from "./levels/index.js";
|
|
4
|
-
export {
|
|
4
|
+
export { getLogsForDir } from "./storage/query.js";
|
|
5
5
|
export { logStream } from "./stream/index.js";
|
|
6
|
-
export type { ConsoleOptions, CreateLogOptions, LogEntry, LogInstance, LogLevelConfig, LogOrigin, LogQueryOptions, LogStats, LogStreamName, RedactOptions, RedactTransformArgs, RequestLoggerOptions, RetentionOptions, WriteOptions, } from "./types.js";
|
|
6
|
+
export type { ConsoleOptions, CreateLogOptions, LogEntry, LogInstance, LogLevelConfig, LogOrigin, LogQueryOptions, LogQueryResult, LogQueryTotals, LogPartitionTotals, LogPartitionSummary, LogStats, LogStreamName, RedactOptions, RedactTransformArgs, RequestLoggerOptions, RetentionOptions, WriteOptions, } from "./types.js";
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,IAAI,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,IAAI,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,cAAc,EACd,SAAS,EACT,eAAe,EACf,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,QAAQ,EACR,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,GACb,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { TOP_LEVEL, DEFAULT_LEVELS as defaultLevels } from "./constants.js";
|
|
2
2
|
export { createLog } from "./core/create_log.js";
|
|
3
3
|
export { normalizeLevels } from "./levels/index.js";
|
|
4
|
-
export {
|
|
4
|
+
export { getLogsForDir } from "./storage/query.js";
|
|
5
5
|
export { logStream } from "./stream/index.js";
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,IAAI,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,IAAI,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/storage/names.d.ts
CHANGED
|
@@ -9,13 +9,16 @@ type ParsedLogFile = {
|
|
|
9
9
|
type WalkedLogFile = ParsedLogFile & {
|
|
10
10
|
absPath: string;
|
|
11
11
|
relDir: string;
|
|
12
|
+
groupDir: string;
|
|
12
13
|
groupKey: string;
|
|
14
|
+
partition: string | null;
|
|
13
15
|
};
|
|
16
|
+
declare function normalizePartitionKey(input: unknown): string;
|
|
14
17
|
declare function nowFileStamp(date?: Date, timeZone?: string): string;
|
|
15
18
|
declare function fileStampForEntry(entry: LogEntry, timeZone?: string): string;
|
|
16
19
|
declare function makeLogFileName(stamp: string, sequence: number, level: string): string;
|
|
17
20
|
declare function parseLogFileName(fileName: string): ParsedLogFile | null;
|
|
18
|
-
declare function walkedFileFromPath(baseDir: string, filePath: string): WalkedLogFile | null;
|
|
19
|
-
export { fileStampForEntry, makeLogFileName, nowFileStamp, parseLogFileName, walkedFileFromPath };
|
|
21
|
+
declare function walkedFileFromPath(baseDir: string, filePath: string, partition?: string | null, rootDir?: string): WalkedLogFile | null;
|
|
22
|
+
export { fileStampForEntry, makeLogFileName, normalizePartitionKey, nowFileStamp, parseLogFileName, walkedFileFromPath };
|
|
20
23
|
export type { ParsedLogFile, WalkedLogFile };
|
|
21
24
|
//# sourceMappingURL=names.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"names.d.ts","sourceRoot":"","sources":["../../src/storage/names.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"names.d.ts","sourceRoot":"","sources":["../../src/storage/names.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI5C,KAAK,aAAa,GAAG;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,KAAK,aAAa,GAAG,aAAa,GAAG;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEF,iBAAS,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAErD;AAED,iBAAS,YAAY,CAAC,IAAI,OAAa,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAGlE;AAED,iBAAS,iBAAiB,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAGrE;AAED,iBAAS,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAG/E;AAED,iBAAS,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAiChE;AAED,iBAAS,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,GAAE,MAAM,GAAG,IAAW,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAetI;AAED,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,qBAAqB,EAAE,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,CAAC;AACzH,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/storage/names.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { TOP_LEVEL } from "../constants.js";
|
|
3
3
|
import { groupKeyFromRelDir } from "../groups.js";
|
|
4
|
+
import { toString } from "../utils/values.js";
|
|
4
5
|
import { getLocalDateTimeParts, normalizeTimeZone } from "../utils/datetime.js";
|
|
6
|
+
function normalizePartitionKey(input) {
|
|
7
|
+
return toString(input).replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
8
|
+
}
|
|
5
9
|
function nowFileStamp(date = new Date(), timeZone) {
|
|
6
10
|
const parts = getLocalDateTimeParts(date, normalizeTimeZone(timeZone));
|
|
7
11
|
return `${parts.year}-${parts.month}-${parts.day}-${parts.hour}`;
|
|
@@ -46,17 +50,21 @@ function parseLogFileName(fileName) {
|
|
|
46
50
|
compressed: Boolean(legacy[4]),
|
|
47
51
|
};
|
|
48
52
|
}
|
|
49
|
-
function walkedFileFromPath(baseDir, filePath) {
|
|
53
|
+
function walkedFileFromPath(baseDir, filePath, partition = null, rootDir) {
|
|
50
54
|
const parsed = parseLogFileName(path.basename(filePath));
|
|
51
55
|
if (!parsed)
|
|
52
56
|
return null;
|
|
53
|
-
const
|
|
57
|
+
const relativeRoot = rootDir || baseDir;
|
|
58
|
+
const relDir = path.relative(relativeRoot, path.dirname(filePath));
|
|
59
|
+
const groupDir = relDir && relDir !== "." ? relDir : "";
|
|
54
60
|
return {
|
|
55
61
|
...parsed,
|
|
56
62
|
absPath: filePath,
|
|
57
|
-
relDir,
|
|
58
|
-
|
|
63
|
+
relDir: path.relative(baseDir, path.dirname(filePath)),
|
|
64
|
+
groupDir,
|
|
65
|
+
groupKey: groupDir ? groupKeyFromRelDir(groupDir) : TOP_LEVEL,
|
|
66
|
+
partition,
|
|
59
67
|
};
|
|
60
68
|
}
|
|
61
|
-
export { fileStampForEntry, makeLogFileName, nowFileStamp, parseLogFileName, walkedFileFromPath };
|
|
69
|
+
export { fileStampForEntry, makeLogFileName, normalizePartitionKey, nowFileStamp, parseLogFileName, walkedFileFromPath };
|
|
62
70
|
//# sourceMappingURL=names.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"names.js","sourceRoot":"","sources":["../../src/storage/names.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"names.js","sourceRoot":"","sources":["../../src/storage/names.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAkBhF,SAAS,qBAAqB,CAAC,KAAc;IAC3C,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;AACzD,CAAC;AAED,SAAS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,CAAC,QAAQ,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IACnE,MAAM,QAAQ,GAAG,MAAM,IAAI,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IAExD,OAAO;QACL,GAAG,MAAM;QACT,OAAO,EAAE,QAAQ;QACjB,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACtD,QAAQ;QACR,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS;QAC7D,SAAS;KACV,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,qBAAqB,EAAE,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/storage/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGtH,iBAAS,qBAAqB,CAAC,KAAK,CAAC,EAAE,YAAY,GAAG,sBAAsB,CAY3E;AAED,iBAAS,yBAAyB,CAAC,KAAK,CAAC,EAAE,gBAAgB,GAAG,0BAA0B,
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/storage/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGtH,iBAAS,qBAAqB,CAAC,KAAK,CAAC,EAAE,YAAY,GAAG,sBAAsB,CAY3E;AAED,iBAAS,yBAAyB,CAAC,KAAK,CAAC,EAAE,gBAAgB,GAAG,0BAA0B,CAcvF;AAED,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,CAAC"}
|
package/dist/storage/options.js
CHANGED
|
@@ -13,10 +13,12 @@ function normalizeWriteOptions(input) {
|
|
|
13
13
|
function normalizeRetentionOptions(input) {
|
|
14
14
|
const cfg = input || {};
|
|
15
15
|
const days = Number(cfg.maxAgeDays);
|
|
16
|
+
const maxPartitions = Number(cfg.maxPartitions);
|
|
16
17
|
const cleanupIntervalMs = Number(cfg.cleanupIntervalMs);
|
|
17
18
|
return {
|
|
18
19
|
enabled: cfg.enabled !== false,
|
|
19
|
-
maxAgeDays: Number.isFinite(days) && days > 0 ? days :
|
|
20
|
+
maxAgeDays: Number.isFinite(days) && days > 0 ? Math.floor(days) : null,
|
|
21
|
+
maxPartitions: Number.isFinite(maxPartitions) && maxPartitions > 0 ? Math.floor(maxPartitions) : null,
|
|
20
22
|
maxFileSize: parseSize(cfg.maxFileSize, 20 * 1024 * 1024),
|
|
21
23
|
compressOldFiles: cfg.compressOldFiles === true,
|
|
22
24
|
cleanupIntervalMs: Number.isFinite(cleanupIntervalMs) && cleanupIntervalMs > 0 ? cleanupIntervalMs : 60 * 60 * 1000,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/storage/options.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,SAAS,qBAAqB,CAAC,KAAoB;IACjD,MAAM,GAAG,GAAG,KAAK,IAAI,EAAE,CAAC;IACxB,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAEtC,OAAO;QACL,IAAI,EAAE,GAAG,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;QAC5C,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,CA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AyB,EAAE,qBAAqB,EAAE,CAAC"}
|
package/dist/storage/query.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import type { LogEntry, LogQueryOptions } from "../types.js";
|
|
1
|
+
import type { LogEntry, LogQueryOptions, LogQueryResult, LogQueryTotals } from "../types.js";
|
|
2
|
+
type DeploymentSummaryState = {
|
|
3
|
+
partition: string;
|
|
4
|
+
total: LogQueryTotals;
|
|
5
|
+
};
|
|
2
6
|
declare function readLogRows(filePath: string, compressed: boolean): Promise<LogEntry[]>;
|
|
3
7
|
declare function sortByRecordedAtAsc(entries: LogEntry[]): LogEntry[];
|
|
4
|
-
declare function
|
|
5
|
-
|
|
8
|
+
declare function buildQueryResult(dir: string, logs: LogEntry[], options: LogQueryOptions | undefined, partition: string | null, total: LogQueryTotals, items: Map<string, DeploymentSummaryState>, counts: Map<string, number>): LogQueryResult;
|
|
9
|
+
declare function getLogsForDir(dir: string, options?: LogQueryOptions): Promise<LogQueryResult>;
|
|
10
|
+
export { buildQueryResult, getLogsForDir, readLogRows, sortByRecordedAtAsc };
|
|
6
11
|
//# sourceMappingURL=query.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/storage/query.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/storage/query.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAGV,QAAQ,EACR,eAAe,EACf,cAAc,EACd,cAAc,EACf,MAAM,aAAa,CAAC;AAOrB,KAAK,sBAAsB,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,cAAc,CAAC;CACvB,CAAC;AAEF,iBAAe,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAkBrF;AAED,iBAAS,mBAAmB,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,QAAQ,EAAE,CAS5D;AA2CD,iBAAS,gBAAgB,CACvB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,QAAQ,EAAE,EAChB,OAAO,EAAE,eAAe,GAAG,SAAS,EACpC,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAAC,EAC1C,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC1B,cAAc,CA6BhB;AAiFD,iBAAe,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CA+B5F;AAED,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAC"}
|