@xylabs/log 2.11.23 → 2.12.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.
@@ -31,7 +31,7 @@ __export(Log_exports, {
31
31
  Log: () => Log
32
32
  });
33
33
  module.exports = __toCommonJS(Log_exports);
34
- var import_rollbar = __toESM(require("rollbar"));
34
+ var import_rollbar = __toESM(require("rollbar"), 1);
35
35
  class Log {
36
36
  devMode;
37
37
  rollbar;
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/Log.ts
31
+ var Log_exports = {};
32
+ __export(Log_exports, {
33
+ Log: () => Log
34
+ });
35
+ module.exports = __toCommonJS(Log_exports);
36
+ var import_rollbar = __toESM(require("rollbar"), 1);
37
+ var Log = class {
38
+ devMode;
39
+ rollbar;
40
+ constructor(config) {
41
+ this.devMode = config.devMode ?? false;
42
+ if (config.rollbarToken) {
43
+ this.rollbar = new import_rollbar.default({
44
+ accessToken: config.rollbarToken,
45
+ captureUncaught: true,
46
+ captureUnhandledRejections: true,
47
+ codeVersion: config.commitHash,
48
+ code_version: config.commitHash,
49
+ payload: {
50
+ client: {
51
+ javascript: {
52
+ code_version: config.commitHash,
53
+ guess_uncaught_frames: true,
54
+ source_map_enabled: true
55
+ }
56
+ },
57
+ codeVersion: config.commitHash,
58
+ code_version: config.commitHash,
59
+ environment: this.devMode ? "development" : "production",
60
+ ...config.payload
61
+ },
62
+ sendConfig: true
63
+ });
64
+ }
65
+ }
66
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
67
+ debug(...params) {
68
+ if (this.devMode) {
69
+ console.debug(params);
70
+ }
71
+ }
72
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
73
+ error(...params) {
74
+ var _a;
75
+ console.error(params);
76
+ if (!this.devMode) {
77
+ (_a = this.rollbar) == null ? void 0 : _a.error(params);
78
+ }
79
+ }
80
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
81
+ info(...params) {
82
+ if (this.devMode) {
83
+ console.info(params);
84
+ }
85
+ }
86
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
87
+ log(...params) {
88
+ if (this.devMode) {
89
+ console.log(params);
90
+ }
91
+ }
92
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
93
+ warn(...params) {
94
+ var _a;
95
+ console.warn(params);
96
+ if (!this.devMode) {
97
+ (_a = this.rollbar) == null ? void 0 : _a.warn(params);
98
+ }
99
+ }
100
+ };
101
+ // Annotate the CommonJS export names for ESM import in node:
102
+ 0 && (module.exports = {
103
+ Log
104
+ });
105
+ //# sourceMappingURL=Log.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/Log.ts"],"sourcesContent":["import Rollbar from 'rollbar'\n\nexport interface LogConfig {\n commitHash?: string\n devMode?: boolean\n payload?: Record<string, unknown>\n rollbarToken?: string\n}\n\nexport class Log {\n private devMode?: boolean\n private rollbar?: Rollbar\n\n constructor(config: LogConfig) {\n this.devMode = config.devMode ?? false\n\n if (config.rollbarToken) {\n this.rollbar = new Rollbar({\n accessToken: config.rollbarToken,\n captureUncaught: true,\n captureUnhandledRejections: true,\n codeVersion: config.commitHash,\n code_version: config.commitHash,\n payload: {\n client: {\n javascript: {\n code_version: config.commitHash,\n guess_uncaught_frames: true,\n source_map_enabled: true,\n },\n },\n codeVersion: config.commitHash,\n code_version: config.commitHash,\n environment: this.devMode ? 'development' : 'production',\n ...config.payload,\n },\n sendConfig: true,\n })\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n debug(...params: any[]) {\n if (this.devMode) {\n console.debug(params)\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n error(...params: any[]) {\n console.error(params)\n if (!this.devMode) {\n this.rollbar?.error(params)\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n info(...params: any[]) {\n if (this.devMode) {\n console.info(params)\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n log(...params: any[]) {\n if (this.devMode) {\n console.log(params)\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n warn(...params: any[]) {\n console.warn(params)\n if (!this.devMode) {\n this.rollbar?.warn(params)\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAoB;AASb,IAAM,MAAN,MAAU;AAAA,EACP;AAAA,EACA;AAAA,EAER,YAAY,QAAmB;AAC7B,SAAK,UAAU,OAAO,WAAW;AAEjC,QAAI,OAAO,cAAc;AACvB,WAAK,UAAU,IAAI,eAAAA,QAAQ;AAAA,QACzB,aAAa,OAAO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