@putkoff/abstract-logger 0.0.60 → 0.0.63

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 (41) hide show
  1. package/dist/cjs/index.js +530 -438
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/types/imports/functions.d.ts +1 -1
  4. package/dist/cjs/types/imports/utils/index.d.ts +2 -2
  5. package/dist/cjs/types/index.d.ts +4 -4
  6. package/dist/cjs/types/logger/index.d.ts +1 -1
  7. package/dist/cjs/types/logger/logit/blocker.d.ts +4 -0
  8. package/dist/cjs/types/logger/logit/index.d.ts +1 -0
  9. package/dist/cjs/types/logger/logit/logger.d.ts +3 -0
  10. package/dist/cjs/types/logger/main/index.d.ts +3 -0
  11. package/dist/cjs/types/logger/main/loggerBench.d.ts +24 -0
  12. package/dist/cjs/types/logger/main/loggerBenchRecorder.d.ts +1 -0
  13. package/dist/cjs/types/logger/main/loggerModes.d.ts +6 -0
  14. package/dist/cjs/types/types/index.d.ts +1 -1
  15. package/dist/esm/index.js +528 -437
  16. package/dist/esm/index.js.map +1 -1
  17. package/dist/esm/types/imports/functions.d.ts +1 -1
  18. package/dist/esm/types/imports/utils/index.d.ts +2 -2
  19. package/dist/esm/types/index.d.ts +4 -4
  20. package/dist/esm/types/logger/index.d.ts +1 -1
  21. package/dist/esm/types/logger/logit/blocker.d.ts +4 -0
  22. package/dist/esm/types/logger/logit/index.d.ts +1 -0
  23. package/dist/esm/types/logger/logit/logger.d.ts +3 -0
  24. package/dist/esm/types/logger/main/index.d.ts +3 -0
  25. package/dist/esm/types/logger/main/loggerBench.d.ts +24 -0
  26. package/dist/esm/types/logger/main/loggerBenchRecorder.d.ts +1 -0
  27. package/dist/esm/types/logger/main/loggerModes.d.ts +6 -0
  28. package/dist/esm/types/types/index.d.ts +1 -1
  29. package/dist/types/imports/functions.d.ts +1 -1
  30. package/dist/types/imports/utils/index.d.ts +2 -2
  31. package/dist/types/index.d.ts +4 -4
  32. package/dist/types/logger/index.d.ts +1 -1
  33. package/dist/types/logger/logit/blocker.d.ts +4 -0
  34. package/dist/types/logger/logit/index.d.ts +1 -0
  35. package/dist/types/logger/logit/logger.d.ts +3 -0
  36. package/dist/types/logger/main/index.d.ts +3 -0
  37. package/dist/types/logger/main/loggerBench.d.ts +24 -0
  38. package/dist/types/logger/main/loggerBenchRecorder.d.ts +1 -0
  39. package/dist/types/logger/main/loggerModes.d.ts +6 -0
  40. package/dist/types/types/index.d.ts +1 -1
  41. package/package.json +1 -1
package/dist/cjs/index.js CHANGED
@@ -13,6 +13,145 @@ var require$$1$1 = require('string_decoder');
13
13
  var require$$0$6 = require('http');
14
14
  var require$$1$2 = require('https');
15
15
 
16
+ if (typeof process === "undefined") {
17
+ throw new Error("@putkoff/abstract-env is Node-only");
18
+ }
19
+ /* ========================================================================== */
20
+ /* Utilities */
21
+ /* ========================================================================== */
22
+ function splitEq(line) {
23
+ const idx = line.indexOf("=");
24
+ if (idx === -1)
25
+ return [line.trim(), null];
26
+ const key = line.slice(0, idx).trim();
27
+ const value = line.slice(idx + 1).trim().replace(/^['"]|['"]$/g, "");
28
+ return [key, value];
29
+ }
30
+ /* ========================================================================== */
31
+ /* AbstractEnv */
32
+ /* ========================================================================== */
33
+ class AbstractEnv {
34
+ key;
35
+ fileName;
36
+ path;
37
+ deepScan;
38
+ currentFolder;
39
+ homeFolder;
40
+ envyAll;
41
+ directories = [];
42
+ envValue = null;
43
+ envPath = null;
44
+ constructor(options = {}) {
45
+ this.key = options.key ?? "MY_PASSWORD";
46
+ this.fileName = options.fileName ?? ".env";
47
+ this.path = options.startPath ?? process.cwd();
48
+ this.deepScan = options.deepScan ?? false;
49
+ this.currentFolder = process.cwd();
50
+ this.homeFolder = require$$0$1.homedir();
51
+ this.envyAll = path.join(this.homeFolder, ".envy_all");
52
+ this.initialize();
53
+ }
54
+ initialize() {
55
+ if (fs.existsSync(this.path) && fs.statSync(this.path).isFile()) {
56
+ this.fileName = path.basename(this.path);
57
+ this.path = path.dirname(this.path);
58
+ }
59
+ this.directories = this.getDirectories();
60
+ this.envValue = this.findAndReadEnv();
61
+ }
62
+ getDirectories() {
63
+ const dirs = [
64
+ this.path,
65
+ this.currentFolder,
66
+ this.homeFolder,
67
+ this.envyAll,
68
+ ];
69
+ return [...new Set(dirs.filter(d => fs.existsSync(d) && fs.statSync(d).isDirectory()))];
70
+ }
71
+ findAndReadEnv() {
72
+ for (const dir of this.directories) {
73
+ const envPath = path.join(dir, this.fileName);
74
+ if (!fs.existsSync(envPath))
75
+ continue;
76
+ this.envPath = envPath;
77
+ const value = this.searchForKey(envPath);
78
+ if (value !== null)
79
+ return value;
80
+ }
81
+ return null;
82
+ }
83
+ searchForKey(filePath) {
84
+ const content = fs.readFileSync(filePath, "utf8");
85
+ const lines = content.split(/\r?\n/);
86
+ let bestMatch = null;
87
+ for (const line of lines) {
88
+ const [lineKey, lineValue] = splitEq(line);
89
+ if (!lineValue)
90
+ continue;
91
+ if (lineKey === this.key)
92
+ return lineValue;
93
+ if (this.deepScan) {
94
+ const score = this.fuzzyScore(this.key, lineKey);
95
+ if (score >= 0.5 && (!bestMatch || score > bestMatch.score)) {
96
+ bestMatch = { value: lineValue, score };
97
+ }
98
+ }
99
+ }
100
+ return bestMatch?.value ?? null;
101
+ }
102
+ fuzzyScore(target, candidate) {
103
+ let matched = 0;
104
+ for (const part of target.split("_")) {
105
+ if (candidate.includes(part))
106
+ matched += part.length;
107
+ }
108
+ return matched / target.length;
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Retrieve environment variable value by searching .env files.
114
+ */
115
+ function getEnvValue(options = {}) {
116
+ const env = new AbstractEnv(options);
117
+ return env.envValue;
118
+ }
119
+
120
+ function parseList$1(key) {
121
+ const v = getEnvValue({ key });
122
+ return v ? v.split(",").map(s => s.trim()).filter(Boolean) : [];
123
+ }
124
+ function getLogConfig() {
125
+ return {
126
+ condensed: getEnvValue({ key: "LOG_CONDENSED" }) !== "false",
127
+ expandOnDebug: getEnvValue({ key: "LOG_EXPAND_DEBUG" }) !== "false",
128
+ showDetails: getEnvValue({ key: "LOG_SHOW_DETAILS" }) !== "false",
129
+ showOnly: getEnvValue({ key: "LOG_SHOW_ONLY" }) === "true",
130
+ showOnlyFunctions: parseList$1("LOG_SHOW_ONLY_FUNCTIONS"),
131
+ showOnlyActivities: parseList$1("LOG_SHOW_ONLY_ACTIVITIES"),
132
+ showOnlyTypes: parseList$1("LOG_SHOW_ONLY_TYPES"),
133
+ maxDetailsLength: Number(getEnvValue({ key: "LOG_DETAILS_MAX" }) ?? 500),
134
+ sampleRate: Number(getEnvValue({ key: "LOG_SAMPLE_RATE" }) ?? 1),
135
+ prettyDetails: getEnvValue({ key: "LOG_PRETTY_DETAILS" }) === "true",
136
+ activityBlocklist: parseList$1("LOG_ACTIVITY_BLOCKLIST"),
137
+ logTypeBlocklist: parseList$1("LOG_TYPE_BLOCKLIST"),
138
+ showDetailslist: parseList$1("LOG_DETAILS_ALLOWLIST"),
139
+ functionAllowlist: parseList$1("LOG_FUNCTION_ALLOWLIST"),
140
+ functionBlocklist: parseList$1("LOG_FUNCTION_BLOCKLIST"),
141
+ };
142
+ }
143
+ function debugLogConfig() {
144
+ if (getEnvValue({ key: "LOG_DEBUG_CONFIG" }) === "true") {
145
+ console.log("LOG CONFIG ENV:", {
146
+ LOG_SHOW_DETAILS: getEnvValue({ key: "LOG_SHOW_DETAILS" }),
147
+ LOG_DETAILS_ALLOWLIST: getEnvValue({ key: "LOG_DETAILS_ALLOWLIST" }),
148
+ LOG_PRETTY_DETAILS: getEnvValue({ key: "LOG_PRETTY_DETAILS" }),
149
+ LOG_CONDENSED: getEnvValue({ key: "LOG_CONDENSED" }),
150
+ LOG_EXPAND_DEBUG: getEnvValue({ key: "LOG_EXPAND_DEBUG" }),
151
+ });
152
+ }
153
+ }
154
+
16
155
  /* ------------------------------------------------------------------ */
17
156
  /* Stack inspection */
18
157
  /* ------------------------------------------------------------------ */
@@ -42,7 +181,7 @@ function resolveValue(...values) {
42
181
  }
43
182
  return sawInput ? "unknown" : "unknown";
44
183
  }
45
- function parseList$1(value) {
184
+ function parseList(value) {
46
185
  return value
47
186
  ? value.split(",").map(s => s.trim()).filter(Boolean)
48
187
  : [];
@@ -184,145 +323,6 @@ const COLS = {
184
323
  file: 16,
185
324
  };
186
325
 
187
- if (typeof process === "undefined") {
188
- throw new Error("@putkoff/abstract-env is Node-only");
189
- }
190
- /* ========================================================================== */
191
- /* Utilities */
192
- /* ========================================================================== */
193
- function splitEq(line) {
194
- const idx = line.indexOf("=");
195
- if (idx === -1)
196
- return [line.trim(), null];
197
- const key = line.slice(0, idx).trim();
198
- const value = line.slice(idx + 1).trim().replace(/^['"]|['"]$/g, "");
199
- return [key, value];
200
- }
201
- /* ========================================================================== */
202
- /* AbstractEnv */
203
- /* ========================================================================== */
204
- class AbstractEnv {
205
- key;
206
- fileName;
207
- path;
208
- deepScan;
209
- currentFolder;
210
- homeFolder;
211
- envyAll;
212
- directories = [];
213
- envValue = null;
214
- envPath = null;
215
- constructor(options = {}) {
216
- this.key = options.key ?? "MY_PASSWORD";
217
- this.fileName = options.fileName ?? ".env";
218
- this.path = options.startPath ?? process.cwd();
219
- this.deepScan = options.deepScan ?? false;
220
- this.currentFolder = process.cwd();
221
- this.homeFolder = require$$0$1.homedir();
222
- this.envyAll = path.join(this.homeFolder, ".envy_all");
223
- this.initialize();
224
- }
225
- initialize() {
226
- if (fs.existsSync(this.path) && fs.statSync(this.path).isFile()) {
227
- this.fileName = path.basename(this.path);
228
- this.path = path.dirname(this.path);
229
- }
230
- this.directories = this.getDirectories();
231
- this.envValue = this.findAndReadEnv();
232
- }
233
- getDirectories() {
234
- const dirs = [
235
- this.path,
236
- this.currentFolder,
237
- this.homeFolder,
238
- this.envyAll,
239
- ];
240
- return [...new Set(dirs.filter(d => fs.existsSync(d) && fs.statSync(d).isDirectory()))];
241
- }
242
- findAndReadEnv() {
243
- for (const dir of this.directories) {
244
- const envPath = path.join(dir, this.fileName);
245
- if (!fs.existsSync(envPath))
246
- continue;
247
- this.envPath = envPath;
248
- const value = this.searchForKey(envPath);
249
- if (value !== null)
250
- return value;
251
- }
252
- return null;
253
- }
254
- searchForKey(filePath) {
255
- const content = fs.readFileSync(filePath, "utf8");
256
- const lines = content.split(/\r?\n/);
257
- let bestMatch = null;
258
- for (const line of lines) {
259
- const [lineKey, lineValue] = splitEq(line);
260
- if (!lineValue)
261
- continue;
262
- if (lineKey === this.key)
263
- return lineValue;
264
- if (this.deepScan) {
265
- const score = this.fuzzyScore(this.key, lineKey);
266
- if (score >= 0.5 && (!bestMatch || score > bestMatch.score)) {
267
- bestMatch = { value: lineValue, score };
268
- }
269
- }
270
- }
271
- return bestMatch?.value ?? null;
272
- }
273
- fuzzyScore(target, candidate) {
274
- let matched = 0;
275
- for (const part of target.split("_")) {
276
- if (candidate.includes(part))
277
- matched += part.length;
278
- }
279
- return matched / target.length;
280
- }
281
- }
282
-
283
- /**
284
- * Retrieve environment variable value by searching .env files.
285
- */
286
- function getEnvValue(options = {}) {
287
- const env = new AbstractEnv(options);
288
- return env.envValue;
289
- }
290
-
291
- function parseList(key) {
292
- const v = getEnvValue({ key });
293
- return v ? v.split(",").map(s => s.trim()).filter(Boolean) : [];
294
- }
295
- function getLogConfig() {
296
- return {
297
- condensed: getEnvValue({ key: "LOG_CONDENSED" }) !== "false",
298
- expandOnDebug: getEnvValue({ key: "LOG_EXPAND_DEBUG" }) !== "false",
299
- showDetails: getEnvValue({ key: "LOG_SHOW_DETAILS" }) !== "false",
300
- showOnly: getEnvValue({ key: "LOG_SHOW_ONLY" }) === "true",
301
- showOnlyFunctions: parseList("LOG_SHOW_ONLY_FUNCTIONS"),
302
- showOnlyActivities: parseList("LOG_SHOW_ONLY_ACTIVITIES"),
303
- showOnlyTypes: parseList("LOG_SHOW_ONLY_TYPES"),
304
- maxDetailsLength: Number(getEnvValue({ key: "LOG_DETAILS_MAX" }) ?? 500),
305
- sampleRate: Number(getEnvValue({ key: "LOG_SAMPLE_RATE" }) ?? 1),
306
- prettyDetails: getEnvValue({ key: "LOG_PRETTY_DETAILS" }) === "true",
307
- activityBlocklist: parseList("LOG_ACTIVITY_BLOCKLIST"),
308
- logTypeBlocklist: parseList("LOG_TYPE_BLOCKLIST"),
309
- showDetailslist: parseList("LOG_DETAILS_ALLOWLIST"),
310
- functionAllowlist: parseList("LOG_FUNCTION_ALLOWLIST"),
311
- functionBlocklist: parseList("LOG_FUNCTION_BLOCKLIST"),
312
- };
313
- }
314
- function debugLogConfig() {
315
- if (getEnvValue({ key: "LOG_DEBUG_CONFIG" }) === "true") {
316
- console.log("LOG CONFIG ENV:", {
317
- LOG_SHOW_DETAILS: getEnvValue({ key: "LOG_SHOW_DETAILS" }),
318
- LOG_DETAILS_ALLOWLIST: getEnvValue({ key: "LOG_DETAILS_ALLOWLIST" }),
319
- LOG_PRETTY_DETAILS: getEnvValue({ key: "LOG_PRETTY_DETAILS" }),
320
- LOG_CONDENSED: getEnvValue({ key: "LOG_CONDENSED" }),
321
- LOG_EXPAND_DEBUG: getEnvValue({ key: "LOG_EXPAND_DEBUG" }),
322
- });
323
- }
324
- }
325
-
326
326
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
327
327
 
328
328
  function getAugmentedNamespace(n) {
@@ -1595,11 +1595,11 @@ function requireAlign () {
1595
1595
  /* eslint no-undefined: 0 */
1596
1596
 
1597
1597
  var errors$1;
1598
- var hasRequiredErrors$1;
1598
+ var hasRequiredErrors;
1599
1599
 
1600
- function requireErrors$1 () {
1601
- if (hasRequiredErrors$1) return errors$1;
1602
- hasRequiredErrors$1 = 1;
1600
+ function requireErrors () {
1601
+ if (hasRequiredErrors) return errors$1;
1602
+ hasRequiredErrors = 1;
1603
1603
 
1604
1604
  const format = format$2;
1605
1605
  const { LEVEL, MESSAGE } = tripleBeam;
@@ -3649,7 +3649,7 @@ function exposeFormat(name, requireFormat) {
3649
3649
  // Setup all transports as lazy-loaded getters.
3650
3650
  //
3651
3651
  exposeFormat('align', function () { return requireAlign(); });
3652
- exposeFormat('errors', function () { return requireErrors$1(); });
3652
+ exposeFormat('errors', function () { return requireErrors(); });
3653
3653
  exposeFormat('cli', function () { return requireCli(); });
3654
3654
  exposeFormat('combine', function () { return requireCombine(); });
3655
3655
  exposeFormat('colorize', function () { return requireColorize(); });
@@ -3726,288 +3726,246 @@ var winstonTransport = {exports: {}};
3726
3726
 
3727
3727
  var modern = {exports: {}};
3728
3728
 
3729
- var node$1;
3730
- var hasRequiredNode;
3729
+ /**
3730
+ * For Node.js, simply re-export the core `util.deprecate` function.
3731
+ */
3731
3732
 
3732
- function requireNode () {
3733
- if (hasRequiredNode) return node$1;
3734
- hasRequiredNode = 1;
3735
- /**
3736
- * For Node.js, simply re-export the core `util.deprecate` function.
3737
- */
3733
+ var node$1 = require$$0$2.deprecate;
3734
+
3735
+ var stream$1 = require$$0$3;
3736
+
3737
+ // undocumented cb() API, needed for core, not for public API
3738
+ function destroy(err, cb) {
3739
+ var _this = this;
3740
+ var readableDestroyed = this._readableState && this._readableState.destroyed;
3741
+ var writableDestroyed = this._writableState && this._writableState.destroyed;
3742
+ if (readableDestroyed || writableDestroyed) {
3743
+ if (cb) {
3744
+ cb(err);
3745
+ } else if (err) {
3746
+ if (!this._writableState) {
3747
+ process.nextTick(emitErrorNT, this, err);
3748
+ } else if (!this._writableState.errorEmitted) {
3749
+ this._writableState.errorEmitted = true;
3750
+ process.nextTick(emitErrorNT, this, err);
3751
+ }
3752
+ }
3753
+ return this;
3754
+ }
3738
3755
 
3739
- node$1 = require$$0$2.deprecate;
3740
- return node$1;
3741
- }
3756
+ // we set destroyed to true before firing error callbacks in order
3757
+ // to make it re-entrance safe in case destroy() is called within callbacks
3742
3758
 
3743
- var stream$1;
3744
- var hasRequiredStream$1;
3759
+ if (this._readableState) {
3760
+ this._readableState.destroyed = true;
3761
+ }
3745
3762
 
3746
- function requireStream$1 () {
3747
- if (hasRequiredStream$1) return stream$1;
3748
- hasRequiredStream$1 = 1;
3749
- stream$1 = require$$0$3;
3750
- return stream$1;
3763
+ // if this is a duplex stream mark the writable part as destroyed as well
3764
+ if (this._writableState) {
3765
+ this._writableState.destroyed = true;
3766
+ }
3767
+ this._destroy(err || null, function (err) {
3768
+ if (!cb && err) {
3769
+ if (!_this._writableState) {
3770
+ process.nextTick(emitErrorAndCloseNT, _this, err);
3771
+ } else if (!_this._writableState.errorEmitted) {
3772
+ _this._writableState.errorEmitted = true;
3773
+ process.nextTick(emitErrorAndCloseNT, _this, err);
3774
+ } else {
3775
+ process.nextTick(emitCloseNT, _this);
3776
+ }
3777
+ } else if (cb) {
3778
+ process.nextTick(emitCloseNT, _this);
3779
+ cb(err);
3780
+ } else {
3781
+ process.nextTick(emitCloseNT, _this);
3782
+ }
3783
+ });
3784
+ return this;
3751
3785
  }
3752
-
3753
- var destroy_1;
3754
- var hasRequiredDestroy;
3755
-
3756
- function requireDestroy () {
3757
- if (hasRequiredDestroy) return destroy_1;
3758
- hasRequiredDestroy = 1;
3759
-
3760
- // undocumented cb() API, needed for core, not for public API
3761
- function destroy(err, cb) {
3762
- var _this = this;
3763
- var readableDestroyed = this._readableState && this._readableState.destroyed;
3764
- var writableDestroyed = this._writableState && this._writableState.destroyed;
3765
- if (readableDestroyed || writableDestroyed) {
3766
- if (cb) {
3767
- cb(err);
3768
- } else if (err) {
3769
- if (!this._writableState) {
3770
- process.nextTick(emitErrorNT, this, err);
3771
- } else if (!this._writableState.errorEmitted) {
3772
- this._writableState.errorEmitted = true;
3773
- process.nextTick(emitErrorNT, this, err);
3774
- }
3775
- }
3776
- return this;
3777
- }
3778
-
3779
- // we set destroyed to true before firing error callbacks in order
3780
- // to make it re-entrance safe in case destroy() is called within callbacks
3781
-
3782
- if (this._readableState) {
3783
- this._readableState.destroyed = true;
3784
- }
3785
-
3786
- // if this is a duplex stream mark the writable part as destroyed as well
3787
- if (this._writableState) {
3788
- this._writableState.destroyed = true;
3789
- }
3790
- this._destroy(err || null, function (err) {
3791
- if (!cb && err) {
3792
- if (!_this._writableState) {
3793
- process.nextTick(emitErrorAndCloseNT, _this, err);
3794
- } else if (!_this._writableState.errorEmitted) {
3795
- _this._writableState.errorEmitted = true;
3796
- process.nextTick(emitErrorAndCloseNT, _this, err);
3797
- } else {
3798
- process.nextTick(emitCloseNT, _this);
3799
- }
3800
- } else if (cb) {
3801
- process.nextTick(emitCloseNT, _this);
3802
- cb(err);
3803
- } else {
3804
- process.nextTick(emitCloseNT, _this);
3805
- }
3806
- });
3807
- return this;
3808
- }
3809
- function emitErrorAndCloseNT(self, err) {
3810
- emitErrorNT(self, err);
3811
- emitCloseNT(self);
3812
- }
3813
- function emitCloseNT(self) {
3814
- if (self._writableState && !self._writableState.emitClose) return;
3815
- if (self._readableState && !self._readableState.emitClose) return;
3816
- self.emit('close');
3817
- }
3818
- function undestroy() {
3819
- if (this._readableState) {
3820
- this._readableState.destroyed = false;
3821
- this._readableState.reading = false;
3822
- this._readableState.ended = false;
3823
- this._readableState.endEmitted = false;
3824
- }
3825
- if (this._writableState) {
3826
- this._writableState.destroyed = false;
3827
- this._writableState.ended = false;
3828
- this._writableState.ending = false;
3829
- this._writableState.finalCalled = false;
3830
- this._writableState.prefinished = false;
3831
- this._writableState.finished = false;
3832
- this._writableState.errorEmitted = false;
3833
- }
3834
- }
3835
- function emitErrorNT(self, err) {
3836
- self.emit('error', err);
3837
- }
3838
- function errorOrDestroy(stream, err) {
3839
- // We have tests that rely on errors being emitted
3840
- // in the same tick, so changing this is semver major.
3841
- // For now when you opt-in to autoDestroy we allow
3842
- // the error to be emitted nextTick. In a future
3843
- // semver major update we should change the default to this.
3844
-
3845
- var rState = stream._readableState;
3846
- var wState = stream._writableState;
3847
- if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
3848
- }
3849
- destroy_1 = {
3850
- destroy: destroy,
3851
- undestroy: undestroy,
3852
- errorOrDestroy: errorOrDestroy
3853
- };
3854
- return destroy_1;
3786
+ function emitErrorAndCloseNT(self, err) {
3787
+ emitErrorNT(self, err);
3788
+ emitCloseNT(self);
3789
+ }
3790
+ function emitCloseNT(self) {
3791
+ if (self._writableState && !self._writableState.emitClose) return;
3792
+ if (self._readableState && !self._readableState.emitClose) return;
3793
+ self.emit('close');
3794
+ }
3795
+ function undestroy() {
3796
+ if (this._readableState) {
3797
+ this._readableState.destroyed = false;
3798
+ this._readableState.reading = false;
3799
+ this._readableState.ended = false;
3800
+ this._readableState.endEmitted = false;
3801
+ }
3802
+ if (this._writableState) {
3803
+ this._writableState.destroyed = false;
3804
+ this._writableState.ended = false;
3805
+ this._writableState.ending = false;
3806
+ this._writableState.finalCalled = false;
3807
+ this._writableState.prefinished = false;
3808
+ this._writableState.finished = false;
3809
+ this._writableState.errorEmitted = false;
3810
+ }
3811
+ }
3812
+ function emitErrorNT(self, err) {
3813
+ self.emit('error', err);
3814
+ }
3815
+ function errorOrDestroy(stream, err) {
3816
+ // We have tests that rely on errors being emitted
3817
+ // in the same tick, so changing this is semver major.
3818
+ // For now when you opt-in to autoDestroy we allow
3819
+ // the error to be emitted nextTick. In a future
3820
+ // semver major update we should change the default to this.
3821
+
3822
+ var rState = stream._readableState;
3823
+ var wState = stream._writableState;
3824
+ if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
3855
3825
  }
3826
+ var destroy_1 = {
3827
+ destroy: destroy,
3828
+ undestroy: undestroy,
3829
+ errorOrDestroy: errorOrDestroy
3830
+ };
3856
3831
 
3857
3832
  var errors = {};
3858
3833
 
3859
- var hasRequiredErrors;
3860
-
3861
- function requireErrors () {
3862
- if (hasRequiredErrors) return errors;
3863
- hasRequiredErrors = 1;
3864
-
3865
- const codes = {};
3834
+ const codes = {};
3866
3835
 
3867
- function createErrorType(code, message, Base) {
3868
- if (!Base) {
3869
- Base = Error;
3870
- }
3871
-
3872
- function getMessage (arg1, arg2, arg3) {
3873
- if (typeof message === 'string') {
3874
- return message
3875
- } else {
3876
- return message(arg1, arg2, arg3)
3877
- }
3878
- }
3879
-
3880
- class NodeError extends Base {
3881
- constructor (arg1, arg2, arg3) {
3882
- super(getMessage(arg1, arg2, arg3));
3883
- }
3884
- }
3836
+ function createErrorType(code, message, Base) {
3837
+ if (!Base) {
3838
+ Base = Error;
3839
+ }
3885
3840
 
3886
- NodeError.prototype.name = Base.name;
3887
- NodeError.prototype.code = code;
3841
+ function getMessage (arg1, arg2, arg3) {
3842
+ if (typeof message === 'string') {
3843
+ return message
3844
+ } else {
3845
+ return message(arg1, arg2, arg3)
3846
+ }
3847
+ }
3888
3848
 
3889
- codes[code] = NodeError;
3890
- }
3849
+ class NodeError extends Base {
3850
+ constructor (arg1, arg2, arg3) {
3851
+ super(getMessage(arg1, arg2, arg3));
3852
+ }
3853
+ }
3891
3854
 
3892
- // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
3893
- function oneOf(expected, thing) {
3894
- if (Array.isArray(expected)) {
3895
- const len = expected.length;
3896
- expected = expected.map((i) => String(i));
3897
- if (len > 2) {
3898
- return `one of ${thing} ${expected.slice(0, len - 1).join(', ')}, or ` +
3899
- expected[len - 1];
3900
- } else if (len === 2) {
3901
- return `one of ${thing} ${expected[0]} or ${expected[1]}`;
3902
- } else {
3903
- return `of ${thing} ${expected[0]}`;
3904
- }
3905
- } else {
3906
- return `of ${thing} ${String(expected)}`;
3907
- }
3908
- }
3855
+ NodeError.prototype.name = Base.name;
3856
+ NodeError.prototype.code = code;
3909
3857
 
3910
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
3911
- function startsWith(str, search, pos) {
3912
- return str.substr(0 , search.length) === search;
3913
- }
3858
+ codes[code] = NodeError;
3859
+ }
3914
3860
 
3915
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
3916
- function endsWith(str, search, this_len) {
3917
- if (this_len === undefined || this_len > str.length) {
3918
- this_len = str.length;
3919
- }
3920
- return str.substring(this_len - search.length, this_len) === search;
3921
- }
3861
+ // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
3862
+ function oneOf(expected, thing) {
3863
+ if (Array.isArray(expected)) {
3864
+ const len = expected.length;
3865
+ expected = expected.map((i) => String(i));
3866
+ if (len > 2) {
3867
+ return `one of ${thing} ${expected.slice(0, len - 1).join(', ')}, or ` +
3868
+ expected[len - 1];
3869
+ } else if (len === 2) {
3870
+ return `one of ${thing} ${expected[0]} or ${expected[1]}`;
3871
+ } else {
3872
+ return `of ${thing} ${expected[0]}`;
3873
+ }
3874
+ } else {
3875
+ return `of ${thing} ${String(expected)}`;
3876
+ }
3877
+ }
3922
3878
 
3923
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
3924
- function includes(str, search, start) {
3925
- if (typeof start !== 'number') {
3926
- start = 0;
3927
- }
3879
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
3880
+ function startsWith(str, search, pos) {
3881
+ return str.substr(0 , search.length) === search;
3882
+ }
3928
3883
 
3929
- if (start + search.length > str.length) {
3930
- return false;
3931
- } else {
3932
- return str.indexOf(search, start) !== -1;
3933
- }
3884
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
3885
+ function endsWith(str, search, this_len) {
3886
+ if (this_len === undefined || this_len > str.length) {
3887
+ this_len = str.length;
3934
3888
  }
3889
+ return str.substring(this_len - search.length, this_len) === search;
3890
+ }
3935
3891
 
3936
- createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {
3937
- return 'The value "' + value + '" is invalid for option "' + name + '"'
3938
- }, TypeError);
3939
- createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {
3940
- // determiner: 'must be' or 'must not be'
3941
- let determiner;
3942
- if (typeof expected === 'string' && startsWith(expected, 'not ')) {
3943
- determiner = 'must not be';
3944
- expected = expected.replace(/^not /, '');
3945
- } else {
3946
- determiner = 'must be';
3947
- }
3948
-
3949
- let msg;
3950
- if (endsWith(name, ' argument')) {
3951
- // For cases like 'first argument'
3952
- msg = `The ${name} ${determiner} ${oneOf(expected, 'type')}`;
3953
- } else {
3954
- const type = includes(name, '.') ? 'property' : 'argument';
3955
- msg = `The "${name}" ${type} ${determiner} ${oneOf(expected, 'type')}`;
3956
- }
3892
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
3893
+ function includes(str, search, start) {
3894
+ if (typeof start !== 'number') {
3895
+ start = 0;
3896
+ }
3957
3897
 
3958
- msg += `. Received type ${typeof actual}`;
3959
- return msg;
3960
- }, TypeError);
3961
- createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');
3962
- createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {
3963
- return 'The ' + name + ' method is not implemented'
3964
- });
3965
- createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close');
3966
- createErrorType('ERR_STREAM_DESTROYED', function (name) {
3967
- return 'Cannot call ' + name + ' after a stream was destroyed';
3968
- });
3969
- createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');
3970
- createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');
3971
- createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end');
3972
- createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError);
3973
- createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
3974
- return 'Unknown encoding: ' + arg
3975
- }, TypeError);
3976
- createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
3977
-
3978
- errors.codes = codes;
3979
- return errors;
3898
+ if (start + search.length > str.length) {
3899
+ return false;
3900
+ } else {
3901
+ return str.indexOf(search, start) !== -1;
3902
+ }
3980
3903
  }
3981
3904
 
3982
- var state;
3983
- var hasRequiredState;
3905
+ createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {
3906
+ return 'The value "' + value + '" is invalid for option "' + name + '"'
3907
+ }, TypeError);
3908
+ createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {
3909
+ // determiner: 'must be' or 'must not be'
3910
+ let determiner;
3911
+ if (typeof expected === 'string' && startsWith(expected, 'not ')) {
3912
+ determiner = 'must not be';
3913
+ expected = expected.replace(/^not /, '');
3914
+ } else {
3915
+ determiner = 'must be';
3916
+ }
3984
3917
 
3985
- function requireState () {
3986
- if (hasRequiredState) return state;
3987
- hasRequiredState = 1;
3918
+ let msg;
3919
+ if (endsWith(name, ' argument')) {
3920
+ // For cases like 'first argument'
3921
+ msg = `The ${name} ${determiner} ${oneOf(expected, 'type')}`;
3922
+ } else {
3923
+ const type = includes(name, '.') ? 'property' : 'argument';
3924
+ msg = `The "${name}" ${type} ${determiner} ${oneOf(expected, 'type')}`;
3925
+ }
3988
3926
 
3989
- var ERR_INVALID_OPT_VALUE = requireErrors().codes.ERR_INVALID_OPT_VALUE;
3990
- function highWaterMarkFrom(options, isDuplex, duplexKey) {
3991
- return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
3992
- }
3993
- function getHighWaterMark(state, options, duplexKey, isDuplex) {
3994
- var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
3995
- if (hwm != null) {
3996
- if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
3997
- var name = isDuplex ? duplexKey : 'highWaterMark';
3998
- throw new ERR_INVALID_OPT_VALUE(name, hwm);
3999
- }
4000
- return Math.floor(hwm);
4001
- }
3927
+ msg += `. Received type ${typeof actual}`;
3928
+ return msg;
3929
+ }, TypeError);
3930
+ createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');
3931
+ createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {
3932
+ return 'The ' + name + ' method is not implemented'
3933
+ });
3934
+ createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close');
3935
+ createErrorType('ERR_STREAM_DESTROYED', function (name) {
3936
+ return 'Cannot call ' + name + ' after a stream was destroyed';
3937
+ });
3938
+ createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');
3939
+ createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');
3940
+ createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end');
3941
+ createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError);
3942
+ createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
3943
+ return 'Unknown encoding: ' + arg
3944
+ }, TypeError);
3945
+ createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
3946
+
3947
+ errors.codes = codes;
3948
+
3949
+ var ERR_INVALID_OPT_VALUE = errors.codes.ERR_INVALID_OPT_VALUE;
3950
+ function highWaterMarkFrom(options, isDuplex, duplexKey) {
3951
+ return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
3952
+ }
3953
+ function getHighWaterMark(state, options, duplexKey, isDuplex) {
3954
+ var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
3955
+ if (hwm != null) {
3956
+ if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
3957
+ var name = isDuplex ? duplexKey : 'highWaterMark';
3958
+ throw new ERR_INVALID_OPT_VALUE(name, hwm);
3959
+ }
3960
+ return Math.floor(hwm);
3961
+ }
4002
3962
 
4003
- // Default value
4004
- return state.objectMode ? 16 : 16 * 1024;
4005
- }
4006
- state = {
4007
- getHighWaterMark: getHighWaterMark
4008
- };
4009
- return state;
3963
+ // Default value
3964
+ return state.objectMode ? 16 : 16 * 1024;
4010
3965
  }
3966
+ var state = {
3967
+ getHighWaterMark: getHighWaterMark
3968
+ };
4011
3969
 
4012
3970
  var inherits = {exports: {}};
4013
3971
 
@@ -4048,23 +4006,18 @@ function requireInherits_browser () {
4048
4006
  return inherits_browser.exports;
4049
4007
  }
4050
4008
 
4051
- var hasRequiredInherits;
4052
-
4053
- function requireInherits () {
4054
- if (hasRequiredInherits) return inherits.exports;
4055
- hasRequiredInherits = 1;
4056
- try {
4057
- var util = require('util');
4058
- /* istanbul ignore next */
4059
- if (typeof util.inherits !== 'function') throw '';
4060
- inherits.exports = util.inherits;
4061
- } catch (e) {
4062
- /* istanbul ignore next */
4063
- inherits.exports = requireInherits_browser();
4064
- }
4065
- return inherits.exports;
4009
+ try {
4010
+ var util$2 = require('util');
4011
+ /* istanbul ignore next */
4012
+ if (typeof util$2.inherits !== 'function') throw '';
4013
+ inherits.exports = util$2.inherits;
4014
+ } catch (e) {
4015
+ /* istanbul ignore next */
4016
+ inherits.exports = requireInherits_browser();
4066
4017
  }
4067
4018
 
4019
+ var inheritsExports = inherits.exports;
4020
+
4068
4021
  var buffer_list;
4069
4022
  var hasRequiredBuffer_list;
4070
4023
 
@@ -4624,7 +4577,7 @@ function requireEndOfStream () {
4624
4577
  if (hasRequiredEndOfStream) return endOfStream;
4625
4578
  hasRequiredEndOfStream = 1;
4626
4579
 
4627
- var ERR_STREAM_PREMATURE_CLOSE = requireErrors().codes.ERR_STREAM_PREMATURE_CLOSE;
4580
+ var ERR_STREAM_PREMATURE_CLOSE = errors.codes.ERR_STREAM_PREMATURE_CLOSE;
4628
4581
  function once(callback) {
4629
4582
  var called = false;
4630
4583
  return function () {
@@ -4910,7 +4863,7 @@ function requireFrom () {
4910
4863
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4911
4864
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
4912
4865
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
4913
- var ERR_INVALID_ARG_TYPE = requireErrors().codes.ERR_INVALID_ARG_TYPE;
4866
+ var ERR_INVALID_ARG_TYPE = errors.codes.ERR_INVALID_ARG_TYPE;
4914
4867
  function from(Readable, iterable, opts) {
4915
4868
  var iterator;
4916
4869
  if (iterable && typeof iterable.next === 'function') {
@@ -4979,7 +4932,7 @@ function require_stream_readable () {
4979
4932
  /*</replacement>*/
4980
4933
 
4981
4934
  /*<replacement>*/
4982
- var Stream = requireStream$1();
4935
+ var Stream = stream$1;
4983
4936
  /*</replacement>*/
4984
4937
 
4985
4938
  var Buffer = require$$0$4.Buffer;
@@ -5002,10 +4955,10 @@ function require_stream_readable () {
5002
4955
  /*</replacement>*/
5003
4956
 
5004
4957
  var BufferList = requireBuffer_list();
5005
- var destroyImpl = requireDestroy();
5006
- var _require = requireState(),
4958
+ var destroyImpl = destroy_1;
4959
+ var _require = state,
5007
4960
  getHighWaterMark = _require.getHighWaterMark;
5008
- var _require$codes = requireErrors().codes,
4961
+ var _require$codes = errors.codes,
5009
4962
  ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
5010
4963
  ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF,
5011
4964
  ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
@@ -5015,7 +4968,7 @@ function require_stream_readable () {
5015
4968
  var StringDecoder;
5016
4969
  var createReadableStreamAsyncIterator;
5017
4970
  var from;
5018
- requireInherits()(Readable, Stream);
4971
+ inheritsExports(Readable, Stream);
5019
4972
  var errorOrDestroy = destroyImpl.errorOrDestroy;
5020
4973
  var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
5021
4974
  function prependListener(emitter, event, fn) {
@@ -5988,7 +5941,7 @@ function require_stream_duplex () {
5988
5941
  _stream_duplex = Duplex;
5989
5942
  var Readable = require_stream_readable();
5990
5943
  var Writable = require_stream_writable();
5991
- requireInherits()(Duplex, Readable);
5944
+ inheritsExports(Duplex, Readable);
5992
5945
  {
5993
5946
  // Allow the keys array to be GC'ed.
5994
5947
  var keys = objectKeys(Writable.prototype);
@@ -6107,12 +6060,12 @@ function require_stream_writable () {
6107
6060
 
6108
6061
  /*<replacement>*/
6109
6062
  var internalUtil = {
6110
- deprecate: requireNode()
6063
+ deprecate: node$1
6111
6064
  };
6112
6065
  /*</replacement>*/
6113
6066
 
6114
6067
  /*<replacement>*/
6115
- var Stream = requireStream$1();
6068
+ var Stream = stream$1;
6116
6069
  /*</replacement>*/
6117
6070
 
6118
6071
  var Buffer = require$$0$4.Buffer;
@@ -6123,10 +6076,10 @@ function require_stream_writable () {
6123
6076
  function _isUint8Array(obj) {
6124
6077
  return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
6125
6078
  }
6126
- var destroyImpl = requireDestroy();
6127
- var _require = requireState(),
6079
+ var destroyImpl = destroy_1;
6080
+ var _require = state,
6128
6081
  getHighWaterMark = _require.getHighWaterMark;
6129
- var _require$codes = requireErrors().codes,
6082
+ var _require$codes = errors.codes,
6130
6083
  ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
6131
6084
  ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
6132
6085
  ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
@@ -6136,7 +6089,7 @@ function require_stream_writable () {
6136
6089
  ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END,
6137
6090
  ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING;
6138
6091
  var errorOrDestroy = destroyImpl.errorOrDestroy;
6139
- requireInherits()(Writable, Stream);
6092
+ inheritsExports(Writable, Stream);
6140
6093
  function nop() {}
6141
6094
  function WritableState(options, stream, isDuplex) {
6142
6095
  Duplex = Duplex || require_stream_duplex();
@@ -8112,13 +8065,13 @@ function require_stream_transform () {
8112
8065
  hasRequired_stream_transform = 1;
8113
8066
 
8114
8067
  _stream_transform = Transform;
8115
- var _require$codes = requireErrors().codes,
8068
+ var _require$codes = errors.codes,
8116
8069
  ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
8117
8070
  ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
8118
8071
  ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING,
8119
8072
  ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0;
8120
8073
  var Duplex = require_stream_duplex();
8121
- requireInherits()(Transform, Duplex);
8074
+ inheritsExports(Transform, Duplex);
8122
8075
  function afterTransform(er, data) {
8123
8076
  var ts = this._transformState;
8124
8077
  ts.transforming = false;
@@ -8248,7 +8201,7 @@ function require_stream_passthrough () {
8248
8201
 
8249
8202
  _stream_passthrough = PassThrough;
8250
8203
  var Transform = require_stream_transform();
8251
- requireInherits()(PassThrough, Transform);
8204
+ inheritsExports(PassThrough, Transform);
8252
8205
  function PassThrough(options) {
8253
8206
  if (!(this instanceof PassThrough)) return new PassThrough(options);
8254
8207
  Transform.call(this, options);
@@ -8275,7 +8228,7 @@ function requirePipeline () {
8275
8228
  callback.apply(void 0, arguments);
8276
8229
  };
8277
8230
  }
8278
- var _require$codes = requireErrors().codes,
8231
+ var _require$codes = errors.codes,
8279
8232
  ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS,
8280
8233
  ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;
8281
8234
  function noop(err) {
@@ -14911,6 +14864,14 @@ function formatLogLine({ emoji, timestamp, functionName, message, details, file,
14911
14864
  return line;
14912
14865
  }
14913
14866
 
14867
+ var LogMode;
14868
+ (function (LogMode) {
14869
+ LogMode["FULL"] = "full";
14870
+ LogMode["CONSOLE"] = "console";
14871
+ LogMode["COUNT"] = "count";
14872
+ LogMode["OFF"] = "off";
14873
+ })(LogMode || (LogMode = {}));
14874
+
14914
14875
  const seen = new Map();
14915
14876
  function hash(str) {
14916
14877
  let h = 0;
@@ -14978,7 +14939,7 @@ function shouldLog(opts, caller) {
14978
14939
  return true;
14979
14940
  }
14980
14941
 
14981
- function getLogString(messageOrOptions, logType = null, details = null, function_name = null, file_location = null, consumerLogger = null) {
14942
+ function logit(messageOrOptions, logType = null, details = null, function_name = null, file_location = null, consumerLogger = null) {
14982
14943
  /* -------------------------------------------------- */
14983
14944
  /* Normalize inputs */
14984
14945
  /* -------------------------------------------------- */
@@ -14996,7 +14957,7 @@ function getLogString(messageOrOptions, logType = null, details = null, function
14996
14957
  /* -------------------------------------------------- */
14997
14958
  /* Caller info */
14998
14959
  /* -------------------------------------------------- */
14999
- const caller = getCallerInfo(getLogString);
14960
+ const caller = getCallerInfo(logit);
15000
14961
  /* -------------------------------------------------- */
15001
14962
  /* 🔒 Single source of truth for logType */
15002
14963
  /* -------------------------------------------------- */
@@ -15046,6 +15007,136 @@ function getLogString(messageOrOptions, logType = null, details = null, function
15046
15007
  }), finalLogType, resolvedLoggerInput);
15047
15008
  }
15048
15009
 
15010
+ let mode = LogMode.COUNT; // 🔒 DEFAULT FASTEST
15011
+ const LATENCY_BUCKETS = [1000n, 10000n, 100000n, 1000000n];
15012
+ const stats = {
15013
+ calls: 0,
15014
+ totalNs: 0n,
15015
+ byMode: {},
15016
+ byType: {},
15017
+ byFunction: {},
15018
+ latency: {
15019
+ buckets: LATENCY_BUCKETS.map(Number),
15020
+ counts: new Array(LATENCY_BUCKETS.length + 1).fill(0),
15021
+ },
15022
+ };
15023
+ function inc(map, key) {
15024
+ if (!key)
15025
+ return;
15026
+ map[key] = (map[key] ?? 0) + 1;
15027
+ }
15028
+ function recordLatency(ns) {
15029
+ let i = 0;
15030
+ while (i < LATENCY_BUCKETS.length && ns > LATENCY_BUCKETS[i])
15031
+ i++;
15032
+ stats.latency.counts[i]++;
15033
+ }
15034
+ /* ---------------------------------- */
15035
+ /* Mode control (LOCKED) */
15036
+ /* ---------------------------------- */
15037
+ function setLogMode(next) {
15038
+ mode = next;
15039
+ }
15040
+ function getLogMode() {
15041
+ return mode;
15042
+ }
15043
+ /* ---------------------------------- */
15044
+ /* Stats */
15045
+ /* ---------------------------------- */
15046
+ function getLogStats() {
15047
+ return {
15048
+ calls: stats.calls,
15049
+ avgNs: stats.calls === 0
15050
+ ? 0
15051
+ : Number(stats.totalNs / BigInt(stats.calls)),
15052
+ byMode: stats.byMode,
15053
+ byType: stats.byType,
15054
+ byFunction: stats.byFunction,
15055
+ latency: stats.latency,
15056
+ };
15057
+ }
15058
+ function resetLogStats() {
15059
+ stats.calls = 0;
15060
+ stats.totalNs = 0n;
15061
+ stats.byMode = {};
15062
+ stats.byType = {};
15063
+ stats.byFunction = {};
15064
+ stats.latency.counts.fill(0);
15065
+ }
15066
+ /* ---------------------------------- */
15067
+ /* Unified logging entry point */
15068
+ /* ---------------------------------- */
15069
+ function logEvent(props) {
15070
+ stats.calls++;
15071
+ // 🔥 OFF = absolute fastest
15072
+ if (mode === LogMode.OFF)
15073
+ return;
15074
+ const type = typeof props?.logType === "string" ? props.logType : "info";
15075
+ inc(stats.byMode, mode);
15076
+ inc(stats.byType, type);
15077
+ inc(stats.byFunction, props?.function_name);
15078
+ // ⚡ COUNT = no timers, no I/O
15079
+ if (mode === LogMode.COUNT)
15080
+ return;
15081
+ const start = process.hrtime.bigint();
15082
+ if (mode === LogMode.FULL) {
15083
+ logit(props);
15084
+ }
15085
+ else if (mode === LogMode.CONSOLE) {
15086
+ console.log(props);
15087
+ }
15088
+ const elapsed = process.hrtime.bigint() - start;
15089
+ stats.totalNs += elapsed;
15090
+ recordLatency(elapsed);
15091
+ }
15092
+ function setLogs(mode = null, interval = false, window_ms = null) {
15093
+ const modes = [
15094
+ LogMode.FULL,
15095
+ LogMode.CONSOLE,
15096
+ LogMode.COUNT,
15097
+ LogMode.OFF,
15098
+ ];
15099
+ if (window_ms != false) {
15100
+ if (window_ms === true || window_ms == null) {
15101
+ window_ms = 30000;
15102
+ }
15103
+ }
15104
+ if (interval != true) {
15105
+ mode = mode || 3;
15106
+ setLogMode(modes[mode]);
15107
+ resetLogStats();
15108
+ }
15109
+ else {
15110
+ let i = 0;
15111
+ setInterval(() => {
15112
+ window_ms || (window_ms = 30000);
15113
+ recordBenchSnapshot(window_ms);
15114
+ resetLogStats();
15115
+ setLogMode(modes[++i % modes.length]);
15116
+ }, window_ms);
15117
+ }
15118
+ }
15119
+
15120
+ const LOG_DIR = process.env.LOG_BENCH_DIR ??
15121
+ path.resolve(process.cwd(), "log-bench");
15122
+ const FILE = path.join(LOG_DIR, "bench.ndjson");
15123
+ fs.mkdirSync(LOG_DIR, { recursive: true });
15124
+ function recordBenchSnapshot(windowMs) {
15125
+ const stats = getLogStats();
15126
+ const record = {
15127
+ ts: new Date().toISOString(),
15128
+ windowMs,
15129
+ mode: getLogMode(),
15130
+ calls: stats.calls,
15131
+ avgNs: stats.avgNs,
15132
+ byMode: stats.byMode,
15133
+ byType: stats.byType,
15134
+ byFunction: stats.byFunction,
15135
+ latency: stats.latency,
15136
+ };
15137
+ fs.appendFileSync(FILE, JSON.stringify(record) + "\n");
15138
+ }
15139
+
15049
15140
  exports.COLS = COLS;
15050
15141
  exports.IS_BROWSER = IS_BROWSER;
15051
15142
  exports.IS_NODE = IS_NODE;
@@ -15058,15 +15149,16 @@ exports.formatLogLine = formatLogLine;
15058
15149
  exports.getCallerInfo = getCallerInfo;
15059
15150
  exports.getFinalLine = getFinalLine;
15060
15151
  exports.getLogConfig = getLogConfig;
15061
- exports.getLogString = getLogString;
15152
+ exports.getLogString = logEvent;
15062
15153
  exports.getNodeLogger = getNodeLogger;
15063
15154
  exports.logger = logger;
15064
15155
  exports.padLeft = padLeft;
15065
15156
  exports.padRight = padRight;
15066
- exports.parseList = parseList$1;
15157
+ exports.parseList = parseList;
15067
15158
  exports.resolveLogger = resolveLogger;
15068
15159
  exports.resolveValue = resolveValue;
15069
15160
  exports.serializeDetails = serializeDetails;
15161
+ exports.setLogs = setLogs;
15070
15162
  exports.shouldCondense = shouldCondense;
15071
15163
  exports.shouldShowDetails = shouldShowDetails;
15072
15164
  exports.transports = winston.transports;