infront-logger 1.1.19 → 1.1.20

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.es.js CHANGED
@@ -99,11 +99,37 @@ function createTransport(options) {
99
99
  }
100
100
  return new transports.DailyRotateFile(options);
101
101
  }
102
+ const loggerCache = /* @__PURE__ */ new Map();
103
+ function transportCacheKey(o) {
104
+ return JSON.stringify({
105
+ dirname: o.dirname,
106
+ filename: o.filename,
107
+ errorFilename: o.errorFilename,
108
+ level: o.level,
109
+ levels: o.levels,
110
+ maxFiles: o.maxFiles,
111
+ maxFileSize: o.maxFileSize,
112
+ zippedArchive: o.zippedArchive,
113
+ dateFormat: o.dateFormat,
114
+ createSymlink: o.createSymlink,
115
+ symlinkName: o.symlinkName,
116
+ file: !!o.file,
117
+ console: !!o.console,
118
+ consoleJSON: !!o.consoleJSON,
119
+ http: o.http || null
120
+ });
121
+ }
102
122
  class Logger {
103
123
  constructor(options = {}) {
104
124
  this.options = { ...OPTIONS$1, ...options };
105
125
  if (!this.options.filename.includes(".")) this.options.filename += ".log";
106
126
  if (!this.options.errorFilename.includes(".")) this.options.errorFilename += ".log";
127
+ const cacheKey = transportCacheKey(this.options);
128
+ const cachedLogger = loggerCache.get(cacheKey);
129
+ if (cachedLogger) {
130
+ this.logger = cachedLogger;
131
+ return;
132
+ }
107
133
  let trans = [];
108
134
  let exceptionHandlers = [new transports.Console({
109
135
  format: getFormatter("console", this.options)
@@ -159,6 +185,7 @@ class Logger {
159
185
  transports: trans
160
186
  // exceptionHandlers
161
187
  });
188
+ loggerCache.set(cacheKey, this.logger);
162
189
  }
163
190
  }
164
191
  const redact$2 = (data, ...sensitiveKeysList) => {
package/dist/index.umd.js CHANGED
@@ -103,11 +103,37 @@
103
103
  }
104
104
  return new transports.DailyRotateFile(options);
105
105
  }
106
+ const loggerCache = /* @__PURE__ */ new Map();
107
+ function transportCacheKey(o) {
108
+ return JSON.stringify({
109
+ dirname: o.dirname,
110
+ filename: o.filename,
111
+ errorFilename: o.errorFilename,
112
+ level: o.level,
113
+ levels: o.levels,
114
+ maxFiles: o.maxFiles,
115
+ maxFileSize: o.maxFileSize,
116
+ zippedArchive: o.zippedArchive,
117
+ dateFormat: o.dateFormat,
118
+ createSymlink: o.createSymlink,
119
+ symlinkName: o.symlinkName,
120
+ file: !!o.file,
121
+ console: !!o.console,
122
+ consoleJSON: !!o.consoleJSON,
123
+ http: o.http || null
124
+ });
125
+ }
106
126
  class Logger {
107
127
  constructor(options = {}) {
108
128
  this.options = { ...OPTIONS$1, ...options };
109
129
  if (!this.options.filename.includes(".")) this.options.filename += ".log";
110
130
  if (!this.options.errorFilename.includes(".")) this.options.errorFilename += ".log";
131
+ const cacheKey = transportCacheKey(this.options);
132
+ const cachedLogger = loggerCache.get(cacheKey);
133
+ if (cachedLogger) {
134
+ this.logger = cachedLogger;
135
+ return;
136
+ }
111
137
  let trans = [];
112
138
  let exceptionHandlers = [new transports.Console({
113
139
  format: getFormatter("console", this.options)
@@ -163,6 +189,7 @@
163
189
  transports: trans
164
190
  // exceptionHandlers
165
191
  });
192
+ loggerCache.set(cacheKey, this.logger);
166
193
  }
167
194
  }
168
195
  const redact$2 = (data, ...sensitiveKeysList) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "infront-logger",
3
- "version": "1.1.19",
3
+ "version": "1.1.20",
4
4
  "description": "",
5
5
  "files": [
6
6
  "dist"