@loglayer/transport-log-file-rotation 2.1.6 → 2.1.7

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/dist/index.d.ts CHANGED
@@ -1,267 +1,268 @@
1
- import { LoggerlessTransportConfig, LoggerlessTransport, LogLayerTransportParams } from '@loglayer/transport';
1
+ import { LogLayerTransportParams, LoggerlessTransport, LoggerlessTransportConfig } from "@loglayer/transport";
2
2
 
3
+ //#region src/LogFileRotationTransport.d.ts
3
4
  interface LogFileRotationCallbacks {
4
- /**
5
- * Called when a log file is rotated
6
- * @param oldFile - The path to the old log file
7
- * @param newFile - The path to the new log file
8
- */
9
- onRotate?: (oldFile: string, newFile: string) => void;
10
- /**
11
- * Called when a new log file is created
12
- * @param newFile - The path to the new log file
13
- */
14
- onNew?: (newFile: string) => void;
15
- /**
16
- * Called when a log file is opened
17
- */
18
- onOpen?: () => void;
19
- /**
20
- * Called when a log file is closed
21
- */
22
- onClose?: () => void;
23
- /**
24
- * Called when an error occurs
25
- * @param error - The error that occurred
26
- */
27
- onError?: (error: Error) => void;
28
- /**
29
- * Called when the stream is finished
30
- */
31
- onFinish?: () => void;
32
- /**
33
- * Called when a log file is removed due to retention policy
34
- * @param info - Information about the removed log file
35
- */
36
- onLogRemoved?: (info: {
37
- date: number;
38
- name: string;
39
- hash: string;
40
- }) => void;
5
+ /**
6
+ * Called when a log file is rotated
7
+ * @param oldFile - The path to the old log file
8
+ * @param newFile - The path to the new log file
9
+ */
10
+ onRotate?: (oldFile: string, newFile: string) => void;
11
+ /**
12
+ * Called when a new log file is created
13
+ * @param newFile - The path to the new log file
14
+ */
15
+ onNew?: (newFile: string) => void;
16
+ /**
17
+ * Called when a log file is opened
18
+ */
19
+ onOpen?: () => void;
20
+ /**
21
+ * Called when a log file is closed
22
+ */
23
+ onClose?: () => void;
24
+ /**
25
+ * Called when an error occurs
26
+ * @param error - The error that occurred
27
+ */
28
+ onError?: (error: Error) => void;
29
+ /**
30
+ * Called when the stream is finished
31
+ */
32
+ onFinish?: () => void;
33
+ /**
34
+ * Called when a log file is removed due to retention policy
35
+ * @param info - Information about the removed log file
36
+ */
37
+ onLogRemoved?: (info: {
38
+ date: number;
39
+ name: string;
40
+ hash: string;
41
+ }) => void;
41
42
  }
42
43
  interface LogFileRotationFieldNames {
43
- /**
44
- * Field name for the log level
45
- * @default "level"
46
- */
47
- level?: string;
48
- /**
49
- * Field name for the log message
50
- * @default "message"
51
- */
52
- message?: string;
53
- /**
54
- * Field name for the timestamp
55
- * @default "timestamp"
56
- */
57
- timestamp?: string;
44
+ /**
45
+ * Field name for the log level
46
+ * @default "level"
47
+ */
48
+ level?: string;
49
+ /**
50
+ * Field name for the log message
51
+ * @default "message"
52
+ */
53
+ message?: string;
54
+ /**
55
+ * Field name for the timestamp
56
+ * @default "timestamp"
57
+ */
58
+ timestamp?: string;
58
59
  }
59
60
  interface LogFileRotationLevelMap {
60
- /**
61
- * Mapping for the 'fatal' log level
62
- * @example 60 or "FATAL"
63
- */
64
- fatal?: string | number;
65
- /**
66
- * Mapping for the 'error' log level
67
- * @example 50 or "ERROR"
68
- */
69
- error?: string | number;
70
- /**
71
- * Mapping for the 'warn' log level
72
- * @example 40 or "WARN"
73
- */
74
- warn?: string | number;
75
- /**
76
- * Mapping for the 'info' log level
77
- * @example 30 or "INFO"
78
- */
79
- info?: string | number;
80
- /**
81
- * Mapping for the 'debug' log level
82
- * @example 20 or "DEBUG"
83
- */
84
- debug?: string | number;
85
- /**
86
- * Mapping for the 'trace' log level
87
- * @example 10 or "TRACE"
88
- */
89
- trace?: string | number;
61
+ /**
62
+ * Mapping for the 'fatal' log level
63
+ * @example 60 or "FATAL"
64
+ */
65
+ fatal?: string | number;
66
+ /**
67
+ * Mapping for the 'error' log level
68
+ * @example 50 or "ERROR"
69
+ */
70
+ error?: string | number;
71
+ /**
72
+ * Mapping for the 'warn' log level
73
+ * @example 40 or "WARN"
74
+ */
75
+ warn?: string | number;
76
+ /**
77
+ * Mapping for the 'info' log level
78
+ * @example 30 or "INFO"
79
+ */
80
+ info?: string | number;
81
+ /**
82
+ * Mapping for the 'debug' log level
83
+ * @example 20 or "DEBUG"
84
+ */
85
+ debug?: string | number;
86
+ /**
87
+ * Mapping for the 'trace' log level
88
+ * @example 10 or "TRACE"
89
+ */
90
+ trace?: string | number;
90
91
  }
91
92
  interface LogFileRotationBatchConfig {
92
- /**
93
- * Maximum number of log entries to queue before writing.
94
- * Default: 1000
95
- */
96
- size?: number;
97
- /**
98
- * Maximum time in milliseconds to wait before writing queued logs.
99
- * Default: 5000 (5 seconds)
100
- */
101
- timeout?: number;
93
+ /**
94
+ * Maximum number of log entries to queue before writing.
95
+ * Default: 1000
96
+ */
97
+ size?: number;
98
+ /**
99
+ * Maximum time in milliseconds to wait before writing queued logs.
100
+ * Default: 5000 (5 seconds)
101
+ */
102
+ timeout?: number;
102
103
  }
103
104
  interface LogFileRotationTransportConfig extends LoggerlessTransportConfig {
104
- /**
105
- * The filename pattern to use for the log files.
106
- * Supports date format using numerical values.
107
- * Example: "./logs/application-%DATE%.log"
108
- */
109
- filename: string;
110
- /**
111
- * Static data to be included in every log entry.
112
- * Can be either:
113
- * - A function that returns an object containing static data
114
- * - A direct object containing static data
115
- *
116
- * The data will be merged with the log entry before any other data.
117
- * If using a function, it will be called for each log entry.
118
- * @example
119
- * ```typescript
120
- * // Using a function
121
- * staticData: () => ({
122
- * hostname: hostname(),
123
- * pid: process.pid
124
- * })
125
- *
126
- * // Using an object
127
- * staticData: {
128
- * hostname: hostname(),
129
- * pid: process.pid
130
- * }
131
- * ```
132
- */
133
- staticData?: (() => Record<string, any>) | Record<string, any>;
134
- /**
135
- * The frequency of rotation. Can be:
136
- * - 'daily' for daily rotation
137
- * - 'date' for rotation on date format change
138
- * - '[1-30]m' for rotation every X minutes
139
- * - '[1-12]h' for rotation every X hours
140
- */
141
- frequency?: string;
142
- /**
143
- * The date format to use in the filename.
144
- * Uses single characters for each date component:
145
- * - 'Y' for full year
146
- * - 'M' for month
147
- * - 'D' for day
148
- * - 'H' for hour
149
- * - 'm' for minutes
150
- * - 's' for seconds
151
- *
152
- * Common patterns:
153
- * - For daily rotation: use "YMD" (creates files like app-20240117.log)
154
- * - For hourly/minute rotation: use "YMDHm" (creates files like app-202401171430.log)
155
- *
156
- * @default "YMD"
157
- */
158
- dateFormat?: string;
159
- /**
160
- * The size at which to rotate.
161
- * Examples: "10M", "100K", "100B"
162
- * If frequency is specified, this will be ignored.
163
- */
164
- size?: string;
165
- /**
166
- * Maximum number of logs to keep.
167
- * Can be a number of files or days (e.g., "10d" for 10 days)
168
- */
169
- maxLogs?: string | number;
170
- /**
171
- * Location to store the log audit file.
172
- * If not set, it will be stored in the root of the application.
173
- */
174
- auditFile?: string;
175
- /**
176
- * File extension to be appended to the filename.
177
- * Useful when using size restrictions as the rotation adds a count at the end.
178
- */
179
- extension?: string;
180
- /**
181
- * Create a tailable symlink to the current active log file.
182
- * Default: false
183
- */
184
- createSymlink?: boolean;
185
- /**
186
- * Name to use when creating the symbolic link.
187
- * Default: 'current.log'
188
- */
189
- symlinkName?: string;
190
- /**
191
- * Use UTC time for date in filename.
192
- * Default: false
193
- */
194
- utc?: boolean;
195
- /**
196
- * Use specified hashing algorithm for audit.
197
- * Default: 'md5'
198
- * Use 'sha256' for FIPS compliance.
199
- */
200
- auditHashType?: "md5" | "sha256";
201
- /**
202
- * File mode to be used when creating log files.
203
- * Default: 0o640 (user read/write, group read, others none)
204
- */
205
- fileMode?: number;
206
- /**
207
- * Options passed to the file stream.
208
- * See: https://nodejs.org/api/fs.html#fs_fs_createwritestream_path_options
209
- */
210
- fileOptions?: {
211
- flags?: string;
212
- encoding?: string;
213
- mode?: number;
214
- };
215
- /**
216
- * Event callbacks for various file stream events
217
- */
218
- callbacks?: LogFileRotationCallbacks;
219
- /**
220
- * Custom field names for the log entry JSON
221
- * Default: { level: "level", message: "message", data: "data", timestamp: "timestamp" }
222
- */
223
- fieldNames?: LogFileRotationFieldNames;
224
- /**
225
- * Delimiter between log entries.
226
- * Default: "\n"
227
- */
228
- delimiter?: string;
229
- /**
230
- * Custom function to generate timestamps for log entries.
231
- * Can return either a string (e.g., ISO string) or a number (e.g., Unix timestamp)
232
- * If not provided, defaults to new Date().toISOString()
233
- */
234
- timestampFn?: () => string | number;
235
- /**
236
- * Custom mapping for log levels.
237
- * Each log level can be mapped to either a string or number.
238
- * Example: { error: 50, warn: 40, info: 30, debug: 20, trace: 10, fatal: 60 }
239
- * Example: { error: "ERROR", warn: "WARN", info: "INFO", debug: "DEBUG", trace: "TRACE", fatal: "FATAL" }
240
- */
241
- levelMap?: LogFileRotationLevelMap;
242
- /**
243
- * Whether to compress rotated log files using gzip.
244
- * When enabled, rotated files will be compressed with .gz extension.
245
- * Default: false
246
- */
247
- compressOnRotate?: boolean;
248
- /**
249
- * Whether to enable verbose mode in the underlying file-stream-rotator.
250
- * When enabled, the rotator will log detailed information about its operations.
251
- * Default: false
252
- */
253
- verbose?: boolean;
254
- /**
255
- * Batch processing configuration.
256
- * If defined, batch processing will be enabled.
257
- * When batching is enabled, logs are queued in memory and written to disk in batches.
258
- * Queued logs are automatically flushed in the following situations:
259
- * - When the batch size is reached
260
- * - When the batch timeout is reached
261
- * - When the transport is disposed
262
- * - When the process exits (including SIGINT and SIGTERM signals)
263
- */
264
- batch?: LogFileRotationBatchConfig;
105
+ /**
106
+ * The filename pattern to use for the log files.
107
+ * Supports date format using numerical values.
108
+ * Example: "./logs/application-%DATE%.log"
109
+ */
110
+ filename: string;
111
+ /**
112
+ * Static data to be included in every log entry.
113
+ * Can be either:
114
+ * - A function that returns an object containing static data
115
+ * - A direct object containing static data
116
+ *
117
+ * The data will be merged with the log entry before any other data.
118
+ * If using a function, it will be called for each log entry.
119
+ * @example
120
+ * ```typescript
121
+ * // Using a function
122
+ * staticData: () => ({
123
+ * hostname: hostname(),
124
+ * pid: process.pid
125
+ * })
126
+ *
127
+ * // Using an object
128
+ * staticData: {
129
+ * hostname: hostname(),
130
+ * pid: process.pid
131
+ * }
132
+ * ```
133
+ */
134
+ staticData?: (() => Record<string, any>) | Record<string, any>;
135
+ /**
136
+ * The frequency of rotation. Can be:
137
+ * - 'daily' for daily rotation
138
+ * - 'date' for rotation on date format change
139
+ * - '[1-30]m' for rotation every X minutes
140
+ * - '[1-12]h' for rotation every X hours
141
+ */
142
+ frequency?: string;
143
+ /**
144
+ * The date format to use in the filename.
145
+ * Uses single characters for each date component:
146
+ * - 'Y' for full year
147
+ * - 'M' for month
148
+ * - 'D' for day
149
+ * - 'H' for hour
150
+ * - 'm' for minutes
151
+ * - 's' for seconds
152
+ *
153
+ * Common patterns:
154
+ * - For daily rotation: use "YMD" (creates files like app-20240117.log)
155
+ * - For hourly/minute rotation: use "YMDHm" (creates files like app-202401171430.log)
156
+ *
157
+ * @default "YMD"
158
+ */
159
+ dateFormat?: string;
160
+ /**
161
+ * The size at which to rotate.
162
+ * Examples: "10M", "100K", "100B"
163
+ * If frequency is specified, this will be ignored.
164
+ */
165
+ size?: string;
166
+ /**
167
+ * Maximum number of logs to keep.
168
+ * Can be a number of files or days (e.g., "10d" for 10 days)
169
+ */
170
+ maxLogs?: string | number;
171
+ /**
172
+ * Location to store the log audit file.
173
+ * If not set, it will be stored in the root of the application.
174
+ */
175
+ auditFile?: string;
176
+ /**
177
+ * File extension to be appended to the filename.
178
+ * Useful when using size restrictions as the rotation adds a count at the end.
179
+ */
180
+ extension?: string;
181
+ /**
182
+ * Create a tailable symlink to the current active log file.
183
+ * Default: false
184
+ */
185
+ createSymlink?: boolean;
186
+ /**
187
+ * Name to use when creating the symbolic link.
188
+ * Default: 'current.log'
189
+ */
190
+ symlinkName?: string;
191
+ /**
192
+ * Use UTC time for date in filename.
193
+ * Default: false
194
+ */
195
+ utc?: boolean;
196
+ /**
197
+ * Use specified hashing algorithm for audit.
198
+ * Default: 'md5'
199
+ * Use 'sha256' for FIPS compliance.
200
+ */
201
+ auditHashType?: "md5" | "sha256";
202
+ /**
203
+ * File mode to be used when creating log files.
204
+ * Default: 0o640 (user read/write, group read, others none)
205
+ */
206
+ fileMode?: number;
207
+ /**
208
+ * Options passed to the file stream.
209
+ * See: https://nodejs.org/api/fs.html#fs_fs_createwritestream_path_options
210
+ */
211
+ fileOptions?: {
212
+ flags?: string;
213
+ encoding?: string;
214
+ mode?: number;
215
+ };
216
+ /**
217
+ * Event callbacks for various file stream events
218
+ */
219
+ callbacks?: LogFileRotationCallbacks;
220
+ /**
221
+ * Custom field names for the log entry JSON
222
+ * Default: { level: "level", message: "message", data: "data", timestamp: "timestamp" }
223
+ */
224
+ fieldNames?: LogFileRotationFieldNames;
225
+ /**
226
+ * Delimiter between log entries.
227
+ * Default: "\n"
228
+ */
229
+ delimiter?: string;
230
+ /**
231
+ * Custom function to generate timestamps for log entries.
232
+ * Can return either a string (e.g., ISO string) or a number (e.g., Unix timestamp)
233
+ * If not provided, defaults to new Date().toISOString()
234
+ */
235
+ timestampFn?: () => string | number;
236
+ /**
237
+ * Custom mapping for log levels.
238
+ * Each log level can be mapped to either a string or number.
239
+ * Example: { error: 50, warn: 40, info: 30, debug: 20, trace: 10, fatal: 60 }
240
+ * Example: { error: "ERROR", warn: "WARN", info: "INFO", debug: "DEBUG", trace: "TRACE", fatal: "FATAL" }
241
+ */
242
+ levelMap?: LogFileRotationLevelMap;
243
+ /**
244
+ * Whether to compress rotated log files using gzip.
245
+ * When enabled, rotated files will be compressed with .gz extension.
246
+ * Default: false
247
+ */
248
+ compressOnRotate?: boolean;
249
+ /**
250
+ * Whether to enable verbose mode in the underlying file-stream-rotator.
251
+ * When enabled, the rotator will log detailed information about its operations.
252
+ * Default: false
253
+ */
254
+ verbose?: boolean;
255
+ /**
256
+ * Batch processing configuration.
257
+ * If defined, batch processing will be enabled.
258
+ * When batching is enabled, logs are queued in memory and written to disk in batches.
259
+ * Queued logs are automatically flushed in the following situations:
260
+ * - When the batch size is reached
261
+ * - When the batch timeout is reached
262
+ * - When the transport is disposed
263
+ * - When the process exits (including SIGINT and SIGTERM signals)
264
+ */
265
+ batch?: LogFileRotationBatchConfig;
265
266
  }
266
267
  /**
267
268
  * A transport that writes logs to rotating files with support for time-based and size-based rotation.
@@ -279,141 +280,147 @@ interface LogFileRotationTransportConfig extends LoggerlessTransportConfig {
279
280
  * If you need multiple loggers to write to the same file, share the same transport instance between them.
280
281
  */
281
282
  declare class LogFileRotationTransport extends LoggerlessTransport implements Disposable {
282
- /** Registry of active filenames to prevent multiple transports writing to the same file */
283
- private static activeFilenames;
284
- /** The current write stream for the log file */
285
- private stream;
286
- /** Custom field names for log entries */
287
- private fieldNames;
288
- /** Delimiter between log entries */
289
- private delimiter;
290
- /** Function to generate timestamps for log entries */
291
- private timestampFn;
292
- /** Custom mapping for log levels */
293
- private levelMap;
294
- /** Whether to compress rotated files */
295
- private compressOnRotate;
296
- /** Whether a file is currently being compressed */
297
- private isCompressing;
298
- /** The base filename pattern for log files */
299
- private filename;
300
- /** Static data to be included in every log entry */
301
- private staticData?;
302
- /** Whether batch processing is enabled */
303
- private batchEnabled;
304
- /** Maximum number of log entries to queue before writing */
305
- private batchSize;
306
- /** Maximum time in milliseconds to wait before writing queued logs */
307
- private batchTimeout;
308
- /** Queue of log entries waiting to be written */
309
- private batchQueue;
310
- /** Timer for batch flush timeout */
311
- private batchTimer;
312
- /** Whether the transport is being disposed */
313
- private isDisposing;
314
- /** Event callbacks for various file stream events */
315
- private callbacks?;
316
- /** Frequency of rotation (daily, hourly, etc.) */
317
- private frequency?;
318
- /** Whether to enable verbose mode */
319
- private verbose?;
320
- /** Date format for filename patterns */
321
- private dateFormat?;
322
- /** Size threshold for rotation */
323
- private size?;
324
- /** Maximum number of log files to keep */
325
- private maxLogs?;
326
- /** Path to the audit file */
327
- private auditFile?;
328
- /** File extension for log files */
329
- private extension?;
330
- /** Whether to create a symlink to current log */
331
- private createSymlink?;
332
- /** Name of the symlink file */
333
- private symlinkName?;
334
- /** Whether to use UTC time in filenames */
335
- private utc?;
336
- /** Hash algorithm for audit file */
337
- private auditHashType?;
338
- /** Options for file streams */
339
- private fileOptions?;
340
- /** File mode to be used when creating log files */
341
- private fileMode?;
342
- /**
343
- * Generates the options for FileStreamRotator consistently across the transport
344
- * @returns FileStreamRotatorOptions object
345
- * @private
346
- */
347
- private getRotatorOptions;
348
- /**
349
- * Creates a new LogFileRotationTransport instance.
350
- * @param params - Configuration options for the transport
351
- * @throws {Error} If the filename is already in use by another transport instance
352
- */
353
- constructor(params: LogFileRotationTransportConfig);
354
- /**
355
- * Initializes the write stream and sets up event listeners.
356
- * This is called either immediately if batching is disabled,
357
- * or lazily when the first batch needs to be written if batching is enabled.
358
- * @param options - Options for the file stream rotator
359
- * @private
360
- */
361
- private initStream;
362
- /**
363
- * Generates a unique path for a compressed log file.
364
- * If a file with .gz extension already exists, appends timestamp and counter.
365
- * @param filePath - The original log file path
366
- * @returns The unique path for the compressed file
367
- * @private
368
- */
369
- private getUniqueCompressedFilePath;
370
- /**
371
- * Compresses a log file using gzip.
372
- * @param filePath - Path to the file to compress
373
- * @returns Path to the compressed file
374
- * @private
375
- */
376
- private compressFile;
377
- /**
378
- * Flushes queued log entries to disk asynchronously.
379
- * This is used for normal batch processing operations.
380
- * @private
381
- */
382
- private flush;
383
- /**
384
- * Synchronously flush logs to disk.
385
- * This is used during process termination (SIGINT/SIGTERM) to ensure logs are written
386
- * before the process exits. This method uses synchronous file I/O to guarantee that
387
- * logs are written even during abrupt process termination.
388
- * @private
389
- */
390
- private flushSync;
391
- /**
392
- * Schedules a batch flush operation.
393
- * This creates a timer that will flush the batch after the configured timeout.
394
- * The timer is unref'd to prevent keeping the process alive.
395
- * @private
396
- */
397
- private scheduleBatchFlush;
398
- /**
399
- * Processes and writes a log entry.
400
- * If batching is enabled, the entry is queued and written based on batch settings.
401
- * If batching is disabled, the entry is written immediately.
402
- * @param params - The log entry parameters
403
- * @returns The original messages array
404
- */
405
- shipToLogger({ logLevel, messages, data, hasData }: LogLayerTransportParams): any[];
406
- /**
407
- * Disposes of the transport, cleaning up resources and flushing any remaining logs.
408
- * This method:
409
- * 1. Prevents new batch flushes from being scheduled
410
- * 2. Cancels any pending batch flush
411
- * 3. Flushes any remaining logs
412
- * 4. Waits for any in-progress compression to complete
413
- * 5. Closes the write stream
414
- * 6. Removes the filename from the registry
415
- */
416
- [Symbol.dispose](): void;
283
+ /** Registry of active filenames to prevent multiple transports writing to the same file */
284
+ private static activeFilenames;
285
+ /** The current write stream for the log file */
286
+ private stream;
287
+ /** Custom field names for log entries */
288
+ private fieldNames;
289
+ /** Delimiter between log entries */
290
+ private delimiter;
291
+ /** Function to generate timestamps for log entries */
292
+ private timestampFn;
293
+ /** Custom mapping for log levels */
294
+ private levelMap;
295
+ /** Whether to compress rotated files */
296
+ private compressOnRotate;
297
+ /** Whether a file is currently being compressed */
298
+ private isCompressing;
299
+ /** The base filename pattern for log files */
300
+ private filename;
301
+ /** Static data to be included in every log entry */
302
+ private staticData?;
303
+ /** Whether batch processing is enabled */
304
+ private batchEnabled;
305
+ /** Maximum number of log entries to queue before writing */
306
+ private batchSize;
307
+ /** Maximum time in milliseconds to wait before writing queued logs */
308
+ private batchTimeout;
309
+ /** Queue of log entries waiting to be written */
310
+ private batchQueue;
311
+ /** Timer for batch flush timeout */
312
+ private batchTimer;
313
+ /** Whether the transport is being disposed */
314
+ private isDisposing;
315
+ /** Event callbacks for various file stream events */
316
+ private callbacks?;
317
+ /** Frequency of rotation (daily, hourly, etc.) */
318
+ private frequency?;
319
+ /** Whether to enable verbose mode */
320
+ private verbose?;
321
+ /** Date format for filename patterns */
322
+ private dateFormat?;
323
+ /** Size threshold for rotation */
324
+ private size?;
325
+ /** Maximum number of log files to keep */
326
+ private maxLogs?;
327
+ /** Path to the audit file */
328
+ private auditFile?;
329
+ /** File extension for log files */
330
+ private extension?;
331
+ /** Whether to create a symlink to current log */
332
+ private createSymlink?;
333
+ /** Name of the symlink file */
334
+ private symlinkName?;
335
+ /** Whether to use UTC time in filenames */
336
+ private utc?;
337
+ /** Hash algorithm for audit file */
338
+ private auditHashType?;
339
+ /** Options for file streams */
340
+ private fileOptions?;
341
+ /** File mode to be used when creating log files */
342
+ private fileMode?;
343
+ /**
344
+ * Generates the options for FileStreamRotator consistently across the transport
345
+ * @returns FileStreamRotatorOptions object
346
+ * @private
347
+ */
348
+ private getRotatorOptions;
349
+ /**
350
+ * Creates a new LogFileRotationTransport instance.
351
+ * @param params - Configuration options for the transport
352
+ * @throws {Error} If the filename is already in use by another transport instance
353
+ */
354
+ constructor(params: LogFileRotationTransportConfig);
355
+ /**
356
+ * Initializes the write stream and sets up event listeners.
357
+ * This is called either immediately if batching is disabled,
358
+ * or lazily when the first batch needs to be written if batching is enabled.
359
+ * @param options - Options for the file stream rotator
360
+ * @private
361
+ */
362
+ private initStream;
363
+ /**
364
+ * Generates a unique path for a compressed log file.
365
+ * If a file with .gz extension already exists, appends timestamp and counter.
366
+ * @param filePath - The original log file path
367
+ * @returns The unique path for the compressed file
368
+ * @private
369
+ */
370
+ private getUniqueCompressedFilePath;
371
+ /**
372
+ * Compresses a log file using gzip.
373
+ * @param filePath - Path to the file to compress
374
+ * @returns Path to the compressed file
375
+ * @private
376
+ */
377
+ private compressFile;
378
+ /**
379
+ * Flushes queued log entries to disk asynchronously.
380
+ * This is used for normal batch processing operations.
381
+ * @private
382
+ */
383
+ private flush;
384
+ /**
385
+ * Synchronously flush logs to disk.
386
+ * This is used during process termination (SIGINT/SIGTERM) to ensure logs are written
387
+ * before the process exits. This method uses synchronous file I/O to guarantee that
388
+ * logs are written even during abrupt process termination.
389
+ * @private
390
+ */
391
+ private flushSync;
392
+ /**
393
+ * Schedules a batch flush operation.
394
+ * This creates a timer that will flush the batch after the configured timeout.
395
+ * The timer is unref'd to prevent keeping the process alive.
396
+ * @private
397
+ */
398
+ private scheduleBatchFlush;
399
+ /**
400
+ * Processes and writes a log entry.
401
+ * If batching is enabled, the entry is queued and written based on batch settings.
402
+ * If batching is disabled, the entry is written immediately.
403
+ * @param params - The log entry parameters
404
+ * @returns The original messages array
405
+ */
406
+ shipToLogger({
407
+ logLevel,
408
+ messages,
409
+ data,
410
+ hasData
411
+ }: LogLayerTransportParams): any[];
412
+ /**
413
+ * Disposes of the transport, cleaning up resources and flushing any remaining logs.
414
+ * This method:
415
+ * 1. Prevents new batch flushes from being scheduled
416
+ * 2. Cancels any pending batch flush
417
+ * 3. Flushes any remaining logs
418
+ * 4. Waits for any in-progress compression to complete
419
+ * 5. Closes the write stream
420
+ * 6. Removes the filename from the registry
421
+ */
422
+ [Symbol.dispose](): void;
417
423
  }
418
-
419
- export { type LogFileRotationBatchConfig, type LogFileRotationCallbacks, type LogFileRotationFieldNames, type LogFileRotationLevelMap, LogFileRotationTransport, type LogFileRotationTransportConfig };
424
+ //#endregion
425
+ export { LogFileRotationBatchConfig, LogFileRotationCallbacks, LogFileRotationFieldNames, LogFileRotationLevelMap, LogFileRotationTransport, LogFileRotationTransportConfig };
426
+ //# sourceMappingURL=index.d.ts.map