logroller 2.1.0 → 3.0.0

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.
@@ -1,5 +1,8 @@
1
- import type { RotateFileStream } from "./rotate-file-stream.js";
2
- export interface ShutdownOptions {
1
+ import { R as RotateFileStream } from './rotate-file-stream.cjs';
2
+ export { C as ClockInfo, a as RotateFileStreamEventMap, b as RotateFileStreamOptions, c as RotatedInfo, d as RotationReason, S as SealInfo, e as SegmentInfo, f as StreamStats, g as createStream } from './rotate-file-stream.cjs';
3
+ import 'node:stream';
4
+
5
+ interface ShutdownOptions {
3
6
  /** Signals to listen on. @default ["SIGINT", "SIGTERM"] */
4
7
  signals?: NodeJS.Signals[];
5
8
  /** Hard-exit deadline (ms) if a stream refuses to end.
@@ -23,10 +26,14 @@ export interface ShutdownOptions {
23
26
  * const flush = installShutdown(logStream);
24
27
  * process.on("exit", () => { void flush(); });
25
28
  */
26
- export declare function installShutdown(streams: RotateFileStream | RotateFileStream[], opts?: ShutdownOptions): () => Promise<void>;
29
+ declare function installShutdown(streams: RotateFileStream | RotateFileStream[], opts?: ShutdownOptions): () => Promise<void>;
27
30
  /**
28
31
  * End every registered stream (flush buffered writes) with a deadline.
29
- * Does NOT exit the process. Double-ending an already-ended stream is
30
- * harmless — the error lands in the ignored callback.
32
+ * Does NOT exit the process. Resolves `true` when every stream finished,
33
+ * `false` when the deadline hit first. Concurrent calls share one flush.
34
+ * Ended/destroyed streams leave the registry.
31
35
  */
32
- export declare function flushAll(timeoutMs?: number): Promise<void>;
36
+ declare function flushAll(timeoutMs?: number): Promise<boolean>;
37
+
38
+ export { RotateFileStream, flushAll, installShutdown };
39
+ export type { ShutdownOptions };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,39 @@
1
+ import { R as RotateFileStream } from './rotate-file-stream.js';
2
+ export { C as ClockInfo, a as RotateFileStreamEventMap, b as RotateFileStreamOptions, c as RotatedInfo, d as RotationReason, S as SealInfo, e as SegmentInfo, f as StreamStats, g as createStream } from './rotate-file-stream.js';
3
+ import 'node:stream';
4
+
5
+ interface ShutdownOptions {
6
+ /** Signals to listen on. @default ["SIGINT", "SIGTERM"] */
7
+ signals?: NodeJS.Signals[];
8
+ /** Hard-exit deadline (ms) if a stream refuses to end.
9
+ * @default 5000 */
10
+ timeoutMs?: number;
11
+ /** Process exit code. @default 0 */
12
+ code?: number;
13
+ }
1
14
  /**
2
- * logroller — zero-dependency rotating file streams for Node.js.
15
+ * Register streams for graceful shutdown: on SIGINT/SIGTERM every
16
+ * registered stream is ended — flushing buffered writes and finishing the
17
+ * audit manifest — before the process exits, with a hard deadline.
3
18
  *
4
- * @packageDocumentation
19
+ * Safe to call multiple times: process listeners install once, streams
20
+ * accumulate in the registry.
21
+ *
22
+ * Returns `flush()`, the same graceful end WITHOUT exiting — for tests
23
+ * and custom signal handling.
24
+ *
25
+ * @example
26
+ * const flush = installShutdown(logStream);
27
+ * process.on("exit", () => { void flush(); });
28
+ */
29
+ declare function installShutdown(streams: RotateFileStream | RotateFileStream[], opts?: ShutdownOptions): () => Promise<void>;
30
+ /**
31
+ * End every registered stream (flush buffered writes) with a deadline.
32
+ * Does NOT exit the process. Resolves `true` when every stream finished,
33
+ * `false` when the deadline hit first. Concurrent calls share one flush.
34
+ * Ended/destroyed streams leave the registry.
5
35
  */
6
- export { createStream, RotateFileStream } from "./rotate-file-stream.js";
7
- export { flushAll, installShutdown } from "./shutdown.js";
8
- export type { ShutdownOptions } from "./shutdown.js";
9
- export type { ClockInfo, RotatedInfo, RotateFileStreamEventMap, RotateFileStreamOptions, RotationReason, SealInfo, SegmentInfo, StreamStats } from "./types.js";
36
+ declare function flushAll(timeoutMs?: number): Promise<boolean>;
37
+
38
+ export { RotateFileStream, flushAll, installShutdown };
39
+ export type { ShutdownOptions };