@reliverse/relinka 1.3.2 → 1.3.3

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 (55) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +87 -134
  3. package/bin/deprecated/components/core/core.d.ts +2 -0
  4. package/bin/deprecated/components/core/core.js +2 -0
  5. package/{dist-npm → bin/deprecated}/components/levels/levels.d.ts +26 -26
  6. package/{dist-npm → bin/deprecated}/components/modes/basic.d.ts +20 -20
  7. package/{dist-npm → bin/deprecated}/components/modes/basic.js +5 -5
  8. package/{dist-npm → bin/deprecated}/components/modes/browser.d.ts +19 -19
  9. package/{dist-npm → bin/deprecated}/components/modes/browser.js +2 -2
  10. package/bin/deprecated/components/modes/shared.d.ts +5 -0
  11. package/bin/deprecated/components/modes/shared.js +2 -0
  12. package/{dist-npm → bin/deprecated}/components/relinka/logger.d.ts +5 -5
  13. package/{dist-npm → bin/deprecated}/components/relinka/mod.d.ts +21 -21
  14. package/{dist-npm → bin/deprecated}/components/relinka/mod.js +3 -3
  15. package/{dist-npm → bin/deprecated}/components/relinka/relinka.d.ts +141 -140
  16. package/{dist-npm → bin/deprecated}/components/relinka/relinka.js +14 -11
  17. package/{dist-npm → bin/deprecated}/components/reporters/basic.d.ts +11 -11
  18. package/{dist-npm → bin/deprecated}/components/reporters/basic.js +10 -6
  19. package/{dist-npm → bin/deprecated}/components/reporters/browser.d.ts +10 -10
  20. package/{dist-npm → bin/deprecated}/components/reporters/fancy.d.ts +10 -10
  21. package/{dist-npm → bin/deprecated}/components/reporters/fancy.js +16 -11
  22. package/{dist-npm/main.js → bin/deprecated/depd-main.d.ts} +2 -2
  23. package/{dist-npm → bin/deprecated}/types/mod.d.ts +150 -149
  24. package/{dist-npm → bin/deprecated}/utils/box.d.ts +114 -114
  25. package/{dist-npm → bin/deprecated}/utils/box.js +1 -1
  26. package/{dist-npm → bin/deprecated}/utils/deprecatedColors.d.ts +69 -69
  27. package/{dist-npm → bin/deprecated}/utils/deprecatedColors.js +3 -9
  28. package/{dist-npm → bin/deprecated}/utils/error.d.ts +6 -6
  29. package/{dist-npm → bin/deprecated}/utils/format.d.ts +14 -14
  30. package/{dist-npm → bin/deprecated}/utils/format.js +2 -2
  31. package/{dist-npm → bin/deprecated}/utils/log.d.ts +13 -13
  32. package/bin/deprecated/utils/mod.d.ts +3 -0
  33. package/bin/deprecated/utils/mod.js +9 -0
  34. package/{dist-npm → bin/deprecated}/utils/stream.d.ts +15 -14
  35. package/{dist-npm → bin/deprecated}/utils/string.d.ts +50 -50
  36. package/{dist-npm → bin/deprecated}/utils/tree.d.ts +41 -41
  37. package/bin/main.d.ts +1 -0
  38. package/bin/main.js +1 -0
  39. package/package.json +46 -83
  40. package/dist-npm/components/core/core.d.ts +0 -2
  41. package/dist-npm/components/core/core.js +0 -2
  42. package/dist-npm/components/modes/shared.d.ts +0 -5
  43. package/dist-npm/components/modes/shared.js +0 -2
  44. package/dist-npm/utils/mod.d.ts +0 -3
  45. package/dist-npm/utils/mod.js +0 -9
  46. /package/{dist-npm → bin/deprecated}/components/levels/levels.js +0 -0
  47. /package/{dist-npm → bin/deprecated}/components/relinka/logger.js +0 -0
  48. /package/{dist-npm → bin/deprecated}/components/reporters/browser.js +0 -0
  49. /package/{dist-npm/main.d.ts → bin/deprecated/depd-main.js} +0 -0
  50. /package/{dist-npm → bin/deprecated}/types/mod.js +0 -0
  51. /package/{dist-npm → bin/deprecated}/utils/error.js +0 -0
  52. /package/{dist-npm → bin/deprecated}/utils/log.js +0 -0
  53. /package/{dist-npm → bin/deprecated}/utils/stream.js +0 -0
  54. /package/{dist-npm → bin/deprecated}/utils/string.js +0 -0
  55. /package/{dist-npm → bin/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 { InputLogObject, LogObject, RelinkaOptions, RelinkaReporter } from "../../types/mod.js";
3
+ import { type LogType } from "../levels/levels.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 {RelinkaInstance} A new Relinka instance. See {@link RelinkaInstance}.
45
+ */
46
+ create(options: Partial<RelinkaOptions>): RelinkaInstance;
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 {RelinkaInstance} A new Relinka instance. See {@link RelinkaInstance}.
52
+ */
53
+ withDefaults(defaults: InputLogObject): RelinkaInstance;
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 {RelinkaInstance} A new Relinka instance. See {@link RelinkaInstance}.
59
+ */
60
+ withTag(tag: string): RelinkaInstance;
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: LogType): 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 RelinkaInstance = RelinkaInterface & Record<LogType, 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 {RelinkaInstance} A new instance of RelinkaInterface. See {@link RelinkaInstance}.
140
+ */
141
+ export declare function createRelinka(options?: Partial<RelinkaOptions>): RelinkaInstance;
@@ -1,5 +1,7 @@
1
1
  import { defu } from "defu";
2
- import { LogTypes } from "../../components/levels/levels.js";
2
+ import {
3
+ LogTypes
4
+ } from "../levels/levels.js";
3
5
  import { isLogObj } from "../../utils/log.js";
4
6
  export class RelinkaInterface {
5
7
  options;
@@ -111,7 +113,7 @@ export class RelinkaInterface {
111
113
  */
112
114
  withTag(tag) {
113
115
  return this.withDefaults({
114
- tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag
116
+ tag: this.options.defaults.tag ? `${this.options.defaults.tag}:${tag}` : tag
115
117
  });
116
118
  }
117
119
  /**
@@ -166,8 +168,8 @@ export class RelinkaInterface {
166
168
  */
167
169
  wrapConsole() {
168
170
  for (const type in this.options.types) {
169
- if (!console["__" + type]) {
170
- console["__" + type] = console[type];
171
+ if (!console[`__${type}`]) {
172
+ console[`__${type}`] = console[type];
171
173
  }
172
174
  console[type] = this[type].raw;
173
175
  }
@@ -177,9 +179,9 @@ export class RelinkaInterface {
177
179
  */
178
180
  restoreConsole() {
179
181
  for (const type in this.options.types) {
180
- if (console["__" + type]) {
181
- console[type] = console["__" + type];
182
- delete console["__" + type];
182
+ if (console[`__${type}`]) {
183
+ console[type] = console[`__${type}`];
184
+ delete console[`__${type}`];
183
185
  }
184
186
  }
185
187
  }
@@ -214,7 +216,7 @@ export class RelinkaInterface {
214
216
  }
215
217
  if (stream.__write) {
216
218
  stream.write = stream.__write;
217
- delete stream.__write;
219
+ stream.__write = void 0;
218
220
  }
219
221
  }
220
222
  /**
@@ -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 : "";
@@ -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 "../../../main.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,10 +1,10 @@
1
- import type { LogLevel, LogType } from "../../components/levels/levels.js";
2
- import type { FormatOptions, LogObject } from "../../types/mod.js";
3
- import { BasicReporter } from "../../components/reporters/basic.js";
4
- export declare const TYPE_COLOR_MAP: Partial<Record<LogType, string>>;
5
- export declare const LEVEL_COLOR_MAP: Partial<Record<LogLevel, 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
+ import type { LogLevel, LogType } from "../levels/levels.js";
2
+ import type { FormatOptions, LogObject } from "../../../main.js";
3
+ import { BasicReporter } from "./basic.js";
4
+ export declare const TYPE_COLOR_MAP: Partial<Record<LogType, string>>;
5
+ export declare const LEVEL_COLOR_MAP: Partial<Record<LogLevel, 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,6 +1,6 @@
1
1
  import { isUnicodeSupported } from "@reliverse/runtime";
2
2
  import stringWidth from "string-width";
3
- import { BasicReporter } from "../../components/reporters/basic.js";
3
+ import { BasicReporter } from "./basic.js";
4
4
  import { box } from "../../utils/box.js";
5
5
  import { colors } from "../../utils/deprecatedColors.js";
6
6
  import { parseStack } from "../../utils/error.js";
@@ -39,9 +39,10 @@ function getStringWidth(str) {
39
39
  }
40
40
  export class FancyReporter extends BasicReporter {
41
41
  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");
42
+ return `
43
+ ${parseStack(stack).map(
44
+ (line) => ` ${line.replace(/^at +/, (m) => colors.gray(m)).replace(/\((.+)\)/, (_, m) => `(${colors.cyan(m)})`)}`
45
+ ).join("\n")}`;
45
46
  }
46
47
  formatType(logObj, isBadge) {
47
48
  const typeColor = TYPE_COLOR_MAP[logObj.type] || LEVEL_COLOR_MAP[logObj.level] || "gray";
@@ -60,17 +61,18 @@ export class FancyReporter extends BasicReporter {
60
61
  if (logObj.type === "box") {
61
62
  return box(
62
63
  characterFormat(
63
- message + (additional.length > 0 ? "\n" + additional.join("\n") : "")
64
+ message + (additional.length > 0 ? `
65
+ ${additional.join("\n")}` : "")
64
66
  ),
65
67
  {
66
- title: logObj["title"] ? characterFormat(logObj["title"]) : void 0,
67
- style: logObj["style"]
68
+ title: logObj.title ? characterFormat(logObj.title) : void 0,
69
+ style: logObj.style
68
70
  }
69
71
  );
70
72
  }
71
73
  const date = this.formatDate(logObj.date, opts);
72
74
  const coloredDate = date && colors.gray(date);
73
- const isBadge = logObj["badge"] ?? logObj.level < 2;
75
+ const isBadge = logObj.badge ?? logObj.level < 2;
74
76
  const type = this.formatType(logObj, isBadge);
75
77
  const tag = logObj.tag ? colors.gray(logObj.tag) : "";
76
78
  let line;
@@ -79,13 +81,16 @@ export class FancyReporter extends BasicReporter {
79
81
  const space = (opts.columns || 0) - getStringWidth(left) - getStringWidth(right) - 2;
80
82
  line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors.gray(`[${right}]`)} ` : "") + left;
81
83
  line += characterFormat(
82
- additional.length > 0 ? "\n" + additional.join("\n") : ""
84
+ additional.length > 0 ? `
85
+ ${additional.join("\n")}` : ""
83
86
  );
84
87
  if (logObj.type === "trace") {
85
- const _err = new Error("Trace: " + logObj.message);
88
+ const _err = new Error(`Trace: ${logObj.message}`);
86
89
  line += this.formatStack(_err.stack || "");
87
90
  }
88
- return isBadge ? "\n" + line + "\n" : line;
91
+ return isBadge ? `
92
+ ${line}
93
+ ` : line;
89
94
  }
90
95
  }
91
96
  function characterFormat(str) {
@@ -1,2 +1,2 @@
1
- export * from "./components/relinka/mod.js";
2
- export * from "./components/relinka/logger.js";
1
+ export * from "./components/relinka/mod.js";
2
+ export * from "./components/relinka/logger.js";