@reliverse/relinka 1.3.2 → 1.3.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.
Files changed (64) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +87 -134
  3. package/bin/libs/core/core-impl/deprecated/components/core/core.d.ts +1 -0
  4. package/bin/libs/core/core-impl/deprecated/components/core/core.js +1 -0
  5. package/bin/libs/core/core-impl/deprecated/components/levels/levels.d.ts +26 -0
  6. package/{dist-npm → bin/libs/core/core-impl/deprecated}/components/levels/levels.js +15 -15
  7. package/bin/libs/core/core-impl/deprecated/components/modes/basic.d.ts +20 -0
  8. package/bin/libs/core/core-impl/deprecated/components/modes/basic.js +21 -0
  9. package/{dist-npm → bin/libs/core/core-impl/deprecated}/components/modes/browser.d.ts +19 -19
  10. package/bin/libs/core/core-impl/deprecated/components/modes/browser.js +12 -0
  11. package/bin/libs/core/core-impl/deprecated/components/modes/shared.d.ts +3 -0
  12. package/bin/libs/core/core-impl/deprecated/components/modes/shared.js +4 -0
  13. package/{dist-npm/components/relinka → bin/libs/core/core-impl/deprecated/components/relinka-deprecated}/logger.d.ts +5 -5
  14. package/bin/libs/core/core-impl/deprecated/components/relinka-deprecated/logger.js +5 -0
  15. package/{dist-npm/components/relinka → bin/libs/core/core-impl/deprecated/components/relinka-deprecated}/mod.d.ts +21 -21
  16. package/bin/libs/core/core-impl/deprecated/components/relinka-deprecated/mod.js +34 -0
  17. package/{dist-npm/components/relinka → bin/libs/core/core-impl/deprecated/components/relinka-deprecated}/relinka.d.ts +141 -140
  18. package/{dist-npm/components/relinka → bin/libs/core/core-impl/deprecated/components/relinka-deprecated}/relinka.js +30 -27
  19. package/{dist-npm → bin/libs/core/core-impl/deprecated}/components/reporters/basic.d.ts +11 -11
  20. package/{dist-npm → bin/libs/core/core-impl/deprecated}/components/reporters/basic.js +10 -6
  21. package/{dist-npm → bin/libs/core/core-impl/deprecated}/components/reporters/browser.d.ts +10 -10
  22. package/bin/libs/core/core-impl/deprecated/components/reporters/fancy.d.ts +10 -0
  23. package/{dist-npm → bin/libs/core/core-impl/deprecated}/components/reporters/fancy.js +19 -12
  24. package/{dist-npm → bin/libs/core/core-impl/deprecated}/types/mod.d.ts +150 -149
  25. package/{dist-npm → bin/libs/core/core-impl/deprecated}/utils/box.d.ts +114 -114
  26. package/{dist-npm → bin/libs/core/core-impl/deprecated}/utils/box.js +1 -1
  27. package/{dist-npm → bin/libs/core/core-impl/deprecated}/utils/deprecatedColors.d.ts +69 -69
  28. package/{dist-npm → bin/libs/core/core-impl/deprecated}/utils/deprecatedColors.js +3 -12
  29. package/{dist-npm → bin/libs/core/core-impl/deprecated}/utils/error.d.ts +6 -6
  30. package/{dist-npm → bin/libs/core/core-impl/deprecated}/utils/format.d.ts +14 -14
  31. package/{dist-npm → bin/libs/core/core-impl/deprecated}/utils/format.js +2 -2
  32. package/{dist-npm → bin/libs/core/core-impl/deprecated}/utils/log.d.ts +13 -13
  33. package/bin/libs/core/core-impl/deprecated/utils/mod.d.ts +3 -0
  34. package/bin/libs/core/core-impl/deprecated/utils/mod.js +9 -0
  35. package/{dist-npm → bin/libs/core/core-impl/deprecated}/utils/stream.d.ts +15 -14
  36. package/{dist-npm → bin/libs/core/core-impl/deprecated}/utils/string.d.ts +50 -50
  37. package/{dist-npm → bin/libs/core/core-impl/deprecated}/utils/tree.d.ts +41 -41
  38. package/bin/libs/core/core-main.d.ts +23 -0
  39. package/bin/libs/core/core-main.js +49 -0
  40. package/bin/main.d.ts +1 -0
  41. package/bin/main.js +1 -0
  42. package/package.json +47 -83
  43. package/dist-npm/components/core/core.d.ts +0 -2
  44. package/dist-npm/components/core/core.js +0 -2
  45. package/dist-npm/components/levels/levels.d.ts +0 -26
  46. package/dist-npm/components/modes/basic.d.ts +0 -20
  47. package/dist-npm/components/modes/basic.js +0 -21
  48. package/dist-npm/components/modes/browser.js +0 -12
  49. package/dist-npm/components/modes/shared.d.ts +0 -5
  50. package/dist-npm/components/modes/shared.js +0 -2
  51. package/dist-npm/components/relinka/logger.js +0 -5
  52. package/dist-npm/components/relinka/mod.js +0 -34
  53. package/dist-npm/components/reporters/fancy.d.ts +0 -10
  54. package/dist-npm/main.d.ts +0 -2
  55. package/dist-npm/main.js +0 -2
  56. package/dist-npm/utils/mod.d.ts +0 -3
  57. package/dist-npm/utils/mod.js +0 -9
  58. /package/{dist-npm → bin/libs/core/core-impl/deprecated}/components/reporters/browser.js +0 -0
  59. /package/{dist-npm → bin/libs/core/core-impl/deprecated}/types/mod.js +0 -0
  60. /package/{dist-npm → bin/libs/core/core-impl/deprecated}/utils/error.js +0 -0
  61. /package/{dist-npm → bin/libs/core/core-impl/deprecated}/utils/log.js +0 -0
  62. /package/{dist-npm → bin/libs/core/core-impl/deprecated}/utils/stream.js +0 -0
  63. /package/{dist-npm → bin/libs/core/core-impl/deprecated}/utils/string.js +0 -0
  64. /package/{dist-npm → bin/libs/core/core-impl/deprecated}/utils/tree.js +0 -0
@@ -1,140 +1,141 @@
1
- import type { LogType } from "../../components/levels/levels.js";
2
- import type { RelinkaReporter, InputLogObject, LogObject, RelinkaOptions } from "../../types/mod.js";
3
- /**
4
- * Relinka class for logging management with support for pause/resume, mocking and customizable reporting.
5
- * Provides flexible logging capabilities including level-based logging, custom reporters and integration options.
6
- *
7
- * @class Relinka
8
- */
9
- export declare class RelinkaInterface {
10
- options: RelinkaOptions;
11
- _lastLog: {
12
- serialized?: string;
13
- object?: LogObject;
14
- count?: number;
15
- time?: Date;
16
- timeout?: ReturnType<typeof setTimeout>;
17
- };
18
- _paused: boolean;
19
- _queue: any[];
20
- _mockFn?: RelinkaOptions["mockFn"];
21
- /**
22
- * Creates an instance of Relinka with specified options or defaults.
23
- *
24
- * @param {Partial<RelinkaOptions>} [options={}] - Configuration options for the Relinka instance.
25
- */
26
- constructor(options?: Partial<RelinkaOptions>);
27
- /**
28
- * Gets the current log level of the Relinka instance.
29
- *
30
- * @returns {number} The current log level.
31
- */
32
- get level(): any;
33
- /**
34
- * Sets the minimum log level that will be output by the instance.
35
- *
36
- * @param {number} level - The new log level to set.
37
- */
38
- set level(level: any);
39
- /**
40
- * Creates a new instance of Relinka, inheriting options from the current instance, with possible overrides.
41
- *
42
- * @param {Partial<RelinkaOptions>} options - Optional overrides for the new instance. See {@link RelinkaOptions}.
43
- * @returns {RelinkaInstance} A new Relinka instance. See {@link RelinkaInstance}.
44
- */
45
- create(options: Partial<RelinkaOptions>): RelinkaInstance;
46
- /**
47
- * Creates a new Relinka instance with the specified default log object properties.
48
- *
49
- * @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
50
- * @returns {RelinkaInstance} A new Relinka instance. See {@link RelinkaInstance}.
51
- */
52
- withDefaults(defaults: InputLogObject): RelinkaInstance;
53
- /**
54
- * Creates a new Relinka instance with a specified tag, which will be included in every log.
55
- *
56
- * @param {string} tag - The tag to include in each log of the new instance.
57
- * @returns {RelinkaInstance} A new Relinka instance. See {@link RelinkaInstance}.
58
- */
59
- withTag(tag: string): RelinkaInstance;
60
- /**
61
- * Adds a custom reporter to the Relinka instance.
62
- * Reporters will be called for each log message, depending on their implementation and log level.
63
- *
64
- * @param {RelinkaReporter} reporter - The reporter to add. See {@link RelinkaReporter}.
65
- * @returns {Relinka} The current Relinka instance.
66
- */
67
- addReporter(reporter: RelinkaReporter): this;
68
- /**
69
- * Removes a custom reporter from the Relinka instance.
70
- * If no reporter is specified, all reporters will be removed.
71
- *
72
- * @param {RelinkaReporter} reporter - The reporter to remove. See {@link RelinkaReporter}.
73
- * @returns {Relinka} The current Relinka instance.
74
- */
75
- removeReporter(reporter: RelinkaReporter): any;
76
- /**
77
- * Replaces all reporters of the Relinka instance with the specified array of reporters.
78
- *
79
- * @param {RelinkaReporter[]} reporters - The new reporters to set. See {@link RelinkaReporter}.
80
- * @returns {Relinka} The current Relinka instance.
81
- */
82
- setReporters(reporters: RelinkaReporter[]): this;
83
- wrapAll(): void;
84
- restoreAll(): void;
85
- /**
86
- * Overrides console methods with Relinka logging methods for consistent logging.
87
- */
88
- wrapConsole(): void;
89
- /**
90
- * Restores the original console methods, removing Relinka overrides.
91
- */
92
- restoreConsole(): void;
93
- /**
94
- * Overrides standard output and error streams to redirect them through RelinkaInterface.
95
- */
96
- wrapStd(): void;
97
- _wrapStream(stream: NodeJS.WriteStream | undefined, type: LogType): void;
98
- /**
99
- * Restores the original standard output and error streams, removing the Relinka redirection.
100
- */
101
- restoreStd(): void;
102
- _restoreStream(stream?: NodeJS.WriteStream): void;
103
- /**
104
- * Clears the internal state of the Relinka instance.
105
- * This will reset any throttling, last log data, clear any queued logs,
106
- * and optionally clear the actual console.
107
- *
108
- * @param {boolean} clearConsole - Whether to clear the actual console. Defaults to false.
109
- */
110
- clear(clearConsole?: boolean): void;
111
- /**
112
- * Pauses logging, queues incoming logs until resumed.
113
- */
114
- pauseLogs(): void;
115
- /**
116
- * Resumes logging, processing any queued logs.
117
- */
118
- resumeLogs(): void;
119
- /**
120
- * Replaces logging methods with mocks if a mock function is provided.
121
- *
122
- * @param {RelinkaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link RelinkaOptions["mockFn"]}.
123
- */
124
- mockTypes(mockFn?: RelinkaOptions["mockFn"]): void;
125
- _wrapLogFn(defaults: InputLogObject, isRaw?: boolean): (...args: any[]) => boolean;
126
- _logFn(defaults: InputLogObject, args: any[], isRaw?: boolean): boolean;
127
- _log(logObj: LogObject): void;
128
- }
129
- export type LogFn = {
130
- (message: InputLogObject | any, ...args: any[]): void;
131
- raw: (...args: any[]) => void;
132
- };
133
- export type RelinkaInstance = RelinkaInterface & Record<LogType, LogFn>;
134
- /**
135
- * Utility for creating a new Relinka instance with optional configuration.
136
- *
137
- * @param {Partial<RelinkaOptions>} [options={}] - Optional configuration options for the new Relinka instance. See {@link RelinkaOptions}.
138
- * @returns {RelinkaInstance} A new instance of RelinkaInterface. See {@link RelinkaInstance}.
139
- */
140
- export declare function createRelinka(options?: Partial<RelinkaOptions>): RelinkaInstance;
1
+ /// <reference types="node" />
2
+ import type { LogTypeDeprecated } from "../levels/levels.js";
3
+ import type { InputLogObject, LogObject, RelinkaOptions, RelinkaReporter } from "../../types/mod.js";
4
+ /**
5
+ * Relinka class for logging management with support for pause/resume, mocking and customizable reporting.
6
+ * Provides flexible logging capabilities including level-based logging, custom reporters and integration options.
7
+ *
8
+ * @class Relinka
9
+ */
10
+ export declare class RelinkaInterface {
11
+ options: RelinkaOptions;
12
+ _lastLog: {
13
+ serialized?: string;
14
+ object?: LogObject;
15
+ count?: number;
16
+ time?: Date;
17
+ timeout?: ReturnType<typeof setTimeout>;
18
+ };
19
+ _paused: boolean;
20
+ _queue: any[];
21
+ _mockFn?: RelinkaOptions["mockFn"];
22
+ /**
23
+ * Creates an instance of Relinka with specified options or defaults.
24
+ *
25
+ * @param {Partial<RelinkaOptions>} [options={}] - Configuration options for the Relinka instance.
26
+ */
27
+ constructor(options?: Partial<RelinkaOptions>);
28
+ /**
29
+ * Gets the current log level of the Relinka instance.
30
+ *
31
+ * @returns {number} The current log level.
32
+ */
33
+ get level(): any;
34
+ /**
35
+ * Sets the minimum log level that will be output by the instance.
36
+ *
37
+ * @param {number} level - The new log level to set.
38
+ */
39
+ set level(level: any);
40
+ /**
41
+ * Creates a new instance of Relinka, inheriting options from the current instance, with possible overrides.
42
+ *
43
+ * @param {Partial<RelinkaOptions>} options - Optional overrides for the new instance. See {@link RelinkaOptions}.
44
+ * @returns {RelinkaInstanceDeprecated} A new Relinka instance. See {@link RelinkaInstanceDeprecated}.
45
+ */
46
+ create(options: Partial<RelinkaOptions>): RelinkaInstanceDeprecated;
47
+ /**
48
+ * Creates a new Relinka instance with the specified default log object properties.
49
+ *
50
+ * @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
51
+ * @returns {RelinkaInstanceDeprecated} A new Relinka instance. See {@link RelinkaInstanceDeprecated}.
52
+ */
53
+ withDefaults(defaults: InputLogObject): RelinkaInstanceDeprecated;
54
+ /**
55
+ * Creates a new Relinka instance with a specified tag, which will be included in every log.
56
+ *
57
+ * @param {string} tag - The tag to include in each log of the new instance.
58
+ * @returns {RelinkaInstanceDeprecated} A new Relinka instance. See {@link RelinkaInstanceDeprecated}.
59
+ */
60
+ withTag(tag: string): RelinkaInstanceDeprecated;
61
+ /**
62
+ * Adds a custom reporter to the Relinka instance.
63
+ * Reporters will be called for each log message, depending on their implementation and log level.
64
+ *
65
+ * @param {RelinkaReporter} reporter - The reporter to add. See {@link RelinkaReporter}.
66
+ * @returns {Relinka} The current Relinka instance.
67
+ */
68
+ addReporter(reporter: RelinkaReporter): this;
69
+ /**
70
+ * Removes a custom reporter from the Relinka instance.
71
+ * If no reporter is specified, all reporters will be removed.
72
+ *
73
+ * @param {RelinkaReporter} reporter - The reporter to remove. See {@link RelinkaReporter}.
74
+ * @returns {Relinka} The current Relinka instance.
75
+ */
76
+ removeReporter(reporter: RelinkaReporter): any;
77
+ /**
78
+ * Replaces all reporters of the Relinka instance with the specified array of reporters.
79
+ *
80
+ * @param {RelinkaReporter[]} reporters - The new reporters to set. See {@link RelinkaReporter}.
81
+ * @returns {Relinka} The current Relinka instance.
82
+ */
83
+ setReporters(reporters: RelinkaReporter[]): this;
84
+ wrapAll(): void;
85
+ restoreAll(): void;
86
+ /**
87
+ * Overrides console methods with Relinka logging methods for consistent logging.
88
+ */
89
+ wrapConsole(): void;
90
+ /**
91
+ * Restores the original console methods, removing Relinka overrides.
92
+ */
93
+ restoreConsole(): void;
94
+ /**
95
+ * Overrides standard output and error streams to redirect them through RelinkaInterface.
96
+ */
97
+ wrapStd(): void;
98
+ _wrapStream(stream: NodeJS.WriteStream | undefined, type: LogTypeDeprecated): void;
99
+ /**
100
+ * Restores the original standard output and error streams, removing the Relinka redirection.
101
+ */
102
+ restoreStd(): void;
103
+ _restoreStream(stream?: NodeJS.WriteStream): void;
104
+ /**
105
+ * Clears the internal state of the Relinka instance.
106
+ * This will reset any throttling, last log data, clear any queued logs,
107
+ * and optionally clear the actual console.
108
+ *
109
+ * @param {boolean} clearConsole - Whether to clear the actual console. Defaults to false.
110
+ */
111
+ clear(clearConsole?: boolean): void;
112
+ /**
113
+ * Pauses logging, queues incoming logs until resumed.
114
+ */
115
+ pauseLogs(): void;
116
+ /**
117
+ * Resumes logging, processing any queued logs.
118
+ */
119
+ resumeLogs(): void;
120
+ /**
121
+ * Replaces logging methods with mocks if a mock function is provided.
122
+ *
123
+ * @param {RelinkaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link RelinkaOptions["mockFn"]}.
124
+ */
125
+ mockTypes(mockFn?: RelinkaOptions["mockFn"]): void;
126
+ _wrapLogFn(defaults: InputLogObject, isRaw?: boolean): (...args: any[]) => boolean;
127
+ _logFn(defaults: InputLogObject, args: any[], isRaw?: boolean): boolean;
128
+ _log(logObj: LogObject): void;
129
+ }
130
+ export type LogFn = {
131
+ (message: InputLogObject | any, ...args: any[]): void;
132
+ raw: (...args: any[]) => void;
133
+ };
134
+ export type RelinkaInstanceDeprecated = RelinkaInterface & Record<LogTypeDeprecated, LogFn>;
135
+ /**
136
+ * Utility for creating a new Relinka instance with optional configuration.
137
+ *
138
+ * @param {Partial<RelinkaOptions>} [options={}] - Optional configuration options for the new Relinka instance. See {@link RelinkaOptions}.
139
+ * @returns {RelinkaInstanceDeprecated} A new instance of RelinkaInterface. See {@link RelinkaInstanceDeprecated}.
140
+ */
141
+ export declare function createRelinkaDeprecated(options?: Partial<RelinkaOptions>): RelinkaInstanceDeprecated;
@@ -1,5 +1,5 @@
1
1
  import { defu } from "defu";
2
- import { LogTypes } from "../../components/levels/levels.js";
2
+ import { LogTypesDeprecated } from "../modes/shared.js";
3
3
  import { isLogObj } from "../../utils/log.js";
4
4
  export class RelinkaInterface {
5
5
  options;
@@ -14,16 +14,16 @@ export class RelinkaInterface {
14
14
  * @param {Partial<RelinkaOptions>} [options={}] - Configuration options for the Relinka instance.
15
15
  */
16
16
  constructor(options = {}) {
17
- const types = options.types || LogTypes;
17
+ const types = options.types || LogTypesDeprecated;
18
18
  this.options = defu(
19
19
  {
20
20
  ...options,
21
21
  defaults: { ...options.defaults },
22
- level: _normalizeLogLevel(options.level, types),
22
+ level: _normalizeLogLevelDeprecated(options.level, types),
23
23
  reporters: [...options.reporters || []]
24
24
  },
25
25
  {
26
- types: LogTypes,
26
+ types: LogTypesDeprecated,
27
27
  throttle: 1e3,
28
28
  throttleMin: 5,
29
29
  formatOptions: {
@@ -40,10 +40,7 @@ export class RelinkaInterface {
40
40
  ...types[type]
41
41
  };
42
42
  this[type] = this._wrapLogFn(defaults);
43
- this[type].raw = this._wrapLogFn(
44
- defaults,
45
- true
46
- );
43
+ this[type].raw = this._wrapLogFn(defaults, true);
47
44
  }
48
45
  if (this.options.mockFn) {
49
46
  this.mockTypes();
@@ -66,7 +63,7 @@ export class RelinkaInterface {
66
63
  * @param {number} level - The new log level to set.
67
64
  */
68
65
  set level(level) {
69
- this.options.level = _normalizeLogLevel(
66
+ this.options.level = _normalizeLogLevelDeprecated(
70
67
  level,
71
68
  this.options.types,
72
69
  this.options.level
@@ -76,7 +73,7 @@ export class RelinkaInterface {
76
73
  * Creates a new instance of Relinka, inheriting options from the current instance, with possible overrides.
77
74
  *
78
75
  * @param {Partial<RelinkaOptions>} options - Optional overrides for the new instance. See {@link RelinkaOptions}.
79
- * @returns {RelinkaInstance} A new Relinka instance. See {@link RelinkaInstance}.
76
+ * @returns {RelinkaInstanceDeprecated} A new Relinka instance. See {@link RelinkaInstanceDeprecated}.
80
77
  */
81
78
  create(options) {
82
79
  const instance = new RelinkaInterface({
@@ -92,7 +89,7 @@ export class RelinkaInterface {
92
89
  * Creates a new Relinka instance with the specified default log object properties.
93
90
  *
94
91
  * @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
95
- * @returns {RelinkaInstance} A new Relinka instance. See {@link RelinkaInstance}.
92
+ * @returns {RelinkaInstanceDeprecated} A new Relinka instance. See {@link RelinkaInstanceDeprecated}.
96
93
  */
97
94
  withDefaults(defaults) {
98
95
  return this.create({
@@ -107,11 +104,11 @@ export class RelinkaInterface {
107
104
  * Creates a new Relinka instance with a specified tag, which will be included in every log.
108
105
  *
109
106
  * @param {string} tag - The tag to include in each log of the new instance.
110
- * @returns {RelinkaInstance} A new Relinka instance. See {@link RelinkaInstance}.
107
+ * @returns {RelinkaInstanceDeprecated} A new Relinka instance. See {@link RelinkaInstanceDeprecated}.
111
108
  */
112
109
  withTag(tag) {
113
110
  return this.withDefaults({
114
- tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag
111
+ tag: this.options.defaults.tag ? `${this.options.defaults.tag}:${tag}` : tag
115
112
  });
116
113
  }
117
114
  /**
@@ -166,8 +163,8 @@ export class RelinkaInterface {
166
163
  */
167
164
  wrapConsole() {
168
165
  for (const type in this.options.types) {
169
- if (!console["__" + type]) {
170
- console["__" + type] = console[type];
166
+ if (!console[`__${type}`]) {
167
+ console[`__${type}`] = console[type];
171
168
  }
172
169
  console[type] = this[type].raw;
173
170
  }
@@ -177,9 +174,9 @@ export class RelinkaInterface {
177
174
  */
178
175
  restoreConsole() {
179
176
  for (const type in this.options.types) {
180
- if (console["__" + type]) {
181
- console[type] = console["__" + type];
182
- delete console["__" + type];
177
+ if (console[`__${type}`]) {
178
+ console[type] = console[`__${type}`];
179
+ delete console[`__${type}`];
183
180
  }
184
181
  }
185
182
  }
@@ -198,7 +195,9 @@ export class RelinkaInterface {
198
195
  stream.__write = stream.write;
199
196
  }
200
197
  stream.write = (data) => {
201
- this[type].raw(String(data).trim());
198
+ this[type].raw(
199
+ String(data).trim()
200
+ );
202
201
  };
203
202
  }
204
203
  /**
@@ -214,7 +213,7 @@ export class RelinkaInterface {
214
213
  }
215
214
  if (stream.__write) {
216
215
  stream.write = stream.__write;
217
- delete stream.__write;
216
+ stream.__write = void 0;
218
217
  }
219
218
  }
220
219
  /**
@@ -260,7 +259,10 @@ export class RelinkaInterface {
260
259
  return;
261
260
  }
262
261
  for (const type in this.options.types) {
263
- this[type] = _mockFn(type, this.options.types[type]) || this[type];
262
+ this[type] = _mockFn(
263
+ type,
264
+ this.options.types[type]
265
+ ) || this[type];
264
266
  this[type].raw = this[type];
265
267
  }
266
268
  }
@@ -282,7 +284,7 @@ export class RelinkaInterface {
282
284
  date: /* @__PURE__ */ new Date(),
283
285
  args: [],
284
286
  ...defaults,
285
- level: _normalizeLogLevel(defaults.level, this.options.types)
287
+ level: _normalizeLogLevelDeprecated(defaults.level, this.options.types)
286
288
  };
287
289
  if (!isRaw && args.length === 1 && isLogObj(args[0])) {
288
290
  Object.assign(logObj, args[0]);
@@ -291,14 +293,15 @@ export class RelinkaInterface {
291
293
  }
292
294
  if (logObj.message) {
293
295
  logObj.args.unshift(logObj.message);
294
- delete logObj.message;
296
+ logObj.message = void 0;
295
297
  }
296
298
  if (logObj.additional) {
297
299
  if (!Array.isArray(logObj.additional)) {
298
300
  logObj.additional = logObj.additional.split("\n");
299
301
  }
300
- logObj.args.push("\n" + logObj.additional.join("\n"));
301
- delete logObj.additional;
302
+ logObj.args.push(`
303
+ ${logObj.additional.join("\n")}`);
304
+ logObj.additional = void 0;
302
305
  }
303
306
  logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
304
307
  logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
@@ -354,7 +357,7 @@ export class RelinkaInterface {
354
357
  }
355
358
  }
356
359
  }
357
- function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
360
+ function _normalizeLogLevelDeprecated(input, types = {}, defaultLevel = 3) {
358
361
  if (input === void 0) {
359
362
  return defaultLevel;
360
363
  }
@@ -373,6 +376,6 @@ RelinkaInterface.prototype.withScope = RelinkaInterface.prototype.withTag;
373
376
  RelinkaInterface.prototype.mock = RelinkaInterface.prototype.mockTypes;
374
377
  RelinkaInterface.prototype.pause = RelinkaInterface.prototype.pauseLogs;
375
378
  RelinkaInterface.prototype.resume = RelinkaInterface.prototype.resumeLogs;
376
- export function createRelinka(options = {}) {
379
+ export function createRelinkaDeprecated(options = {}) {
377
380
  return new RelinkaInterface(options);
378
381
  }
@@ -1,11 +1,11 @@
1
- import type { LogObject, RelinkaReporter, FormatOptions, RelinkaOptions } from "../../types/mod.js";
2
- export declare class BasicReporter implements RelinkaReporter {
3
- formatStack(stack: string): string;
4
- formatArgs(args: any[], opts: FormatOptions): string;
5
- formatDate(date: Date, opts: FormatOptions): string;
6
- filterAndJoin(arr: any[]): string;
7
- formatLogObj(logObj: LogObject, opts: FormatOptions): string;
8
- log(logObj: LogObject, ctx: {
9
- options: RelinkaOptions;
10
- }): any;
11
- }
1
+ import type { LogObject, RelinkaReporter, FormatOptions, RelinkaOptions } from "../../types/mod.js";
2
+ export declare class BasicReporter implements RelinkaReporter {
3
+ formatStack(stack: string): string;
4
+ formatArgs(args: any[], opts: FormatOptions): string;
5
+ formatDate(date: Date, opts: FormatOptions): string;
6
+ filterAndJoin(arr: any[]): string;
7
+ formatLogObj(logObj: LogObject, opts: FormatOptions): string;
8
+ log(logObj: LogObject, ctx: {
9
+ options: RelinkaOptions;
10
+ }): any;
11
+ }
@@ -4,12 +4,13 @@ import { writeStream } from "../../utils/stream.js";
4
4
  const bracket = (x) => x ? `[${x}]` : "";
5
5
  export class BasicReporter {
6
6
  formatStack(stack) {
7
- return " " + parseStack(stack).join("\n ");
7
+ return ` ${parseStack(stack).join("\n ")}`;
8
8
  }
9
9
  formatArgs(args, opts) {
10
10
  const formattedArgs = args.map((arg) => {
11
11
  if (arg && typeof arg.stack === "string") {
12
- return arg.message + "\n" + this.formatStack(arg.stack);
12
+ return `${arg.message}
13
+ ${this.formatStack(arg.stack)}`;
13
14
  }
14
15
  return arg;
15
16
  });
@@ -24,11 +25,13 @@ export class BasicReporter {
24
25
  formatLogObj(logObj, opts) {
25
26
  const message = this.formatArgs(logObj.args, opts);
26
27
  if (logObj.type === "box") {
27
- return "\n" + [
28
+ return `
29
+ ${[
28
30
  bracket(logObj.tag),
29
- logObj["title"] && logObj["title"],
31
+ logObj.title && logObj.title,
30
32
  ...message.split("\n")
31
- ].filter(Boolean).map((l) => " > " + l).join("\n") + "\n";
33
+ ].filter(Boolean).map((l) => ` > ${l}`).join("\n")}
34
+ `;
32
35
  }
33
36
  return this.filterAndJoin([
34
37
  bracket(logObj.type),
@@ -42,7 +45,8 @@ export class BasicReporter {
42
45
  ...ctx.options.formatOptions
43
46
  });
44
47
  return writeStream(
45
- line + "\n",
48
+ `${line}
49
+ `,
46
50
  logObj.level < 2 ? ctx.options.stderr || process.stderr : ctx.options.stdout || process.stdout
47
51
  );
48
52
  }
@@ -1,10 +1,10 @@
1
- import type { LogObject } from "../../types/mod.js";
2
- export declare class BrowserReporter {
3
- options: any;
4
- defaultColor: string;
5
- levelColorMap: Record<number, string>;
6
- typeColorMap: Record<string, string>;
7
- constructor(options: any);
8
- _getLogFn(level: number): any;
9
- log(logObj: LogObject): void;
10
- }
1
+ import type { LogObject } from "../../types/mod.js";
2
+ export declare class BrowserReporter {
3
+ options: any;
4
+ defaultColor: string;
5
+ levelColorMap: Record<number, string>;
6
+ typeColorMap: Record<string, string>;
7
+ constructor(options: any);
8
+ _getLogFn(level: number): any;
9
+ log(logObj: LogObject): void;
10
+ }
@@ -0,0 +1,10 @@
1
+ import type { LogLevelDeprecated, LogTypeDeprecated } from "../levels/levels.js";
2
+ import type { FormatOptions, LogObject } from "../../types/mod.js";
3
+ import { BasicReporter } from "./basic.js";
4
+ export declare const TYPE_COLOR_MAP: Partial<Record<LogTypeDeprecated, string>>;
5
+ export declare const LEVEL_COLOR_MAP: Partial<Record<LogLevelDeprecated, string>>;
6
+ export declare class FancyReporter extends BasicReporter {
7
+ formatStack(stack: string): string;
8
+ formatType(logObj: LogObject, isBadge: boolean): any;
9
+ formatLogObj(logObj: LogObject, opts: FormatOptions): any;
10
+ }
@@ -1,7 +1,9 @@
1
1
  import { isUnicodeSupported } from "@reliverse/runtime";
2
2
  import stringWidth from "string-width";
3
- import { BasicReporter } from "../../components/reporters/basic.js";
4
- import { box } from "../../utils/box.js";
3
+ import { BasicReporter } from "./basic.js";
4
+ import {
5
+ box
6
+ } from "../../utils/box.js";
5
7
  import { colors } from "../../utils/deprecatedColors.js";
6
8
  import { parseStack } from "../../utils/error.js";
7
9
  import { stripAnsi } from "../../utils/string.js";
@@ -39,9 +41,10 @@ function getStringWidth(str) {
39
41
  }
40
42
  export class FancyReporter extends BasicReporter {
41
43
  formatStack(stack) {
42
- return "\n" + parseStack(stack).map(
43
- (line) => " " + line.replace(/^at +/, (m) => colors.gray(m)).replace(/\((.+)\)/, (_, m) => `(${colors.cyan(m)})`)
44
- ).join("\n");
44
+ return `
45
+ ${parseStack(stack).map(
46
+ (line) => ` ${line.replace(/^at +/, (m) => colors.gray(m)).replace(/\((.+)\)/, (_, m) => `(${colors.cyan(m)})`)}`
47
+ ).join("\n")}`;
45
48
  }
46
49
  formatType(logObj, isBadge) {
47
50
  const typeColor = TYPE_COLOR_MAP[logObj.type] || LEVEL_COLOR_MAP[logObj.level] || "gray";
@@ -60,17 +63,18 @@ export class FancyReporter extends BasicReporter {
60
63
  if (logObj.type === "box") {
61
64
  return box(
62
65
  characterFormat(
63
- message + (additional.length > 0 ? "\n" + additional.join("\n") : "")
66
+ message + (additional.length > 0 ? `
67
+ ${additional.join("\n")}` : "")
64
68
  ),
65
69
  {
66
- title: logObj["title"] ? characterFormat(logObj["title"]) : void 0,
67
- style: logObj["style"]
70
+ title: logObj.title ? characterFormat(logObj.title) : void 0,
71
+ style: logObj.style
68
72
  }
69
73
  );
70
74
  }
71
75
  const date = this.formatDate(logObj.date, opts);
72
76
  const coloredDate = date && colors.gray(date);
73
- const isBadge = logObj["badge"] ?? logObj.level < 2;
77
+ const isBadge = logObj.badge ?? logObj.level < 2;
74
78
  const type = this.formatType(logObj, isBadge);
75
79
  const tag = logObj.tag ? colors.gray(logObj.tag) : "";
76
80
  let line;
@@ -79,13 +83,16 @@ export class FancyReporter extends BasicReporter {
79
83
  const space = (opts.columns || 0) - getStringWidth(left) - getStringWidth(right) - 2;
80
84
  line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors.gray(`[${right}]`)} ` : "") + left;
81
85
  line += characterFormat(
82
- additional.length > 0 ? "\n" + additional.join("\n") : ""
86
+ additional.length > 0 ? `
87
+ ${additional.join("\n")}` : ""
83
88
  );
84
89
  if (logObj.type === "trace") {
85
- const _err = new Error("Trace: " + logObj.message);
90
+ const _err = new Error(`Trace: ${logObj.message}`);
86
91
  line += this.formatStack(_err.stack || "");
87
92
  }
88
- return isBadge ? "\n" + line + "\n" : line;
93
+ return isBadge ? `
94
+ ${line}
95
+ ` : line;
89
96
  }
90
97
  }
91
98
  function characterFormat(str) {