@rife/logger 0.0.6-beta.1 → 0.0.6-beta.4

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.
Files changed (47) hide show
  1. package/dist/cjs/common.cjs +51 -0
  2. package/dist/cjs/env.cjs +40 -0
  3. package/dist/cjs/index.cjs +60 -0
  4. package/dist/cjs/pino/index.cjs +148 -0
  5. package/dist/cjs/pino/rotate.cjs +72 -0
  6. package/dist/cjs/test.cjs +36 -0
  7. package/dist/cjs/trace.cjs +52 -0
  8. package/dist/cjs/worker.cjs +7 -0
  9. package/dist/esm/common.mjs +8 -0
  10. package/dist/esm/env.mjs +5 -0
  11. package/dist/esm/index.mjs +3 -0
  12. package/dist/esm/pino/index.mjs +105 -0
  13. package/dist/esm/pino/rotate.mjs +40 -0
  14. package/dist/esm/test.mjs +32 -0
  15. package/dist/esm/trace.mjs +14 -0
  16. package/dist/esm/worker.mjs +3 -0
  17. package/dist/worker/pino-file.cjs +3522 -0
  18. package/dist/worker/pino-pretty.cjs +2856 -0
  19. package/dist/worker/pino-rotate.cjs +604 -0
  20. package/dist/worker/pino-worker.cjs +3835 -0
  21. package/dist/worker/thread-stream.cjs +172 -0
  22. package/package.json +15 -18
  23. package/src/common.ts +4 -0
  24. package/src/pino/index.ts +99 -0
  25. package/src/{rotate.ts → pino/rotate.ts} +32 -32
  26. package/src/test.ts +19 -14
  27. package/src/trace.ts +15 -16
  28. package/src/worker.ts +1 -0
  29. package/dist/env.d.ts +0 -2
  30. package/dist/env.js +0 -22
  31. package/dist/env.js.map +0 -1
  32. package/dist/index.d.ts +0 -1
  33. package/dist/index.js +0 -8
  34. package/dist/index.js.map +0 -1
  35. package/dist/pino.d.ts +0 -8
  36. package/dist/pino.js +0 -88
  37. package/dist/pino.js.map +0 -1
  38. package/dist/rotate.d.ts +0 -6
  39. package/dist/rotate.js +0 -35
  40. package/dist/rotate.js.map +0 -1
  41. package/dist/test.d.ts +0 -1
  42. package/dist/test.js +0 -23
  43. package/dist/test.js.map +0 -1
  44. package/dist/trace.d.ts +0 -3
  45. package/dist/trace.js +0 -35
  46. package/dist/trace.js.map +0 -1
  47. package/src/pino.ts +0 -80
@@ -0,0 +1,604 @@
1
+ "use strict";
2
+ var __webpack_modules__ = {
3
+ child_process: function(module1) {
4
+ module1.exports = require("child_process");
5
+ },
6
+ fs: function(module1) {
7
+ module1.exports = require("fs");
8
+ },
9
+ "fs/promises": function(module1) {
10
+ module1.exports = require("fs/promises");
11
+ },
12
+ path: function(module1) {
13
+ module1.exports = require("path");
14
+ },
15
+ stream: function(module1) {
16
+ module1.exports = require("stream");
17
+ },
18
+ timers: function(module1) {
19
+ module1.exports = require("timers");
20
+ },
21
+ util: function(module1) {
22
+ module1.exports = require("util");
23
+ },
24
+ zlib: function(module1) {
25
+ module1.exports = require("zlib");
26
+ },
27
+ "../../node_modules/.pnpm/rotating-file-stream@3.2.6/node_modules/rotating-file-stream/dist/cjs/index.js": function(__unused_webpack_module, exports, __webpack_require__) {
28
+ Object.defineProperty(exports, "__esModule", {
29
+ value: true
30
+ });
31
+ exports.RotatingFileStream = exports.RotatingFileStreamError = void 0;
32
+ exports.createStream = createStream;
33
+ const child_process_1 = __webpack_require__("child_process");
34
+ const zlib_1 = __webpack_require__("zlib");
35
+ const stream_1 = __webpack_require__("stream");
36
+ const fs_1 = __webpack_require__("fs");
37
+ const promises_1 = __webpack_require__("fs/promises");
38
+ const path_1 = __webpack_require__("path");
39
+ const util_1 = __webpack_require__("util");
40
+ const timers_1 = __webpack_require__("timers");
41
+ async function exists(filename) {
42
+ return new Promise((resolve)=>(0, fs_1.access)(filename, fs_1.constants.F_OK, (error)=>resolve(!error)));
43
+ }
44
+ class RotatingFileStreamError extends Error {
45
+ constructor(){
46
+ super("Too many destination file attempts");
47
+ this.code = "RFS-TOO-MANY";
48
+ }
49
+ }
50
+ exports.RotatingFileStreamError = RotatingFileStreamError;
51
+ class RotatingFileStream extends stream_1.Writable {
52
+ constructor(generator, options){
53
+ const { encoding, history, maxFiles, maxSize, path } = options;
54
+ super({
55
+ decodeStrings: true,
56
+ defaultEncoding: encoding
57
+ });
58
+ this.createGzip = zlib_1.createGzip;
59
+ this.exec = child_process_1.exec;
60
+ this.filename = path + generator(null);
61
+ this.fsCreateReadStream = fs_1.createReadStream;
62
+ this.fsCreateWriteStream = fs_1.createWriteStream;
63
+ this.fsOpen = promises_1.open;
64
+ this.fsReadFile = promises_1.readFile;
65
+ this.fsStat = promises_1.stat;
66
+ this.fsUnlink = promises_1.unlink;
67
+ this.generator = generator;
68
+ this.maxTimeout = 2147483640;
69
+ this.options = options;
70
+ this.stdout = process.stdout;
71
+ if (maxFiles || maxSize) options.history = path + (history ? history : this.generator(null) + ".txt");
72
+ this.on("close", ()=>this.finished ? null : this.emit("finish"));
73
+ this.on("finish", ()=>this.finished = this.clear());
74
+ (async ()=>{
75
+ try {
76
+ this.initPromise = this.init();
77
+ await this.initPromise;
78
+ delete this.initPromise;
79
+ } catch (e) {}
80
+ })();
81
+ }
82
+ _destroy(error, callback) {
83
+ this.refinal(error, callback);
84
+ }
85
+ _final(callback) {
86
+ this.refinal(void 0, callback);
87
+ }
88
+ _write(chunk, encoding, callback) {
89
+ this.rewrite([
90
+ {
91
+ chunk,
92
+ encoding
93
+ }
94
+ ], 0, callback);
95
+ }
96
+ _writev(chunks, callback) {
97
+ this.rewrite(chunks, 0, callback);
98
+ }
99
+ async refinal(error, callback) {
100
+ try {
101
+ this.clear();
102
+ if (this.initPromise) await this.initPromise;
103
+ if (this.timeoutPromise) await this.timeoutPromise;
104
+ await this.reclose();
105
+ } catch (e) {
106
+ return callback(error || e);
107
+ }
108
+ callback(error);
109
+ }
110
+ async rewrite(chunks, index, callback) {
111
+ const { size, teeToStdout } = this.options;
112
+ try {
113
+ if (this.initPromise) await this.initPromise;
114
+ for(let i = 0; i < chunks.length; ++i){
115
+ const { chunk } = chunks[i];
116
+ this.size += chunk.length;
117
+ if (this.timeoutPromise) await this.timeoutPromise;
118
+ await this.file.write(chunk);
119
+ if (teeToStdout && !this.stdout.destroyed) this.stdout.write(chunk);
120
+ if (size && this.size >= size) await this.rotate();
121
+ }
122
+ } catch (e) {
123
+ return callback(e);
124
+ }
125
+ callback();
126
+ }
127
+ async init() {
128
+ const { immutable, initialRotation, interval, size } = this.options;
129
+ if (immutable) return new Promise((resolve, reject)=>process.nextTick(()=>this.immutate(true).then(resolve).catch(reject)));
130
+ let stats;
131
+ try {
132
+ stats = await (0, promises_1.stat)(this.filename);
133
+ } catch (e) {
134
+ if ("ENOENT" !== e.code) throw e;
135
+ return this.reopen(0);
136
+ }
137
+ if (!stats.isFile()) throw new Error(`Can't write on: ${this.filename} (it is not a file)`);
138
+ if (initialRotation) {
139
+ this.intervalBounds(this.now());
140
+ const prev = this.prev;
141
+ this.intervalBounds(new Date(stats.mtime.getTime()));
142
+ if (prev !== this.prev) return this.rotate();
143
+ }
144
+ this.size = stats.size;
145
+ if (!size || stats.size < size) return this.reopen(stats.size);
146
+ if (interval) this.intervalBounds(this.now());
147
+ return this.rotate();
148
+ }
149
+ async makePath(name) {
150
+ return (0, promises_1.mkdir)(name.split(path_1.sep).slice(0, -1).join(path_1.sep), {
151
+ recursive: true
152
+ });
153
+ }
154
+ async reopen(size) {
155
+ let file;
156
+ try {
157
+ file = await (0, promises_1.open)(this.filename, "a", this.options.mode);
158
+ } catch (e) {
159
+ if ("ENOENT" !== e.code) throw e;
160
+ await this.makePath(this.filename);
161
+ file = await (0, promises_1.open)(this.filename, "a", this.options.mode);
162
+ }
163
+ this.file = file;
164
+ this.size = size;
165
+ this.interval();
166
+ this.emit("open", this.filename);
167
+ }
168
+ async reclose() {
169
+ const { file } = this;
170
+ if (!file) return;
171
+ delete this.file;
172
+ return file.close();
173
+ }
174
+ now() {
175
+ return new Date();
176
+ }
177
+ async rotate() {
178
+ const { immutable, rotate } = this.options;
179
+ this.size = 0;
180
+ this.rotation = this.now();
181
+ this.clear();
182
+ this.emit("rotation");
183
+ await this.reclose();
184
+ if (rotate) return this.classical();
185
+ if (immutable) return this.immutate(false);
186
+ return this.move();
187
+ }
188
+ async findName() {
189
+ const { interval, path, intervalBoundary } = this.options;
190
+ for(let index = 1; index < 1000; ++index){
191
+ const filename = path + this.generator(interval && intervalBoundary ? new Date(this.prev) : this.rotation, index);
192
+ if (!await exists(filename)) return filename;
193
+ }
194
+ throw new RotatingFileStreamError();
195
+ }
196
+ async move() {
197
+ const { compress } = this.options;
198
+ const filename = await this.findName();
199
+ await this.touch(filename);
200
+ if (compress) await this.compress(filename);
201
+ else await (0, promises_1.rename)(this.filename, filename);
202
+ return this.rotated(filename);
203
+ }
204
+ async touch(filename) {
205
+ let file;
206
+ try {
207
+ file = await this.fsOpen(filename, "a");
208
+ } catch (e) {
209
+ if ("ENOENT" !== e.code) throw e;
210
+ await this.makePath(filename);
211
+ file = await (0, promises_1.open)(filename, "a");
212
+ }
213
+ await file.close();
214
+ return this.unlink(filename);
215
+ }
216
+ async classical() {
217
+ const { compress, path, rotate } = this.options;
218
+ let rotatedName = "";
219
+ for(let count = rotate; count > 0; --count){
220
+ const currName = path + this.generator(count);
221
+ const prevName = 1 === count ? this.filename : path + this.generator(count - 1);
222
+ if (await exists(prevName)) {
223
+ if (!rotatedName) rotatedName = currName;
224
+ if (1 === count && compress) await this.compress(currName);
225
+ else try {
226
+ await (0, promises_1.rename)(prevName, currName);
227
+ } catch (e) {
228
+ if ("ENOENT" !== e.code) throw e;
229
+ await this.makePath(currName);
230
+ await (0, promises_1.rename)(prevName, currName);
231
+ }
232
+ }
233
+ }
234
+ return this.rotated(rotatedName);
235
+ }
236
+ clear() {
237
+ if (this.timeout) {
238
+ clearTimeout(this.timeout);
239
+ this.timeout = null;
240
+ }
241
+ return true;
242
+ }
243
+ intervalBoundsBig(now) {
244
+ const year = this.options.intervalUTC ? now.getUTCFullYear() : now.getFullYear();
245
+ let month = this.options.intervalUTC ? now.getUTCMonth() : now.getMonth();
246
+ let day = this.options.intervalUTC ? now.getUTCDate() : now.getDate();
247
+ let hours = this.options.intervalUTC ? now.getUTCHours() : now.getHours();
248
+ const { num, unit } = this.options.interval;
249
+ if ("M" === unit) {
250
+ day = 1;
251
+ hours = 0;
252
+ } else hours = "d" === unit ? 0 : parseInt(hours / num, 10) * num;
253
+ this.prev = new Date(year, month, day, hours, 0, 0, 0).getTime();
254
+ if ("M" === unit) month += num;
255
+ else if ("d" === unit) day += num;
256
+ else hours += num;
257
+ this.next = new Date(year, month, day, hours, 0, 0, 0).getTime();
258
+ }
259
+ intervalBounds(now) {
260
+ const unit = this.options.interval.unit;
261
+ if ("M" === unit || "d" === unit || "h" === unit) this.intervalBoundsBig(now);
262
+ else {
263
+ let period = 1000 * this.options.interval.num;
264
+ if ("m" === unit) period *= 60;
265
+ this.prev = parseInt(now.getTime() / period, 10) * period;
266
+ this.next = this.prev + period;
267
+ }
268
+ return new Date(this.prev);
269
+ }
270
+ interval() {
271
+ if (!this.options.interval) return;
272
+ this.intervalBounds(this.now());
273
+ const set = async ()=>{
274
+ const time = this.next - this.now().getTime();
275
+ if (time <= 0) try {
276
+ this.timeoutPromise = this.rotate();
277
+ await this.timeoutPromise;
278
+ delete this.timeoutPromise;
279
+ } catch (e) {}
280
+ else {
281
+ this.timeout = (0, timers_1.setTimeout)(set, time > this.maxTimeout ? this.maxTimeout : time);
282
+ this.timeout.unref();
283
+ }
284
+ };
285
+ set();
286
+ }
287
+ async compress(filename) {
288
+ const { compress } = this.options;
289
+ if ("function" == typeof compress) await new Promise((resolve, reject)=>{
290
+ this.exec(compress(this.filename, filename), (error, stdout, stderr)=>{
291
+ this.emit("external", stdout, stderr);
292
+ error ? reject(error) : resolve();
293
+ });
294
+ });
295
+ else await this.gzip(filename);
296
+ return this.unlink(this.filename);
297
+ }
298
+ async gzip(filename) {
299
+ const { mode } = this.options;
300
+ const options = mode ? {
301
+ mode
302
+ } : {};
303
+ const inp = this.fsCreateReadStream(this.filename, {});
304
+ const out = this.fsCreateWriteStream(filename, options);
305
+ const zip = this.createGzip();
306
+ return new Promise((resolve, reject)=>{
307
+ inp.once("error", reject);
308
+ out.once("error", reject);
309
+ zip.once("error", reject);
310
+ out.once("finish", resolve);
311
+ inp.pipe(zip).pipe(out);
312
+ });
313
+ }
314
+ async rotated(filename) {
315
+ const { maxFiles, maxSize } = this.options;
316
+ if (maxFiles || maxSize) await this.history(filename);
317
+ this.emit("rotated", filename);
318
+ return this.reopen(0);
319
+ }
320
+ async history(filename) {
321
+ const { history, maxFiles, maxSize } = this.options;
322
+ const res = [];
323
+ let files = [
324
+ filename
325
+ ];
326
+ try {
327
+ const content = await this.fsReadFile(history, "utf8");
328
+ files = [
329
+ ...content.toString().split("\n"),
330
+ filename
331
+ ];
332
+ } catch (e) {
333
+ if ("ENOENT" !== e.code) throw e;
334
+ }
335
+ for (const file of files)if (file) try {
336
+ const stats = await this.fsStat(file);
337
+ if (stats.isFile()) res.push({
338
+ name: file,
339
+ size: stats.size,
340
+ time: stats.mtime.getTime()
341
+ });
342
+ else this.emit("warning", new Error(`File '${file}' contained in history is not a regular file`));
343
+ } catch (e) {
344
+ if ("ENOENT" !== e.code) throw e;
345
+ }
346
+ res.sort((a, b)=>a.time - b.time);
347
+ if (maxFiles) while(res.length > maxFiles){
348
+ const file = res.shift();
349
+ await this.unlink(file.name);
350
+ this.emit("removed", file.name, true);
351
+ }
352
+ if (maxSize) while(res.reduce((size, file)=>size + file.size, 0) > maxSize){
353
+ const file = res.shift();
354
+ await this.unlink(file.name);
355
+ this.emit("removed", file.name, false);
356
+ }
357
+ await (0, promises_1.writeFile)(history, res.map((e)=>e.name).join("\n") + "\n", "utf-8");
358
+ this.emit("history");
359
+ }
360
+ async immutate(first) {
361
+ const { size } = this.options;
362
+ const now = this.now();
363
+ for(let index = 1; index < 1000; ++index){
364
+ let fileSize = 0;
365
+ let stats;
366
+ this.filename = this.options.path + this.generator(now, index);
367
+ try {
368
+ stats = await this.fsStat(this.filename);
369
+ } catch (e) {
370
+ if ("ENOENT" !== e.code) throw e;
371
+ }
372
+ if (stats) {
373
+ fileSize = stats.size;
374
+ if (!stats.isFile()) throw new Error(`Can't write on: '${this.filename}' (it is not a file)`);
375
+ if (size && fileSize >= size) continue;
376
+ }
377
+ if (first) {
378
+ this.last = this.filename;
379
+ return this.reopen(fileSize);
380
+ }
381
+ await this.rotated(this.last);
382
+ this.last = this.filename;
383
+ return;
384
+ }
385
+ throw new RotatingFileStreamError();
386
+ }
387
+ async unlink(filename) {
388
+ try {
389
+ await this.fsUnlink(filename);
390
+ } catch (e) {
391
+ if ("ENOENT" !== e.code) throw e;
392
+ this.emit("warning", e);
393
+ }
394
+ }
395
+ }
396
+ exports.RotatingFileStream = RotatingFileStream;
397
+ function buildNumberCheck(field) {
398
+ return (type, options, value)=>{
399
+ const converted = parseInt(value, 10);
400
+ if ("number" !== type || converted !== value || converted <= 0) throw new Error(`'${field}' option must be a positive integer number`);
401
+ };
402
+ }
403
+ function buildStringCheck(field, check) {
404
+ return (type, options, value)=>{
405
+ if ("string" !== type) throw new Error(`Don't know how to handle 'options.${field}' type: ${type}`);
406
+ options[field] = check(value);
407
+ };
408
+ }
409
+ function checkMeasure(value, what, units) {
410
+ const ret = {};
411
+ ret.num = parseInt(value, 10);
412
+ if (isNaN(ret.num)) throw new Error(`Unknown 'options.${what}' format: ${value}`);
413
+ if (ret.num <= 0) throw new Error(`A positive integer number is expected for 'options.${what}'`);
414
+ ret.unit = value.replace(/^[ 0]*/g, "").substr((ret.num + "").length, 1);
415
+ if (0 === ret.unit.length) throw new Error(`Missing unit for 'options.${what}'`);
416
+ if (!units[ret.unit]) throw new Error(`Unknown 'options.${what}' unit: ${ret.unit}`);
417
+ return ret;
418
+ }
419
+ const intervalUnits = {
420
+ M: true,
421
+ d: true,
422
+ h: true,
423
+ m: true,
424
+ s: true
425
+ };
426
+ function checkIntervalUnit(ret, unit, amount) {
427
+ if (parseInt(amount / ret.num, 10) * ret.num !== amount) throw new Error(`An integer divider of ${amount} is expected as ${unit} for 'options.interval'`);
428
+ }
429
+ function checkInterval(value) {
430
+ const ret = checkMeasure(value, "interval", intervalUnits);
431
+ switch(ret.unit){
432
+ case "h":
433
+ checkIntervalUnit(ret, "hours", 24);
434
+ break;
435
+ case "m":
436
+ checkIntervalUnit(ret, "minutes", 60);
437
+ break;
438
+ case "s":
439
+ checkIntervalUnit(ret, "seconds", 60);
440
+ break;
441
+ }
442
+ return ret;
443
+ }
444
+ const sizeUnits = {
445
+ B: true,
446
+ G: true,
447
+ K: true,
448
+ M: true
449
+ };
450
+ function checkSize(value) {
451
+ const ret = checkMeasure(value, "size", sizeUnits);
452
+ if ("K" === ret.unit) return 1024 * ret.num;
453
+ if ("M" === ret.unit) return 1048576 * ret.num;
454
+ if ("G" === ret.unit) return 1073741824 * ret.num;
455
+ return ret.num;
456
+ }
457
+ const checks = {
458
+ encoding: (type, options, value)=>new util_1.TextDecoder(value),
459
+ immutable: ()=>{},
460
+ initialRotation: ()=>{},
461
+ interval: buildStringCheck("interval", checkInterval),
462
+ intervalBoundary: ()=>{},
463
+ intervalUTC: ()=>{},
464
+ maxFiles: buildNumberCheck("maxFiles"),
465
+ maxSize: buildStringCheck("maxSize", checkSize),
466
+ mode: ()=>{},
467
+ omitExtension: ()=>{},
468
+ rotate: buildNumberCheck("rotate"),
469
+ size: buildStringCheck("size", checkSize),
470
+ teeToStdout: ()=>{},
471
+ ...{
472
+ compress: (type, options, value)=>{
473
+ if (false === value) return;
474
+ if (!value) throw new Error("A value for 'options.compress' must be specified");
475
+ if ("boolean" === type) return options.compress = (source, dest)=>`cat ${source} | gzip -c9 > ${dest}`;
476
+ if ("function" === type) return;
477
+ if ("string" !== type) throw new Error(`Don't know how to handle 'options.compress' type: ${type}`);
478
+ if ("gzip" !== value) throw new Error(`Don't know how to handle compression method: ${value}`);
479
+ },
480
+ history: (type)=>{
481
+ if ("string" !== type) throw new Error(`Don't know how to handle 'options.history' type: ${type}`);
482
+ },
483
+ path: (type, options, value)=>{
484
+ if ("string" !== type) throw new Error(`Don't know how to handle 'options.path' type: ${type}`);
485
+ if (value[value.length - 1] !== path_1.sep) options.path = value + path_1.sep;
486
+ }
487
+ }
488
+ };
489
+ function checkOpts(options) {
490
+ const ret = {};
491
+ let opt;
492
+ for(opt in options){
493
+ const value = options[opt];
494
+ const type = typeof value;
495
+ if (!(opt in checks)) throw new Error(`Unknown option: ${opt}`);
496
+ ret[opt] = options[opt];
497
+ checks[opt](type, ret, value);
498
+ }
499
+ if (!ret.path) ret.path = "";
500
+ if (!ret.interval) {
501
+ delete ret.immutable;
502
+ delete ret.initialRotation;
503
+ delete ret.intervalBoundary;
504
+ delete ret.intervalUTC;
505
+ }
506
+ if (ret.rotate) {
507
+ delete ret.history;
508
+ delete ret.immutable;
509
+ delete ret.maxFiles;
510
+ delete ret.maxSize;
511
+ delete ret.intervalBoundary;
512
+ delete ret.intervalUTC;
513
+ }
514
+ if (ret.immutable) delete ret.compress;
515
+ if (!ret.intervalBoundary) delete ret.initialRotation;
516
+ return ret;
517
+ }
518
+ function createClassical(filename, compress, omitExtension) {
519
+ return (index)=>index ? `${filename}.${index}${compress && !omitExtension ? ".gz" : ""}` : filename;
520
+ }
521
+ function createGenerator(filename, compress, omitExtension) {
522
+ const pad = (num)=>(num > 9 ? "" : "0") + num;
523
+ return (time, index)=>{
524
+ if (!time) return filename;
525
+ const month = time.getFullYear() + "" + pad(time.getMonth() + 1);
526
+ const day = pad(time.getDate());
527
+ const hour = pad(time.getHours());
528
+ const minute = pad(time.getMinutes());
529
+ return month + day + "-" + hour + minute + "-" + pad(index) + "-" + filename + (compress && !omitExtension ? ".gz" : "");
530
+ };
531
+ }
532
+ function createStream(filename, options) {
533
+ if (void 0 === options) options = {};
534
+ else if ("object" != typeof options) throw new Error(`The "options" argument must be of type object. Received type ${typeof options}`);
535
+ const opts = checkOpts(options);
536
+ const { compress, omitExtension } = opts;
537
+ let generator;
538
+ if ("string" == typeof filename) generator = options.rotate ? createClassical(filename, !!compress, omitExtension) : createGenerator(filename, !!compress, omitExtension);
539
+ else if ("function" == typeof filename) generator = filename;
540
+ else throw new Error(`The "filename" argument must be one of type string or function. Received type ${typeof filename}`);
541
+ return new RotatingFileStream(generator, opts);
542
+ }
543
+ }
544
+ };
545
+ var __webpack_module_cache__ = {};
546
+ function __webpack_require__(moduleId) {
547
+ var cachedModule = __webpack_module_cache__[moduleId];
548
+ if (void 0 !== cachedModule) return cachedModule.exports;
549
+ var module1 = __webpack_module_cache__[moduleId] = {
550
+ exports: {}
551
+ };
552
+ __webpack_modules__[moduleId](module1, module1.exports, __webpack_require__);
553
+ return module1.exports;
554
+ }
555
+ (()=>{
556
+ __webpack_require__.d = (exports, definition)=>{
557
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
558
+ enumerable: true,
559
+ get: definition[key]
560
+ });
561
+ };
562
+ })();
563
+ (()=>{
564
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
565
+ })();
566
+ (()=>{
567
+ __webpack_require__.r = (exports)=>{
568
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports, Symbol.toStringTag, {
569
+ value: 'Module'
570
+ });
571
+ Object.defineProperty(exports, '__esModule', {
572
+ value: true
573
+ });
574
+ };
575
+ })();
576
+ var __webpack_exports__ = {};
577
+ (()=>{
578
+ __webpack_require__.r(__webpack_exports__);
579
+ __webpack_require__.d(__webpack_exports__, {
580
+ default: ()=>__WEBPACK_DEFAULT_EXPORT__
581
+ });
582
+ const generator = (time, index)=>{
583
+ if (!time) return 'server.log';
584
+ time = new Date(time);
585
+ const month = String(time.getMonth() + 1).padStart(2, '0');
586
+ const day = String(time.getDate()).padStart(2, '0');
587
+ if (index) {
588
+ const count = String(index).padStart(3, '0');
589
+ return `server.${time.getFullYear()}${month}${day}-${count}.log`;
590
+ }
591
+ return `server.${time.getFullYear()}${month}${day}.log`;
592
+ };
593
+ const __WEBPACK_DEFAULT_EXPORT__ = (options)=>{
594
+ const { createStream } = __webpack_require__("../../node_modules/.pnpm/rotating-file-stream@3.2.6/node_modules/rotating-file-stream/dist/cjs/index.js");
595
+ const { path } = options;
596
+ return createStream(generator, {
597
+ size: '50M',
598
+ maxSize: '500M',
599
+ interval: '1d',
600
+ path
601
+ });
602
+ };
603
+ })();
604
+ module.exports = __webpack_exports__;