@loggerjs/node 0.1.0 → 0.3.1
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 +25 -5
- package/dist/file-transport.d.ts +6 -2
- package/dist/file-transport.d.ts.map +1 -1
- package/dist/index.cjs +445 -95
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +447 -98
- package/dist/index.js.map +1 -1
- package/dist/internal-types.d.ts +2 -0
- package/dist/internal-types.d.ts.map +1 -1
- package/dist/logger-diagnostics.d.ts +14 -0
- package/dist/logger-diagnostics.d.ts.map +1 -0
- package/dist/node-destination.d.ts +32 -0
- package/dist/node-destination.d.ts.map +1 -0
- package/dist/rotating-file-transport.d.ts +2 -0
- package/dist/rotating-file-transport.d.ts.map +1 -1
- package/dist/stdout-transport.d.ts +2 -0
- package/dist/stdout-transport.d.ts.map +1 -1
- package/dist/worker-transport.d.ts +16 -2
- package/dist/worker-transport.d.ts.map +1 -1
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -70,11 +70,31 @@ rotatingFileTransport({ path: "audit.log", maxBytes: 10 * 1024 * 1024 });
|
|
|
70
70
|
|
|
71
71
|
| Transport | Delivers to |
|
|
72
72
|
| --- | --- |
|
|
73
|
-
| `stdoutTransport` / `stderrTransport` | process streams, one NDJSON line per log |
|
|
74
|
-
| `fileTransport` / `rotatingFileTransport` | files, with size-based rotation |
|
|
73
|
+
| `stdoutTransport` / `stderrTransport` | process streams, one NDJSON line per log, drain-aware flush, optional `minLength` buffering, clean `EPIPE` shutdown |
|
|
74
|
+
| `fileTransport` / `rotatingFileTransport` | files, with `mkdir`/`append` controls, optional `sync: true`, crash-path `flushSync`, and size-based rotation |
|
|
75
75
|
| `nodeHttpTransport` | a collector over `fetch`, wrapped in `batchTransport` (batching + retry) |
|
|
76
76
|
| `nodeSyslogTransport` | RFC 5424 syslog over UDP/TCP |
|
|
77
|
-
| `workerTransport` | a worker thread (encodes batches with a codec, optional buffer transfer, fallback on worker
|
|
77
|
+
| `workerTransport` | a worker thread (encodes batches with a codec, optional buffer transfer, ready/ack lifecycle, fallback on worker failure) |
|
|
78
|
+
|
|
79
|
+
File and process-stream transports share the same internal destination logic for
|
|
80
|
+
write callbacks, drain waiting, `minLength` buffering, close, and sync crash
|
|
81
|
+
flush. Use `await flush()` for normal shutdown. Use `flushSync()` only on fatal
|
|
82
|
+
paths, or configure `fileTransport({ sync: true })` when every write must reach
|
|
83
|
+
the filesystem before the log call returns.
|
|
84
|
+
|
|
85
|
+
`workerTransport()` is fire-and-forget unless you opt into lifecycle checks.
|
|
86
|
+
Use `readyTimeoutMs` for workers that send `{ type: "loggerjs:ready" }`, and
|
|
87
|
+
`ackTimeoutMs` for workers that acknowledge `{ type: "loggerjs:batch", id }`
|
|
88
|
+
with `{ type: "loggerjs:batch:ack", id }`. Pending batches fall back or are
|
|
89
|
+
counted as drops when readiness, posting, ack, or worker exit fails. Set
|
|
90
|
+
`autoEnd: false` for shared workers you close elsewhere. Explicit
|
|
91
|
+
`transport.ready()` / `logger.ready()` waits for the ready handshake when
|
|
92
|
+
`readyTimeoutMs` is configured.
|
|
93
|
+
|
|
94
|
+
Call `installLoggerDiagnosticsChannel()` to publish LoggerJS internal
|
|
95
|
+
diagnostics to Node `diagnostics_channel` channels such as `loggerjs.dispatch`,
|
|
96
|
+
`loggerjs.transport`, `loggerjs.flush`, `loggerjs.encode`, and
|
|
97
|
+
`loggerjs.worker`.
|
|
78
98
|
|
|
79
99
|
## Integrations (16)
|
|
80
100
|
|
|
@@ -85,7 +105,7 @@ rotatingFileTransport({ path: "audit.log", maxBytes: 10 * 1024 * 1024 });
|
|
|
85
105
|
| **Clients** | `nodeFetchIntegration`, `nodeHttpClientIntegration`, `redisIntegration`, `prismaIntegration`, `databaseIntegration` |
|
|
86
106
|
| **Queues** | `queueIntegration`, `bullMqIntegration` |
|
|
87
107
|
|
|
88
|
-
`captureProcessIntegration()` turns uncaught exceptions (fatal), unhandled rejections, warnings, and exit into log events; with `exitOnUncaught` it
|
|
108
|
+
`captureProcessIntegration()` turns uncaught exceptions (fatal), unhandled rejections, warnings, and exit into log events; with `exitOnUncaught` it captures the fatal record, calls `flushSync()`, waits for bounded async `flush()`, then exits. Every integration is tagged `source: "integration:<name>"` and guarded against capture loops.
|
|
89
109
|
|
|
90
110
|
### Context manager
|
|
91
111
|
|
|
@@ -100,7 +120,7 @@ await withContext({ requestId: "req_123" }, async () => {
|
|
|
100
120
|
|
|
101
121
|
## Subpath exports
|
|
102
122
|
|
|
103
|
-
Transports — `transport-stdout` · `transport-file` · `transport-rotating-file` · `transport-http` · `transport-syslog` · `transport-worker` · `payload-transforms` · `context`
|
|
123
|
+
Transports — `transport-stdout` · `transport-file` · `transport-rotating-file` · `transport-http` · `transport-syslog` · `transport-worker` · `payload-transforms` · `logger-diagnostics` · `context`
|
|
104
124
|
|
|
105
125
|
Integrations — `integration-process` · `integration-cli` · `integration-diagnostics` · `integration-serverless` · `integration-express` · `integration-fastify` · `integration-koa` · `integration-nest` · `integration-hapi` · `integration-fetch` · `integration-http-client` · `integration-redis` · `integration-prisma` · `integration-database` · `integration-queue` · `integration-bullmq`
|
|
106
126
|
|
package/dist/file-transport.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { type WriteStream } from "fs";
|
|
2
1
|
import { type Codec, type LoggerLevel, type Transport } from "@loggerjs/core";
|
|
2
|
+
import type { WriteStream } from "fs";
|
|
3
3
|
export interface FileTransportOptions {
|
|
4
4
|
path: string;
|
|
5
5
|
name?: string;
|
|
6
6
|
codec?: Codec<string | Uint8Array>;
|
|
7
7
|
minLevel?: LoggerLevel;
|
|
8
8
|
flags?: string;
|
|
9
|
+
append?: boolean;
|
|
10
|
+
mkdir?: boolean;
|
|
11
|
+
sync?: boolean;
|
|
12
|
+
minLength?: number;
|
|
9
13
|
}
|
|
10
14
|
export interface FileTransport extends Transport {
|
|
11
|
-
stream
|
|
15
|
+
stream?: WriteStream;
|
|
12
16
|
flushSync: () => void;
|
|
13
17
|
}
|
|
14
18
|
export declare function fileTransport(options: FileTransportOptions): FileTransport;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-transport.d.ts","sourceRoot":"","sources":["../src/file-transport.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"file-transport.d.ts","sourceRoot":"","sources":["../src/file-transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,KAAK,EAEV,KAAK,WAAW,EAChB,KAAK,SAAS,EACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAGtC,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,UAAU,CAAC,CAAC;IACnC,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAwB1E"}
|