@workleap/logrocket 1.1.0 → 1.2.1
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 +20 -0
- package/dist/LogRocketLogger.d.ts +15 -6
- package/dist/LogRocketLogger.js +47 -16
- package/dist/LogRocketLogger.js.map +1 -1
- package/package.json +3 -3
- package/src/LogRocketLogger.ts +59 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @workleap/logrocket
|
|
2
2
|
|
|
3
|
+
## 1.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#56](https://github.com/workleap/wl-telemetry/pull/56) [`7be6e06`](https://github.com/workleap/wl-telemetry/commit/7be6e06b0f1f42e549ff043dc9b68db91ceb8d15) Thanks [@patricklafrance](https://github.com/patricklafrance)! - LogRocket logger now supports optional segments.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`7be6e06`](https://github.com/workleap/wl-telemetry/commit/7be6e06b0f1f42e549ff043dc9b68db91ceb8d15)]:
|
|
10
|
+
- @workleap/telemetry@1.1.2
|
|
11
|
+
|
|
12
|
+
## 1.2.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- [#54](https://github.com/workleap/wl-telemetry/pull/54) [`79ce028`](https://github.com/workleap/wl-telemetry/commit/79ce028f2418cc43ed18017e82ce9599e97d0e40) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Added support for line change segments to the LogRocket logger.
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [[`79ce028`](https://github.com/workleap/wl-telemetry/commit/79ce028f2418cc43ed18017e82ce9599e97d0e40)]:
|
|
21
|
+
- @workleap/telemetry@1.1.1
|
|
22
|
+
|
|
3
23
|
## 1.1.0
|
|
4
24
|
|
|
5
25
|
### Minor Changes
|
|
@@ -12,15 +12,19 @@ export declare class LogRocketLoggerScope implements LoggerScope {
|
|
|
12
12
|
/**
|
|
13
13
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
14
14
|
*/
|
|
15
|
-
withText(text
|
|
15
|
+
withText(text?: string, options?: LogOptions): this;
|
|
16
16
|
/**
|
|
17
17
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
18
18
|
*/
|
|
19
|
-
withError(error
|
|
19
|
+
withError(error?: Error): this;
|
|
20
20
|
/**
|
|
21
21
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
22
22
|
*/
|
|
23
|
-
withObject(obj
|
|
23
|
+
withObject(obj?: object): this;
|
|
24
|
+
/**
|
|
25
|
+
* @see {@link https://workleap.github.io/wl-logging}
|
|
26
|
+
*/
|
|
27
|
+
withLineChange(): this;
|
|
24
28
|
/**
|
|
25
29
|
* Write a debug log. The log will be processed only if the logger LogLevel is >= debug.
|
|
26
30
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
@@ -68,15 +72,19 @@ export declare class LogRocketLogger implements Logger {
|
|
|
68
72
|
/**
|
|
69
73
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
70
74
|
*/
|
|
71
|
-
withText(text
|
|
75
|
+
withText(text?: string, options?: LogOptions): this;
|
|
76
|
+
/**
|
|
77
|
+
* @see {@link https://workleap.github.io/wl-logging}
|
|
78
|
+
*/
|
|
79
|
+
withError(error?: Error): this;
|
|
72
80
|
/**
|
|
73
81
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
74
82
|
*/
|
|
75
|
-
|
|
83
|
+
withObject(obj?: object): this;
|
|
76
84
|
/**
|
|
77
85
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
78
86
|
*/
|
|
79
|
-
|
|
87
|
+
withLineChange(): this;
|
|
80
88
|
/**
|
|
81
89
|
* Write a debug log. The log will be processed only if the logger LogLevel is >= debug.
|
|
82
90
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
@@ -103,6 +111,7 @@ export declare class LogRocketLogger implements Logger {
|
|
|
103
111
|
*/
|
|
104
112
|
critical(log?: string, options?: LogOptions): void;
|
|
105
113
|
/**
|
|
114
|
+
* Start a new logging scope. The scope will inherit the LogLevel of the root logger.
|
|
106
115
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
107
116
|
*/
|
|
108
117
|
startScope(label: string): LogRocketLoggerScope;
|
package/dist/LogRocketLogger.js
CHANGED
|
@@ -16,6 +16,8 @@ function parseSegments(segments) {
|
|
|
16
16
|
acc.push(x.obj);
|
|
17
17
|
} else if (x.error) {
|
|
18
18
|
acc.push(x.error);
|
|
19
|
+
} else if (x.lineChange) {
|
|
20
|
+
acc.push("\r\n");
|
|
19
21
|
}
|
|
20
22
|
return acc;
|
|
21
23
|
}, []);
|
|
@@ -55,25 +57,39 @@ function parseSegments(segments) {
|
|
|
55
57
|
/**
|
|
56
58
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
57
59
|
*/ withText(text, options = {}) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
if (text) {
|
|
61
|
+
this.#segments.push({
|
|
62
|
+
text,
|
|
63
|
+
options
|
|
64
|
+
});
|
|
65
|
+
}
|
|
62
66
|
return this;
|
|
63
67
|
}
|
|
64
68
|
/**
|
|
65
69
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
66
70
|
*/ withError(error) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
if (error) {
|
|
72
|
+
this.#segments.push({
|
|
73
|
+
error
|
|
74
|
+
});
|
|
75
|
+
}
|
|
70
76
|
return this;
|
|
71
77
|
}
|
|
72
78
|
/**
|
|
73
79
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
74
80
|
*/ withObject(obj) {
|
|
81
|
+
if (obj) {
|
|
82
|
+
this.#segments.push({
|
|
83
|
+
obj
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* @see {@link https://workleap.github.io/wl-logging}
|
|
90
|
+
*/ withLineChange() {
|
|
75
91
|
this.#segments.push({
|
|
76
|
-
|
|
92
|
+
lineChange: true
|
|
77
93
|
});
|
|
78
94
|
return this;
|
|
79
95
|
}
|
|
@@ -186,25 +202,39 @@ function parseSegments(segments) {
|
|
|
186
202
|
/**
|
|
187
203
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
188
204
|
*/ withText(text, options = {}) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
205
|
+
if (text) {
|
|
206
|
+
this.#segments.push({
|
|
207
|
+
text,
|
|
208
|
+
options
|
|
209
|
+
});
|
|
210
|
+
}
|
|
193
211
|
return this;
|
|
194
212
|
}
|
|
195
213
|
/**
|
|
196
214
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
197
215
|
*/ withError(error) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
216
|
+
if (error) {
|
|
217
|
+
this.#segments.push({
|
|
218
|
+
error
|
|
219
|
+
});
|
|
220
|
+
}
|
|
201
221
|
return this;
|
|
202
222
|
}
|
|
203
223
|
/**
|
|
204
224
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
205
225
|
*/ withObject(obj) {
|
|
226
|
+
if (obj) {
|
|
227
|
+
this.#segments.push({
|
|
228
|
+
obj
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
return this;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* @see {@link https://workleap.github.io/wl-logging}
|
|
235
|
+
*/ withLineChange() {
|
|
206
236
|
this.#segments.push({
|
|
207
|
-
|
|
237
|
+
lineChange: true
|
|
208
238
|
});
|
|
209
239
|
return this;
|
|
210
240
|
}
|
|
@@ -269,6 +299,7 @@ function parseSegments(segments) {
|
|
|
269
299
|
this.#log(logrocket.error, LogLevel.critical);
|
|
270
300
|
}
|
|
271
301
|
/**
|
|
302
|
+
* Start a new logging scope. The scope will inherit the LogLevel of the root logger.
|
|
272
303
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
273
304
|
*/ startScope(label) {
|
|
274
305
|
return new LogRocketLoggerScope(label, this.#logLevel);
|
|
@@ -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 }\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 this.#segments.push({\n text,\n options\n });\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withError(error: Error) {\n this.#segments.push({\n error\n });\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withObject(obj: object) {\n this.#segments.push({\n obj\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 this.#segments.push({\n text,\n options\n });\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withError(error: Error) {\n this.#segments.push({\n error\n });\n\n return this;\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-logging}\n */\n withObject(obj: object) {\n this.#segments.push({\n obj\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 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,IAAI,IAAI,CAACC,EAAE,GAAG;QAClB,OAAO,IAAIA,EAAE,KAAK,EAAE;YAChBD,IAAI,IAAI,CAACC,EAAE,KAAK;QACpB;QAEA,OAAOD;IACX,GAAG,EAAE;AACT;AAEA;;;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,cA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AAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAMA;gBACNH;YACJ;QACJ;QAEA,IAAI,CAAC,IAAI,CAACZ,cAAc,EAAED,gBAAgB;IAC9C;IAEA;;;KAGC,GACD,MAAMgB,GAAY,EAAEH,OAAoB,EAAE;QACtC,IAAIG,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAMA;gBACNH;YACJ;QACJ;QAEA,IAAI,CAAC,IAAI,CAACZ,eAAe,EAAED,cAAc;IAC7C;IAEA;;;KAGC,GACD,SAASgB,GAAY,EAAEH,OAAoB,EAAE;QACzC,IAAIG,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAMA;gBACNH;YACJ;QACJ;QAEA,IAAI,CAAC,IAAI,CAACZ,eAAe,EAAED,iBAAiB;IAChD;IAEA;;KAEC,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, 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?: object) {\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?: object) {\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,IAAI,IAAI,CAACC,EAAE,GAAG;QAClB,OAAO,IAAIA,EAAE,KAAK,EAAE;YAChBD,IAAI,IAAI,CAACC,EAAE,KAAK;QACpB,OAAO,IAAIA,EAAE,UAAU,EAAE;YACrBD,IAAI,IAAI,CAAC;QACb;QAEA,OAAOA;IACX,GAAG,EAAE;AACT;AAEA;;;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,SAAS,GAAG,EAAE;IACvB;IAEA,IAAI,CAACE,GAAgB,EAAEC,SAAmB;QACtC,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,GAAG;YAC3B,IAAI,IAAI,CAAC,SAAS,IAAIA,WAAW;gBAC7B,+GAA+G;gBAC/G,MAAMP,WAAW,IAAI,CAAC,SAAS;gBAE/B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC;oBACnB,MAAMQ,iBAAiBT,cAAcC;oBACrCQ,eAAe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EAAE;QACxC,IAAIG,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAMA;gBACNH;YACJ;QACJ;QAEA,IAAI,CAAC,IAAI,CAACZ,cAAc,EAAED,gBAAgB;IAC9C;IAEA;;;KAGC,GACD,MAAMgB,GAAY,EAAEH,OAAoB,EAAE;QACtC,IAAIG,KAAK;YACL,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAChB,MAAMA;gBACNH;YACJ;QACJ;QAEA,IAAI,CAAC,IAAI,CAACZ,eAAe,EAAED,cAAc;IAC7C;IAEA;;;KAGC,GACD,SAASgB,GAAY,EAAEH,OAAoB,EAAE;QACzC,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"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workleap/logrocket",
|
|
3
3
|
"author": "Workleap",
|
|
4
|
-
"version": "1.1
|
|
4
|
+
"version": "1.2.1",
|
|
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.
|
|
34
|
+
"@workleap/logging": "^1.2.1",
|
|
35
35
|
"logrocket-fuzzy-search-sanitizer": "0.0.2",
|
|
36
|
-
"@workleap/telemetry": "1.1.
|
|
36
|
+
"@workleap/telemetry": "1.1.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@rsbuild/core": "1.4.6",
|
package/src/LogRocketLogger.ts
CHANGED
|
@@ -12,6 +12,8 @@ function parseSegments(segments: Segment[]) {
|
|
|
12
12
|
acc.push(x.obj);
|
|
13
13
|
} else if (x.error) {
|
|
14
14
|
acc.push(x.error);
|
|
15
|
+
} else if (x.lineChange) {
|
|
16
|
+
acc.push("\r\n");
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
return acc;
|
|
@@ -63,11 +65,13 @@ export class LogRocketLoggerScope implements LoggerScope {
|
|
|
63
65
|
/**
|
|
64
66
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
65
67
|
*/
|
|
66
|
-
withText(text
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
withText(text?: string, options: LogOptions = {}) {
|
|
69
|
+
if (text) {
|
|
70
|
+
this.#segments.push({
|
|
71
|
+
text,
|
|
72
|
+
options
|
|
73
|
+
});
|
|
74
|
+
}
|
|
71
75
|
|
|
72
76
|
return this;
|
|
73
77
|
}
|
|
@@ -75,10 +79,25 @@ export class LogRocketLoggerScope implements LoggerScope {
|
|
|
75
79
|
/**
|
|
76
80
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
77
81
|
*/
|
|
78
|
-
withError(error
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
withError(error?: Error) {
|
|
83
|
+
if (error) {
|
|
84
|
+
this.#segments.push({
|
|
85
|
+
error
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @see {@link https://workleap.github.io/wl-logging}
|
|
94
|
+
*/
|
|
95
|
+
withObject(obj?: object) {
|
|
96
|
+
if (obj) {
|
|
97
|
+
this.#segments.push({
|
|
98
|
+
obj
|
|
99
|
+
});
|
|
100
|
+
}
|
|
82
101
|
|
|
83
102
|
return this;
|
|
84
103
|
}
|
|
@@ -86,9 +105,9 @@ export class LogRocketLoggerScope implements LoggerScope {
|
|
|
86
105
|
/**
|
|
87
106
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
88
107
|
*/
|
|
89
|
-
|
|
108
|
+
withLineChange() {
|
|
90
109
|
this.#segments.push({
|
|
91
|
-
|
|
110
|
+
lineChange: true
|
|
92
111
|
});
|
|
93
112
|
|
|
94
113
|
return this;
|
|
@@ -238,11 +257,13 @@ export class LogRocketLogger implements Logger {
|
|
|
238
257
|
/**
|
|
239
258
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
240
259
|
*/
|
|
241
|
-
withText(text
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
260
|
+
withText(text?: string, options: LogOptions = {}) {
|
|
261
|
+
if (text) {
|
|
262
|
+
this.#segments.push({
|
|
263
|
+
text,
|
|
264
|
+
options
|
|
265
|
+
});
|
|
266
|
+
}
|
|
246
267
|
|
|
247
268
|
return this;
|
|
248
269
|
}
|
|
@@ -250,10 +271,25 @@ export class LogRocketLogger implements Logger {
|
|
|
250
271
|
/**
|
|
251
272
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
252
273
|
*/
|
|
253
|
-
withError(error
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
274
|
+
withError(error?: Error) {
|
|
275
|
+
if (error) {
|
|
276
|
+
this.#segments.push({
|
|
277
|
+
error
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return this;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* @see {@link https://workleap.github.io/wl-logging}
|
|
286
|
+
*/
|
|
287
|
+
withObject(obj?: object) {
|
|
288
|
+
if (obj) {
|
|
289
|
+
this.#segments.push({
|
|
290
|
+
obj
|
|
291
|
+
});
|
|
292
|
+
}
|
|
257
293
|
|
|
258
294
|
return this;
|
|
259
295
|
}
|
|
@@ -261,9 +297,9 @@ export class LogRocketLogger implements Logger {
|
|
|
261
297
|
/**
|
|
262
298
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
263
299
|
*/
|
|
264
|
-
|
|
300
|
+
withLineChange() {
|
|
265
301
|
this.#segments.push({
|
|
266
|
-
|
|
302
|
+
lineChange: true
|
|
267
303
|
});
|
|
268
304
|
|
|
269
305
|
return this;
|
|
@@ -345,6 +381,7 @@ export class LogRocketLogger implements Logger {
|
|
|
345
381
|
}
|
|
346
382
|
|
|
347
383
|
/**
|
|
384
|
+
* Start a new logging scope. The scope will inherit the LogLevel of the root logger.
|
|
348
385
|
* @see {@link https://workleap.github.io/wl-logging}
|
|
349
386
|
*/
|
|
350
387
|
startScope(label: string) {
|