@workleap/logrocket 1.1.0 → 1.2.0

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,16 @@
1
1
  # @workleap/logrocket
2
2
 
3
+ ## 1.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#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.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`79ce028`](https://github.com/workleap/wl-telemetry/commit/79ce028f2418cc43ed18017e82ce9599e97d0e40)]:
12
+ - @workleap/telemetry@1.1.1
13
+
3
14
  ## 1.1.0
4
15
 
5
16
  ### Minor Changes
@@ -21,6 +21,10 @@ export declare class LogRocketLoggerScope implements LoggerScope {
21
21
  * @see {@link https://workleap.github.io/wl-logging}
22
22
  */
23
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}
@@ -77,6 +81,10 @@ export declare class LogRocketLogger implements Logger {
77
81
  * @see {@link https://workleap.github.io/wl-logging}
78
82
  */
79
83
  withObject(obj: object): this;
84
+ /**
85
+ * @see {@link https://workleap.github.io/wl-logging}
86
+ */
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;
@@ -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
  }, []);
@@ -77,6 +79,14 @@ function parseSegments(segments) {
77
79
  });
78
80
  return this;
79
81
  }
82
+ /**
83
+ * @see {@link https://workleap.github.io/wl-logging}
84
+ */ withLineChange() {
85
+ this.#segments.push({
86
+ lineChange: true
87
+ });
88
+ return this;
89
+ }
80
90
  /**
81
91
  * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.
82
92
  * @see {@link https://workleap.github.io/wl-logging}
@@ -208,6 +218,14 @@ function parseSegments(segments) {
208
218
  });
209
219
  return this;
210
220
  }
221
+ /**
222
+ * @see {@link https://workleap.github.io/wl-logging}
223
+ */ withLineChange() {
224
+ this.#segments.push({
225
+ lineChange: true
226
+ });
227
+ return this;
228
+ }
211
229
  /**
212
230
  * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.
213
231
  * @see {@link https://workleap.github.io/wl-logging}
@@ -269,6 +287,7 @@ function parseSegments(segments) {
269
287
  this.#log(logrocket.error, LogLevel.critical);
270
288
  }
271
289
  /**
290
+ * Start a new logging scope. The scope will inherit the LogLevel of the root logger.
272
291
  * @see {@link https://workleap.github.io/wl-logging}
273
292
  */ startScope(label) {
274
293
  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,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,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;oBAEzC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AI,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 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 * @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 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 * @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,IAA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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.0",
4
+ "version": "1.2.0",
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.0.2",
34
+ "@workleap/logging": "^1.2.0",
35
35
  "logrocket-fuzzy-search-sanitizer": "0.0.2",
36
- "@workleap/telemetry": "1.1.0"
36
+ "@workleap/telemetry": "1.1.1"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@rsbuild/core": "1.4.6",
@@ -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;
@@ -94,6 +96,17 @@ export class LogRocketLoggerScope implements LoggerScope {
94
96
  return this;
95
97
  }
96
98
 
99
+ /**
100
+ * @see {@link https://workleap.github.io/wl-logging}
101
+ */
102
+ withLineChange() {
103
+ this.#segments.push({
104
+ lineChange: true
105
+ });
106
+
107
+ return this;
108
+ }
109
+
97
110
  /**
98
111
  * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.
99
112
  * @see {@link https://workleap.github.io/wl-logging}
@@ -269,6 +282,17 @@ export class LogRocketLogger implements Logger {
269
282
  return this;
270
283
  }
271
284
 
285
+ /**
286
+ * @see {@link https://workleap.github.io/wl-logging}
287
+ */
288
+ withLineChange() {
289
+ this.#segments.push({
290
+ lineChange: true
291
+ });
292
+
293
+ return this;
294
+ }
295
+
272
296
  /**
273
297
  * Write a debug log. The log will be processed only if the logger LogLevel is >= debug.
274
298
  * @see {@link https://workleap.github.io/wl-logging}
@@ -345,6 +369,7 @@ export class LogRocketLogger implements Logger {
345
369
  }
346
370
 
347
371
  /**
372
+ * Start a new logging scope. The scope will inherit the LogLevel of the root logger.
348
373
  * @see {@link https://workleap.github.io/wl-logging}
349
374
  */
350
375
  startScope(label: string) {