@workleap/logrocket 1.2.3 → 1.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @workleap/logrocket
2
2
 
3
+ ## 1.2.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#66](https://github.com/workleap/wl-telemetry/pull/66) [`6b79793`](https://github.com/workleap/wl-telemetry/commit/6b79793e26937f562f51193aedec1a7f57b1578c) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Bumped dependencies and LogRocketLogger refactor.
8
+
9
+ - Updated dependencies [[`6b79793`](https://github.com/workleap/wl-telemetry/commit/6b79793e26937f562f51193aedec1a7f57b1578c)]:
10
+ - @workleap/telemetry@1.1.5
11
+
3
12
  ## 1.2.3
4
13
 
5
14
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- import { type Logger, type LoggerOptions, type LoggerScope, type LoggerScopeEndOptions, LogLevel, type LogOptions } from "@workleap/logging";
1
+ import { type Logger, type LoggerOptions, type LoggerScope, type LoggerScopeEndOptions, LogLevel } from "@workleap/logging";
2
2
  /**
3
3
  * An scope implementation for the LogRocket logger.
4
4
  * @see {@link https://workleap.github.io/wl-telemetry}
@@ -12,7 +12,7 @@ export declare class LogRocketLoggerScope implements LoggerScope {
12
12
  /**
13
13
  * @see {@link https://workleap.github.io/wl-logging}
14
14
  */
15
- withText(text?: string, options?: LogOptions): this;
15
+ withText(text?: string): this;
16
16
  /**
17
17
  * @see {@link https://workleap.github.io/wl-logging}
18
18
  */
@@ -29,27 +29,27 @@ export declare class LogRocketLoggerScope implements LoggerScope {
29
29
  * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.
30
30
  * @see {@link https://workleap.github.io/wl-logging}
31
31
  */
32
- debug(log?: string, options?: LogOptions): void;
32
+ debug(log?: string): void;
33
33
  /**
34
34
  * Write an information log. The log will be processed only if the logger LogLevel is >= information.
35
35
  * @see {@link https://workleap.github.io/wl-logging}
36
36
  */
37
- information(log?: string, options?: LogOptions): void;
37
+ information(log?: string): void;
38
38
  /**
39
39
  * Write a warning log. The log will be processed only if the logger LogLevel is >= warning.
40
40
  * @see {@link https://workleap.github.io/wl-logging}
41
41
  */
42
- warning(log?: string, options?: LogOptions): void;
42
+ warning(log?: string): void;
43
43
  /**
44
44
  * Write an error log. The log will be processed only if the logger LogLevel is >= error.
45
45
  * @see {@link https://workleap.github.io/wl-logging}
46
46
  */
47
- error(log?: string, options?: LogOptions): void;
47
+ error(log?: string): void;
48
48
  /**
49
49
  * Write a critical log. The log will be processed only if the logger LogLevel is >= critical.
50
50
  * @see {@link https://workleap.github.io/wl-logging}
51
51
  */
52
- critical(log?: string, options?: LogOptions): void;
52
+ critical(log?: string): void;
53
53
  /**
54
54
  * @see {@link https://workleap.github.io/wl-logging}
55
55
  */
@@ -72,7 +72,7 @@ export declare class LogRocketLogger implements Logger {
72
72
  /**
73
73
  * @see {@link https://workleap.github.io/wl-logging}
74
74
  */
75
- withText(text?: string, options?: LogOptions): this;
75
+ withText(text?: string): this;
76
76
  /**
77
77
  * @see {@link https://workleap.github.io/wl-logging}
78
78
  */
@@ -89,27 +89,27 @@ export declare class LogRocketLogger implements Logger {
89
89
  * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.
90
90
  * @see {@link https://workleap.github.io/wl-logging}
91
91
  */
92
- debug(log?: string, options?: LogOptions): void;
92
+ debug(log?: string): void;
93
93
  /**
94
94
  * Write an information log. The log will be processed only if the logger LogLevel is >= information.
95
95
  * @see {@link https://workleap.github.io/wl-logging}
96
96
  */
97
- information(log?: string, options?: LogOptions): void;
97
+ information(log?: string): void;
98
98
  /**
99
99
  * Write a warning log. The log will be processed only if the logger LogLevel is >= warning.
100
100
  * @see {@link https://workleap.github.io/wl-logging}
101
101
  */
102
- warning(log?: string, options?: LogOptions): void;
102
+ warning(log?: string): void;
103
103
  /**
104
104
  * Write an error log. The log will be processed only if the logger LogLevel is >= error.
105
105
  * @see {@link https://workleap.github.io/wl-logging}
106
106
  */
107
- error(log?: string, options?: LogOptions): void;
107
+ error(log?: string): void;
108
108
  /**
109
109
  * Write a critical log. The log will be processed only if the logger LogLevel is >= critical.
110
110
  * @see {@link https://workleap.github.io/wl-logging}
111
111
  */
112
- critical(log?: string, options?: LogOptions): void;
112
+ critical(log?: string): void;
113
113
  /**
114
114
  * Start a new logging scope. The scope will inherit the LogLevel of the root logger.
115
115
  * @see {@link https://workleap.github.io/wl-logging}
@@ -8,20 +8,6 @@ import logrocket from "logrocket";
8
8
  ;// CONCATENATED MODULE: ./src/LogRocketLogger.ts
9
9
 
10
10
 
11
- function parseSegments(segments) {
12
- return segments.reduce((acc, x)=>{
13
- if (x.text) {
14
- acc.push(x.text);
15
- } else if (x.obj) {
16
- acc.push(x.obj);
17
- } else if (x.error) {
18
- acc.push(x.error);
19
- } else if (x.lineChange) {
20
- acc.push("\r\n");
21
- }
22
- return acc;
23
- }, []);
24
- }
25
11
  /**
26
12
  * An scope implementation for the LogRocket logger.
27
13
  * @see {@link https://workleap.github.io/wl-telemetry}
@@ -46,9 +32,9 @@ function parseSegments(segments) {
46
32
  // Required closure to preserved the current log items for when they will be formatted when the scope is ended.
47
33
  const segments = this.#segments;
48
34
  this.#pendingLogs.push(()=>{
49
- const parsedSegments = parseSegments(segments);
50
- parsedSegments.unshift(`(${this.#label})`);
51
- fct(...parsedSegments);
35
+ const values = segments.map((x)=>x.value);
36
+ values.unshift(`(${this.#label})`);
37
+ fct(...values);
52
38
  });
53
39
  }
54
40
  this.#resetSegments();
@@ -56,11 +42,11 @@ function parseSegments(segments) {
56
42
  }
57
43
  /**
58
44
  * @see {@link https://workleap.github.io/wl-logging}
59
- */ withText(text, options = {}) {
45
+ */ withText(text) {
60
46
  if (text) {
61
47
  this.#segments.push({
62
- text,
63
- options
48
+ type: "text",
49
+ value: text
64
50
  });
65
51
  }
66
52
  return this;
@@ -70,7 +56,8 @@ function parseSegments(segments) {
70
56
  */ withError(error) {
71
57
  if (error) {
72
58
  this.#segments.push({
73
- error
59
+ type: "error",
60
+ value: error
74
61
  });
75
62
  }
76
63
  return this;
@@ -80,7 +67,8 @@ function parseSegments(segments) {
80
67
  */ withObject(obj) {
81
68
  if (obj) {
82
69
  this.#segments.push({
83
- obj
70
+ type: "object",
71
+ value: obj
84
72
  });
85
73
  }
86
74
  return this;
@@ -89,18 +77,19 @@ function parseSegments(segments) {
89
77
  * @see {@link https://workleap.github.io/wl-logging}
90
78
  */ withLineChange() {
91
79
  this.#segments.push({
92
- lineChange: true
80
+ type: "line-change",
81
+ value: "\r\n"
93
82
  });
94
83
  return this;
95
84
  }
96
85
  /**
97
86
  * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.
98
87
  * @see {@link https://workleap.github.io/wl-logging}
99
- */ debug(log, options) {
88
+ */ debug(log) {
100
89
  if (log) {
101
90
  this.#segments.push({
102
- text: log,
103
- options
91
+ type: "text",
92
+ value: log
104
93
  });
105
94
  }
106
95
  this.#log(logrocket.log, LogLevel.debug);
@@ -108,11 +97,11 @@ function parseSegments(segments) {
108
97
  /**
109
98
  * Write an information log. The log will be processed only if the logger LogLevel is >= information.
110
99
  * @see {@link https://workleap.github.io/wl-logging}
111
- */ information(log, options) {
100
+ */ information(log) {
112
101
  if (log) {
113
102
  this.#segments.push({
114
- text: log,
115
- options
103
+ type: "text",
104
+ value: log
116
105
  });
117
106
  }
118
107
  this.#log(logrocket.log, LogLevel.information);
@@ -120,11 +109,11 @@ function parseSegments(segments) {
120
109
  /**
121
110
  * Write a warning log. The log will be processed only if the logger LogLevel is >= warning.
122
111
  * @see {@link https://workleap.github.io/wl-logging}
123
- */ warning(log, options) {
112
+ */ warning(log) {
124
113
  if (log) {
125
114
  this.#segments.push({
126
- text: log,
127
- options
115
+ type: "text",
116
+ value: log
128
117
  });
129
118
  }
130
119
  this.#log(logrocket.warn, LogLevel.warning);
@@ -132,11 +121,11 @@ function parseSegments(segments) {
132
121
  /**
133
122
  * Write an error log. The log will be processed only if the logger LogLevel is >= error.
134
123
  * @see {@link https://workleap.github.io/wl-logging}
135
- */ error(log, options) {
124
+ */ error(log) {
136
125
  if (log) {
137
126
  this.#segments.push({
138
- text: log,
139
- options
127
+ type: "text",
128
+ value: log
140
129
  });
141
130
  }
142
131
  this.#log(logrocket.error, LogLevel.error);
@@ -144,11 +133,11 @@ function parseSegments(segments) {
144
133
  /**
145
134
  * Write a critical log. The log will be processed only if the logger LogLevel is >= critical.
146
135
  * @see {@link https://workleap.github.io/wl-logging}
147
- */ critical(log, options) {
136
+ */ critical(log) {
148
137
  if (log) {
149
138
  this.#segments.push({
150
- text: log,
151
- options
139
+ type: "text",
140
+ value: log
152
141
  });
153
142
  }
154
143
  this.#log(logrocket.error, LogLevel.critical);
@@ -188,8 +177,8 @@ function parseSegments(segments) {
188
177
  #log(fct, threshold) {
189
178
  if (this.#segments.length > 0) {
190
179
  if (this.#logLevel <= threshold) {
191
- const parsedSegments = parseSegments(this.#segments);
192
- fct(...parsedSegments);
180
+ const values = this.#segments.map((x)=>x.value);
181
+ fct(...values);
193
182
  }
194
183
  this.#resetSegments();
195
184
  }
@@ -201,11 +190,11 @@ function parseSegments(segments) {
201
190
  }
202
191
  /**
203
192
  * @see {@link https://workleap.github.io/wl-logging}
204
- */ withText(text, options = {}) {
193
+ */ withText(text) {
205
194
  if (text) {
206
195
  this.#segments.push({
207
- text,
208
- options
196
+ type: "text",
197
+ value: text
209
198
  });
210
199
  }
211
200
  return this;
@@ -215,7 +204,8 @@ function parseSegments(segments) {
215
204
  */ withError(error) {
216
205
  if (error) {
217
206
  this.#segments.push({
218
- error
207
+ type: "error",
208
+ value: error
219
209
  });
220
210
  }
221
211
  return this;
@@ -225,7 +215,8 @@ function parseSegments(segments) {
225
215
  */ withObject(obj) {
226
216
  if (obj) {
227
217
  this.#segments.push({
228
- obj
218
+ type: "object",
219
+ value: obj
229
220
  });
230
221
  }
231
222
  return this;
@@ -234,18 +225,19 @@ function parseSegments(segments) {
234
225
  * @see {@link https://workleap.github.io/wl-logging}
235
226
  */ withLineChange() {
236
227
  this.#segments.push({
237
- lineChange: true
228
+ type: "line-change",
229
+ value: "\r\n"
238
230
  });
239
231
  return this;
240
232
  }
241
233
  /**
242
234
  * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.
243
235
  * @see {@link https://workleap.github.io/wl-logging}
244
- */ debug(log, options) {
236
+ */ debug(log) {
245
237
  if (log) {
246
238
  this.#segments.push({
247
- text: log,
248
- options
239
+ type: "text",
240
+ value: log
249
241
  });
250
242
  }
251
243
  this.#log(logrocket.log, LogLevel.debug);
@@ -253,11 +245,11 @@ function parseSegments(segments) {
253
245
  /**
254
246
  * Write an information log. The log will be processed only if the logger LogLevel is >= information.
255
247
  * @see {@link https://workleap.github.io/wl-logging}
256
- */ information(log, options) {
248
+ */ information(log) {
257
249
  if (log) {
258
250
  this.#segments.push({
259
- text: log,
260
- options
251
+ type: "text",
252
+ value: log
261
253
  });
262
254
  }
263
255
  this.#log(logrocket.log, LogLevel.information);
@@ -265,11 +257,11 @@ function parseSegments(segments) {
265
257
  /**
266
258
  * Write a warning log. The log will be processed only if the logger LogLevel is >= warning.
267
259
  * @see {@link https://workleap.github.io/wl-logging}
268
- */ warning(log, options) {
260
+ */ warning(log) {
269
261
  if (log) {
270
262
  this.#segments.push({
271
- text: log,
272
- options
263
+ type: "text",
264
+ value: log
273
265
  });
274
266
  }
275
267
  this.#log(logrocket.warn, LogLevel.warning);
@@ -277,11 +269,11 @@ function parseSegments(segments) {
277
269
  /**
278
270
  * Write an error log. The log will be processed only if the logger LogLevel is >= error.
279
271
  * @see {@link https://workleap.github.io/wl-logging}
280
- */ error(log, options) {
272
+ */ error(log) {
281
273
  if (log) {
282
274
  this.#segments.push({
283
- text: log,
284
- options
275
+ type: "text",
276
+ value: log
285
277
  });
286
278
  }
287
279
  this.#log(logrocket.error, LogLevel.error);
@@ -289,11 +281,11 @@ function parseSegments(segments) {
289
281
  /**
290
282
  * Write a critical log. The log will be processed only if the logger LogLevel is >= critical.
291
283
  * @see {@link https://workleap.github.io/wl-logging}
292
- */ critical(log, options) {
284
+ */ critical(log) {
293
285
  if (log) {
294
286
  this.#segments.push({
295
- text: log,
296
- options
287
+ type: "text",
288
+ value: log
297
289
  });
298
290
  }
299
291
  this.#log(logrocket.error, LogLevel.critical);
@@ -1 +1 @@
1
- {"version":3,"file":"LogRocketLogger.js","sources":["webpack://@workleap/logrocket/./src/LogRocketLogger.ts"],"sourcesContent":["import { type Logger, type LoggerOptions, type LoggerScope, type LoggerScopeEndOptions, LogLevel, type LogOptions, type Segment } from \"@workleap/logging\";\nimport LogRocket from \"logrocket\";\n\ntype LogFunction = (...rest: unknown[]) => void;\ntype PendingLog = () => void;\n\nfunction parseSegments(segments: Segment[]) {\n return segments.reduce<unknown[]>((acc, x) => {\n if (x.text) {\n acc.push(x.text);\n } else if (x.obj) {\n acc.push(x.obj);\n } else if (x.error) {\n acc.push(x.error);\n } else if (x.lineChange) {\n acc.push(\"\\r\\n\");\n }\n\n return acc;\n }, []);\n}\n\n/**\n * An scope implementation for the LogRocket logger.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport class LogRocketLoggerScope implements LoggerScope {\n readonly #logLevel: LogLevel;\n readonly #label: string;\n\n #segments: Segment[] = [];\n #pendingLogs: PendingLog[] = [];\n #hasEnded: boolean = false;\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n constructor(label: string, logLevel: LogLevel) {\n this.#logLevel = logLevel;\n this.#label = label;\n }\n\n #resetSegments() {\n this.#segments = [];\n }\n\n #log(fct: LogFunction, threshold: LogLevel) {\n if (this.#segments.length > 0) {\n if (this.#logLevel <= threshold) {\n // Required closure to preserved the current log items for when they will be formatted when the scope is ended.\n const segments = this.#segments;\n\n this.#pendingLogs.push(() => {\n const parsedSegments = parseSegments(segments);\n parsedSegments.unshift(`(${this.#label})`);\n\n fct(...parsedSegments);\n });\n }\n\n this.#resetSegments();\n }\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withText(text?: string, options: LogOptions = {}) {\n if (text) {\n this.#segments.push({\n text,\n options\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withError(error?: Error) {\n if (error) {\n this.#segments.push({\n error\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withObject(obj?: unknown) {\n if (obj) {\n this.#segments.push({\n obj\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withLineChange() {\n this.#segments.push({\n lineChange: true\n });\n\n return this;\n }\n\n /**\n * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n debug(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.log, LogLevel.debug);\n }\n\n /**\n * Write an information log. The log will be processed only if the logger LogLevel is >= information.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n information(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.log, LogLevel.information);\n }\n\n /**\n * Write a warning log. The log will be processed only if the logger LogLevel is >= warning.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n warning(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.warn, LogLevel.warning);\n }\n\n /**\n * Write an error log. The log will be processed only if the logger LogLevel is >= error.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n error(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.error, LogLevel.error);\n }\n\n /**\n * Write a critical log. The log will be processed only if the logger LogLevel is >= critical.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n critical(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.error, LogLevel.critical);\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n end(options: LoggerScopeEndOptions = {}) {\n const {\n dismiss = false\n } = options;\n\n if (!this.#hasEnded) {\n this.#hasEnded = true;\n\n if (!dismiss) {\n if (this.#pendingLogs.length > 0) {\n this.#pendingLogs.forEach(x => {\n x();\n });\n\n this.#pendingLogs = [];\n }\n }\n }\n }\n}\n\n/**\n * A logger implementation for LogRocket.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport class LogRocketLogger implements Logger {\n readonly #logLevel: LogLevel;\n #segments: Segment[] = [];\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n constructor(options: LoggerOptions = {}) {\n const {\n logLevel = LogLevel.debug\n } = options;\n\n this.#logLevel = logLevel;\n }\n\n #resetSegments() {\n this.#segments = [];\n }\n\n #log(fct: LogFunction, threshold: LogLevel) {\n if (this.#segments.length > 0) {\n if (this.#logLevel <= threshold) {\n const parsedSegments = parseSegments(this.#segments);\n\n fct(...parsedSegments);\n }\n\n this.#resetSegments();\n }\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n getName() {\n return LogRocketLogger.name;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withText(text?: string, options: LogOptions = {}) {\n if (text) {\n this.#segments.push({\n text,\n options\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withError(error?: Error) {\n if (error) {\n this.#segments.push({\n error\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withObject(obj?: unknown) {\n if (obj) {\n this.#segments.push({\n obj\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withLineChange() {\n this.#segments.push({\n lineChange: true\n });\n\n return this;\n }\n\n /**\n * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n debug(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.log, LogLevel.debug);\n }\n\n /**\n * Write an information log. The log will be processed only if the logger LogLevel is >= information.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n information(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.log, LogLevel.information);\n }\n\n /**\n * Write a warning log. The log will be processed only if the logger LogLevel is >= warning.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n warning(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.warn, LogLevel.warning);\n }\n\n /**\n * Write an error log. The log will be processed only if the logger LogLevel is >= error.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n error(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.error, LogLevel.error);\n }\n\n /**\n * Write a critical log. The log will be processed only if the logger LogLevel is >= critical.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n critical(log?: string, options?: LogOptions) {\n if (log) {\n this.#segments.push({\n text: log,\n options\n });\n }\n\n this.#log(LogRocket.error, LogLevel.critical);\n }\n\n /**\n * Start a new logging scope. The scope will inherit the LogLevel of the root logger.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n startScope(label: string) {\n return new LogRocketLoggerScope(label, this.#logLevel);\n }\n}\n"],"names":["LogLevel","LogRocket","parseSegments","segments","acc","x","LogRocketLoggerScope","label","logLevel","fct","threshold","parsedSegments","text","options","error","obj","log","dismiss","LogRocketLogger"],"mappings":";;;;;;;;AAA2J;AACzH;AAKlC,SAASE,cAAcC,QAAmB;IACtC,OAAOA,SAAS,MAAM,CAAY,CAACC,KAAKC;QACpC,IAAIA,EAAE,IAAI,EAAE;YACRD,IAAI,IAAI,CAACC,EAAE,IAAI;QACnB,OAAO,IAAIA,EAAE,GAAG,EAAE;YACdD,I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ACzC,IAAIG,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAMA;gBACNH;YACJ;QACJ;QAEA,IAAI,CAAC,IAAI,CAACZ,eAAe,EAAED,iBAAiB;IAChD;IAEA;;;KAGC,GACD,WAAWO,KAAa,EAAE;QACtB,OAAO,IAAID,qBAAqBC,OAAO,IAAI,CAAC,SAAS;IACzD;AACJ"}
1
+ {"version":3,"file":"LogRocketLogger.js","sources":["webpack://@workleap/logrocket/./src/LogRocketLogger.ts"],"sourcesContent":["import { type Logger, type LoggerOptions, type LoggerScope, type LoggerScopeEndOptions, LogLevel } from \"@workleap/logging\";\nimport LogRocket from \"logrocket\";\n\ninterface Segment {\n type: \"text\" | \"object\" | \"error\" | \"line-change\";\n value: unknown;\n}\n\ntype LogFunction = (...rest: unknown[]) => void;\ntype PendingLog = () => void;\n\n/**\n * An scope implementation for the LogRocket logger.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport class LogRocketLoggerScope implements LoggerScope {\n readonly #logLevel: LogLevel;\n readonly #label: string;\n\n #segments: Segment[] = [];\n #pendingLogs: PendingLog[] = [];\n #hasEnded: boolean = false;\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n constructor(label: string, logLevel: LogLevel) {\n this.#logLevel = logLevel;\n this.#label = label;\n }\n\n #resetSegments() {\n this.#segments = [];\n }\n\n #log(fct: LogFunction, threshold: LogLevel) {\n if (this.#segments.length > 0) {\n if (this.#logLevel <= threshold) {\n // Required closure to preserved the current log items for when they will be formatted when the scope is ended.\n const segments = this.#segments;\n\n this.#pendingLogs.push(() => {\n const values = segments.map(x => x.value);\n values.unshift(`(${this.#label})`);\n\n fct(...values);\n });\n }\n\n this.#resetSegments();\n }\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withText(text?: string) {\n if (text) {\n this.#segments.push({\n type: \"text\",\n value: text\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withError(error?: Error) {\n if (error) {\n this.#segments.push({\n type: \"error\",\n value: error\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withObject(obj?: unknown) {\n if (obj) {\n this.#segments.push({\n type: \"object\",\n value: obj\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withLineChange() {\n this.#segments.push({\n type: \"line-change\",\n value: \"\\r\\n\"\n });\n\n return this;\n }\n\n /**\n * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n debug(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.log, LogLevel.debug);\n }\n\n /**\n * Write an information log. The log will be processed only if the logger LogLevel is >= information.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n information(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.log, LogLevel.information);\n }\n\n /**\n * Write a warning log. The log will be processed only if the logger LogLevel is >= warning.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n warning(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.warn, LogLevel.warning);\n }\n\n /**\n * Write an error log. The log will be processed only if the logger LogLevel is >= error.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n error(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.error, LogLevel.error);\n }\n\n /**\n * Write a critical log. The log will be processed only if the logger LogLevel is >= critical.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n critical(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.error, LogLevel.critical);\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n end(options: LoggerScopeEndOptions = {}) {\n const {\n dismiss = false\n } = options;\n\n if (!this.#hasEnded) {\n this.#hasEnded = true;\n\n if (!dismiss) {\n if (this.#pendingLogs.length > 0) {\n this.#pendingLogs.forEach(x => {\n x();\n });\n\n this.#pendingLogs = [];\n }\n }\n }\n }\n}\n\n/**\n * A logger implementation for LogRocket.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport class LogRocketLogger implements Logger {\n readonly #logLevel: LogLevel;\n #segments: Segment[] = [];\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n constructor(options: LoggerOptions = {}) {\n const {\n logLevel = LogLevel.debug\n } = options;\n\n this.#logLevel = logLevel;\n }\n\n #resetSegments() {\n this.#segments = [];\n }\n\n #log(fct: LogFunction, threshold: LogLevel) {\n if (this.#segments.length > 0) {\n if (this.#logLevel <= threshold) {\n const values = this.#segments.map(x => x.value);\n\n fct(...values);\n }\n\n this.#resetSegments();\n }\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n getName() {\n return LogRocketLogger.name;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withText(text?: string) {\n if (text) {\n this.#segments.push({\n type: \"text\",\n value: text\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withError(error?: Error) {\n if (error) {\n this.#segments.push({\n type: \"error\",\n value: error\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withObject(obj?: unknown) {\n if (obj) {\n this.#segments.push({\n type: \"object\",\n value: obj\n });\n }\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withLineChange() {\n this.#segments.push({\n type: \"line-change\",\n value: \"\\r\\n\"\n });\n\n return this;\n }\n\n /**\n * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n debug(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.log, LogLevel.debug);\n }\n\n /**\n * Write an information log. The log will be processed only if the logger LogLevel is >= information.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n information(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.log, LogLevel.information);\n }\n\n /**\n * Write a warning log. The log will be processed only if the logger LogLevel is >= warning.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n warning(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.warn, LogLevel.warning);\n }\n\n /**\n * Write an error log. The log will be processed only if the logger LogLevel is >= error.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n error(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.error, LogLevel.error);\n }\n\n /**\n * Write a critical log. The log will be processed only if the logger LogLevel is >= critical.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n critical(log?: string) {\n if (log) {\n this.#segments.push({\n type: \"text\",\n value: log\n });\n }\n\n this.#log(LogRocket.error, LogLevel.critical);\n }\n\n /**\n * Start a new logging scope. The scope will inherit the LogLevel of the root logger.\n * @see {@link https://workleap.github.io/wl-logging}\n */\n startScope(label: string) {\n return new LogRocketLoggerScope(label, this.#logLevel);\n }\n}\n"],"names":["LogLevel","LogRocket","LogRocketLoggerScope","label","logLevel","fct","threshold","segments","values","x","text","error","obj","log","options","dismiss","LogRocketLogger"],"mappings":";;;;;;;;AAA4H;AAC1F;AAUlC;;;CAGC,GACM,MAAME;IACA,SAAS,CAAW;IACpB,MAAM,CAAS;IAExB,SAAS,GAAc,EAAE,CAAC;IAC1B,YAAY,GAAiB,EAAE,CAAC;IAChC,SAAS,GAAY,MAAM;IAE3B;;KAEC,GACD,YAAYC,KAAa,EAAEC,QAAkB,CAAE;QAC3C,IAAI,CAAC,SAAS,GAAGA;QACjB,IAAI,CAAC,MAAM,GAAGD;IAClB;IAEA,cAAc;QACV,IAAI,CAAC,SAA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CAAC;gBAChB,MAAM;gBACN,OAAOA;YACX;QACJ;QAEA,IAAI,CAAC,IAAI,CAACZ,aAAa,EAAED,cAAc;IAC3C;IAEA;;;KAGC,GACD,YAAYa,GAAY,EAAE;QACtB,IAAIA,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAM;gBACN,OAAOA;YACX;QACJ;QAEA,IAAI,CAAC,IAAI,CAACZ,aAAa,EAAED,oBAAoB;IACjD;IAEA;;;KAGC,GACD,QAAQa,GAAY,EAAE;QAClB,IAAIA,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAM;gBACN,OAAOA;YACX;QACJ;QAEA,IAAI,CAAC,IAAI,CAACZ,cAAc,EAAED,gBAAgB;IAC9C;IAEA;;;KAGC,GACD,MAAMa,GAAY,EAAE;QAChB,IAAIA,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAM;gBACN,OAAOA;YACX;QACJ;QAEA,IAAI,CAAC,IAAI,CAACZ,eAAe,EAAED,cAAc;IAC7C;IAEA;;;KAGC,GACD,SAASa,GAAY,EAAE;QACnB,IAAIA,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAM;gBACN,OAAOA;YACX;QACJ;QAEA,IAAI,CAAC,IAAI,CAACZ,eAAe,EAAED,iBAAiB;IAChD;IAEA;;;KAGC,GACD,WAAWG,KAAa,EAAE;QACtB,OAAO,IAAID,qBAAqBC,OAAO,IAAI,CAAC,SAAS;IACzD;AACJ"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@workleap/logrocket",
3
3
  "author": "Workleap",
4
- "version": "1.2.3",
4
+ "version": "1.2.4",
5
5
  "description": "A package containing utilities for LogRocket.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -31,9 +31,9 @@
31
31
  "logrocket": "^10.1.0"
32
32
  },
33
33
  "dependencies": {
34
- "@workleap/logging": "^1.2.2",
34
+ "@workleap/logging": "^1.2.3",
35
35
  "logrocket-fuzzy-search-sanitizer": "0.0.2",
36
- "@workleap/telemetry": "1.1.4"
36
+ "@workleap/telemetry": "1.1.5"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@rsbuild/core": "1.4.6",
@@ -1,25 +1,14 @@
1
- import { type Logger, type LoggerOptions, type LoggerScope, type LoggerScopeEndOptions, LogLevel, type LogOptions, type Segment } from "@workleap/logging";
1
+ import { type Logger, type LoggerOptions, type LoggerScope, type LoggerScopeEndOptions, LogLevel } from "@workleap/logging";
2
2
  import LogRocket from "logrocket";
3
3
 
4
+ interface Segment {
5
+ type: "text" | "object" | "error" | "line-change";
6
+ value: unknown;
7
+ }
8
+
4
9
  type LogFunction = (...rest: unknown[]) => void;
5
10
  type PendingLog = () => void;
6
11
 
7
- function parseSegments(segments: Segment[]) {
8
- return segments.reduce<unknown[]>((acc, x) => {
9
- if (x.text) {
10
- acc.push(x.text);
11
- } else if (x.obj) {
12
- acc.push(x.obj);
13
- } else if (x.error) {
14
- acc.push(x.error);
15
- } else if (x.lineChange) {
16
- acc.push("\r\n");
17
- }
18
-
19
- return acc;
20
- }, []);
21
- }
22
-
23
12
  /**
24
13
  * An scope implementation for the LogRocket logger.
25
14
  * @see {@link https://workleap.github.io/wl-telemetry}
@@ -51,10 +40,10 @@ export class LogRocketLoggerScope implements LoggerScope {
51
40
  const segments = this.#segments;
52
41
 
53
42
  this.#pendingLogs.push(() => {
54
- const parsedSegments = parseSegments(segments);
55
- parsedSegments.unshift(`(${this.#label})`);
43
+ const values = segments.map(x => x.value);
44
+ values.unshift(`(${this.#label})`);
56
45
 
57
- fct(...parsedSegments);
46
+ fct(...values);
58
47
  });
59
48
  }
60
49
 
@@ -65,11 +54,11 @@ export class LogRocketLoggerScope implements LoggerScope {
65
54
  /**
66
55
  * @see {@link https://workleap.github.io/wl-logging}
67
56
  */
68
- withText(text?: string, options: LogOptions = {}) {
57
+ withText(text?: string) {
69
58
  if (text) {
70
59
  this.#segments.push({
71
- text,
72
- options
60
+ type: "text",
61
+ value: text
73
62
  });
74
63
  }
75
64
 
@@ -82,7 +71,8 @@ export class LogRocketLoggerScope implements LoggerScope {
82
71
  withError(error?: Error) {
83
72
  if (error) {
84
73
  this.#segments.push({
85
- error
74
+ type: "error",
75
+ value: error
86
76
  });
87
77
  }
88
78
 
@@ -95,7 +85,8 @@ export class LogRocketLoggerScope implements LoggerScope {
95
85
  withObject(obj?: unknown) {
96
86
  if (obj) {
97
87
  this.#segments.push({
98
- obj
88
+ type: "object",
89
+ value: obj
99
90
  });
100
91
  }
101
92
 
@@ -107,7 +98,8 @@ export class LogRocketLoggerScope implements LoggerScope {
107
98
  */
108
99
  withLineChange() {
109
100
  this.#segments.push({
110
- lineChange: true
101
+ type: "line-change",
102
+ value: "\r\n"
111
103
  });
112
104
 
113
105
  return this;
@@ -117,11 +109,11 @@ export class LogRocketLoggerScope implements LoggerScope {
117
109
  * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.
118
110
  * @see {@link https://workleap.github.io/wl-logging}
119
111
  */
120
- debug(log?: string, options?: LogOptions) {
112
+ debug(log?: string) {
121
113
  if (log) {
122
114
  this.#segments.push({
123
- text: log,
124
- options
115
+ type: "text",
116
+ value: log
125
117
  });
126
118
  }
127
119
 
@@ -132,11 +124,11 @@ export class LogRocketLoggerScope implements LoggerScope {
132
124
  * Write an information log. The log will be processed only if the logger LogLevel is >= information.
133
125
  * @see {@link https://workleap.github.io/wl-logging}
134
126
  */
135
- information(log?: string, options?: LogOptions) {
127
+ information(log?: string) {
136
128
  if (log) {
137
129
  this.#segments.push({
138
- text: log,
139
- options
130
+ type: "text",
131
+ value: log
140
132
  });
141
133
  }
142
134
 
@@ -147,11 +139,11 @@ export class LogRocketLoggerScope implements LoggerScope {
147
139
  * Write a warning log. The log will be processed only if the logger LogLevel is >= warning.
148
140
  * @see {@link https://workleap.github.io/wl-logging}
149
141
  */
150
- warning(log?: string, options?: LogOptions) {
142
+ warning(log?: string) {
151
143
  if (log) {
152
144
  this.#segments.push({
153
- text: log,
154
- options
145
+ type: "text",
146
+ value: log
155
147
  });
156
148
  }
157
149
 
@@ -162,11 +154,11 @@ export class LogRocketLoggerScope implements LoggerScope {
162
154
  * Write an error log. The log will be processed only if the logger LogLevel is >= error.
163
155
  * @see {@link https://workleap.github.io/wl-logging}
164
156
  */
165
- error(log?: string, options?: LogOptions) {
157
+ error(log?: string) {
166
158
  if (log) {
167
159
  this.#segments.push({
168
- text: log,
169
- options
160
+ type: "text",
161
+ value: log
170
162
  });
171
163
  }
172
164
 
@@ -177,11 +169,11 @@ export class LogRocketLoggerScope implements LoggerScope {
177
169
  * Write a critical log. The log will be processed only if the logger LogLevel is >= critical.
178
170
  * @see {@link https://workleap.github.io/wl-logging}
179
171
  */
180
- critical(log?: string, options?: LogOptions) {
172
+ critical(log?: string) {
181
173
  if (log) {
182
174
  this.#segments.push({
183
- text: log,
184
- options
175
+ type: "text",
176
+ value: log
185
177
  });
186
178
  }
187
179
 
@@ -238,9 +230,9 @@ export class LogRocketLogger implements Logger {
238
230
  #log(fct: LogFunction, threshold: LogLevel) {
239
231
  if (this.#segments.length > 0) {
240
232
  if (this.#logLevel <= threshold) {
241
- const parsedSegments = parseSegments(this.#segments);
233
+ const values = this.#segments.map(x => x.value);
242
234
 
243
- fct(...parsedSegments);
235
+ fct(...values);
244
236
  }
245
237
 
246
238
  this.#resetSegments();
@@ -257,11 +249,11 @@ export class LogRocketLogger implements Logger {
257
249
  /**
258
250
  * @see {@link https://workleap.github.io/wl-logging}
259
251
  */
260
- withText(text?: string, options: LogOptions = {}) {
252
+ withText(text?: string) {
261
253
  if (text) {
262
254
  this.#segments.push({
263
- text,
264
- options
255
+ type: "text",
256
+ value: text
265
257
  });
266
258
  }
267
259
 
@@ -274,7 +266,8 @@ export class LogRocketLogger implements Logger {
274
266
  withError(error?: Error) {
275
267
  if (error) {
276
268
  this.#segments.push({
277
- error
269
+ type: "error",
270
+ value: error
278
271
  });
279
272
  }
280
273
 
@@ -287,7 +280,8 @@ export class LogRocketLogger implements Logger {
287
280
  withObject(obj?: unknown) {
288
281
  if (obj) {
289
282
  this.#segments.push({
290
- obj
283
+ type: "object",
284
+ value: obj
291
285
  });
292
286
  }
293
287
 
@@ -299,7 +293,8 @@ export class LogRocketLogger implements Logger {
299
293
  */
300
294
  withLineChange() {
301
295
  this.#segments.push({
302
- lineChange: true
296
+ type: "line-change",
297
+ value: "\r\n"
303
298
  });
304
299
 
305
300
  return this;
@@ -309,11 +304,11 @@ export class LogRocketLogger implements Logger {
309
304
  * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.
310
305
  * @see {@link https://workleap.github.io/wl-logging}
311
306
  */
312
- debug(log?: string, options?: LogOptions) {
307
+ debug(log?: string) {
313
308
  if (log) {
314
309
  this.#segments.push({
315
- text: log,
316
- options
310
+ type: "text",
311
+ value: log
317
312
  });
318
313
  }
319
314
 
@@ -324,11 +319,11 @@ export class LogRocketLogger implements Logger {
324
319
  * Write an information log. The log will be processed only if the logger LogLevel is >= information.
325
320
  * @see {@link https://workleap.github.io/wl-logging}
326
321
  */
327
- information(log?: string, options?: LogOptions) {
322
+ information(log?: string) {
328
323
  if (log) {
329
324
  this.#segments.push({
330
- text: log,
331
- options
325
+ type: "text",
326
+ value: log
332
327
  });
333
328
  }
334
329
 
@@ -339,11 +334,11 @@ export class LogRocketLogger implements Logger {
339
334
  * Write a warning log. The log will be processed only if the logger LogLevel is >= warning.
340
335
  * @see {@link https://workleap.github.io/wl-logging}
341
336
  */
342
- warning(log?: string, options?: LogOptions) {
337
+ warning(log?: string) {
343
338
  if (log) {
344
339
  this.#segments.push({
345
- text: log,
346
- options
340
+ type: "text",
341
+ value: log
347
342
  });
348
343
  }
349
344
 
@@ -354,11 +349,11 @@ export class LogRocketLogger implements Logger {
354
349
  * Write an error log. The log will be processed only if the logger LogLevel is >= error.
355
350
  * @see {@link https://workleap.github.io/wl-logging}
356
351
  */
357
- error(log?: string, options?: LogOptions) {
352
+ error(log?: string) {
358
353
  if (log) {
359
354
  this.#segments.push({
360
- text: log,
361
- options
355
+ type: "text",
356
+ value: log
362
357
  });
363
358
  }
364
359
 
@@ -369,11 +364,11 @@ export class LogRocketLogger implements Logger {
369
364
  * Write a critical log. The log will be processed only if the logger LogLevel is >= critical.
370
365
  * @see {@link https://workleap.github.io/wl-logging}
371
366
  */
372
- critical(log?: string, options?: LogOptions) {
367
+ critical(log?: string) {
373
368
  if (log) {
374
369
  this.#segments.push({
375
- text: log,
376
- options
370
+ type: "text",
371
+ value: log
377
372
  });
378
373
  }
379
374