@reliverse/relinka 1.3.7 → 1.4.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.
Files changed (54) hide show
  1. package/README.md +197 -70
  2. package/bin/{relinka-impl/deprecated → deprecated}/components/levels/levels.d.ts +13 -13
  3. package/bin/{relinka-impl/deprecated → deprecated}/components/modes/basic.d.ts +19 -19
  4. package/bin/{relinka-impl/deprecated → deprecated}/components/modes/browser.d.ts +19 -19
  5. package/bin/deprecated/components/modes/shared.d.ts +2 -0
  6. package/bin/deprecated/components/modes/shared.js +1 -0
  7. package/bin/{relinka-impl/deprecated → deprecated}/components/relinka-deprecated/logger.d.ts +5 -5
  8. package/bin/{relinka-impl/deprecated → deprecated}/components/relinka-deprecated/mod.d.ts +20 -20
  9. package/bin/{relinka-impl/deprecated → deprecated}/components/relinka-deprecated/relinka.d.ts +140 -141
  10. package/bin/{relinka-impl/deprecated → deprecated}/components/reporters/basic.d.ts +11 -11
  11. package/bin/{relinka-impl/deprecated → deprecated}/components/reporters/browser.d.ts +10 -10
  12. package/bin/{relinka-impl/deprecated → deprecated}/components/reporters/fancy.d.ts +10 -10
  13. package/bin/{relinka-impl/deprecated → deprecated}/components/reporters/fancy.js +1 -3
  14. package/bin/deprecated/impl-old.js +0 -0
  15. package/bin/{relinka-types.d.ts → deprecated/types.d.ts} +161 -194
  16. package/bin/deprecated/types.js +0 -0
  17. package/bin/{relinka-impl/deprecated → deprecated}/utils/box.d.ts +114 -114
  18. package/bin/{relinka-impl/deprecated → deprecated}/utils/deprecatedColors.d.ts +69 -69
  19. package/bin/{relinka-impl/deprecated → deprecated}/utils/error.d.ts +6 -6
  20. package/bin/{relinka-impl/deprecated → deprecated}/utils/format.d.ts +14 -14
  21. package/bin/{relinka-impl/deprecated → deprecated}/utils/log.d.ts +13 -13
  22. package/bin/{relinka-impl/deprecated → deprecated}/utils/stream.d.ts +14 -15
  23. package/bin/{relinka-impl/deprecated → deprecated}/utils/string.d.ts +50 -50
  24. package/bin/{relinka-impl/deprecated → deprecated}/utils/tree.d.ts +41 -41
  25. package/bin/impl.d.ts +149 -0
  26. package/bin/impl.js +606 -0
  27. package/bin/main.d.ts +24 -22
  28. package/bin/main.js +24 -21
  29. package/bin/types.d.ts +0 -0
  30. package/bin/types.js +0 -0
  31. package/package.json +43 -8
  32. package/bin/relinka-impl/deprecated/components/modes/shared.d.ts +0 -2
  33. package/bin/relinka-impl/deprecated/components/modes/shared.js +0 -4
  34. package/bin/relinka-impl/deprecated/components/relinka-deprecated/relinka.test.d.ts +0 -1
  35. package/bin/relinka-impl/deprecated/components/relinka-deprecated/relinka.test.js +0 -57
  36. package/bin/relinka-impl/impl-mod.d.ts +0 -19
  37. package/bin/relinka-impl/impl-mod.js +0 -317
  38. /package/bin/{relinka-impl/deprecated → deprecated}/components/levels/levels.js +0 -0
  39. /package/bin/{relinka-impl/deprecated → deprecated}/components/modes/basic.js +0 -0
  40. /package/bin/{relinka-impl/deprecated → deprecated}/components/modes/browser.js +0 -0
  41. /package/bin/{relinka-impl/deprecated → deprecated}/components/relinka-deprecated/logger.js +0 -0
  42. /package/bin/{relinka-impl/deprecated → deprecated}/components/relinka-deprecated/mod.js +0 -0
  43. /package/bin/{relinka-impl/deprecated → deprecated}/components/relinka-deprecated/relinka.js +0 -0
  44. /package/bin/{relinka-impl/deprecated → deprecated}/components/reporters/basic.js +0 -0
  45. /package/bin/{relinka-impl/deprecated → deprecated}/components/reporters/browser.js +0 -0
  46. /package/bin/{relinka-types.js → deprecated/impl-old.d.ts} +0 -0
  47. /package/bin/{relinka-impl/deprecated → deprecated}/utils/box.js +0 -0
  48. /package/bin/{relinka-impl/deprecated → deprecated}/utils/deprecatedColors.js +0 -0
  49. /package/bin/{relinka-impl/deprecated → deprecated}/utils/error.js +0 -0
  50. /package/bin/{relinka-impl/deprecated → deprecated}/utils/format.js +0 -0
  51. /package/bin/{relinka-impl/deprecated → deprecated}/utils/log.js +0 -0
  52. /package/bin/{relinka-impl/deprecated → deprecated}/utils/stream.js +0 -0
  53. /package/bin/{relinka-impl/deprecated → deprecated}/utils/string.js +0 -0
  54. /package/bin/{relinka-impl/deprecated → deprecated}/utils/tree.js +0 -0
@@ -1,141 +1,140 @@
1
- /// <reference types="node" />
2
- import type { LogTypeDeprecated } from "../../../../relinka-types.js";
3
- import type { InputLogObject, LogObject, RelinkaOptionsDeprecated, RelinkaReporterDeprecated } from "../../../../relinka-types.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: RelinkaOptionsDeprecated;
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?: RelinkaOptionsDeprecated["mockFn"];
22
- /**
23
- * Creates an instance of Relinka with specified options or defaults.
24
- *
25
- * @param {Partial<RelinkaOptionsDeprecated>} [options={}] - Configuration options for the Relinka instance.
26
- */
27
- constructor(options?: Partial<RelinkaOptionsDeprecated>);
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<RelinkaOptionsDeprecated>} options - Optional overrides for the new instance. See {@link RelinkaOptionsDeprecated}.
44
- * @returns {RelinkaInstanceDeprecated} A new Relinka instance. See {@link RelinkaInstanceDeprecated}.
45
- */
46
- create(options: Partial<RelinkaOptionsDeprecated>): 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 {RelinkaReporterDeprecated} reporter - The reporter to add. See {@link RelinkaReporterDeprecated}.
66
- * @returns {Relinka} The current Relinka instance.
67
- */
68
- addReporter(reporter: RelinkaReporterDeprecated): 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 {RelinkaReporterDeprecated} reporter - The reporter to remove. See {@link RelinkaReporterDeprecated}.
74
- * @returns {Relinka} The current Relinka instance.
75
- */
76
- removeReporter(reporter: RelinkaReporterDeprecated): any;
77
- /**
78
- * Replaces all reporters of the Relinka instance with the specified array of reporters.
79
- *
80
- * @param {RelinkaReporterDeprecated[]} reporters - The new reporters to set. See {@link RelinkaReporterDeprecated}.
81
- * @returns {Relinka} The current Relinka instance.
82
- */
83
- setReporters(reporters: RelinkaReporterDeprecated[]): 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 {RelinkaOptionsDeprecated["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link RelinkaOptionsDeprecated["mockFn"]}.
124
- */
125
- mockTypes(mockFn?: RelinkaOptionsDeprecated["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<RelinkaOptionsDeprecated>} [options={}] - Optional configuration options for the new Relinka instance. See {@link RelinkaOptionsDeprecated}.
139
- * @returns {RelinkaInstanceDeprecated} A new instance of RelinkaInterface. See {@link RelinkaInstanceDeprecated}.
140
- */
141
- export declare function createRelinkaDeprecated(options?: Partial<RelinkaOptionsDeprecated>): RelinkaInstanceDeprecated;
1
+ import type { LogTypeDeprecated } from "../../types.js";
2
+ import type { InputLogObject, LogObject, RelinkaOptionsDeprecated, RelinkaReporterDeprecated } from "../../types.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: RelinkaOptionsDeprecated;
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?: RelinkaOptionsDeprecated["mockFn"];
21
+ /**
22
+ * Creates an instance of Relinka with specified options or defaults.
23
+ *
24
+ * @param {Partial<RelinkaOptionsDeprecated>} [options={}] - Configuration options for the Relinka instance.
25
+ */
26
+ constructor(options?: Partial<RelinkaOptionsDeprecated>);
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<RelinkaOptionsDeprecated>} options - Optional overrides for the new instance. See {@link RelinkaOptionsDeprecated}.
43
+ * @returns {RelinkaInstanceDeprecated} A new Relinka instance. See {@link RelinkaInstanceDeprecated}.
44
+ */
45
+ create(options: Partial<RelinkaOptionsDeprecated>): RelinkaInstanceDeprecated;
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 {RelinkaInstanceDeprecated} A new Relinka instance. See {@link RelinkaInstanceDeprecated}.
51
+ */
52
+ withDefaults(defaults: InputLogObject): RelinkaInstanceDeprecated;
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 {RelinkaInstanceDeprecated} A new Relinka instance. See {@link RelinkaInstanceDeprecated}.
58
+ */
59
+ withTag(tag: string): RelinkaInstanceDeprecated;
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 {RelinkaReporterDeprecated} reporter - The reporter to add. See {@link RelinkaReporterDeprecated}.
65
+ * @returns {Relinka} The current Relinka instance.
66
+ */
67
+ addReporter(reporter: RelinkaReporterDeprecated): 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 {RelinkaReporterDeprecated} reporter - The reporter to remove. See {@link RelinkaReporterDeprecated}.
73
+ * @returns {Relinka} The current Relinka instance.
74
+ */
75
+ removeReporter(reporter: RelinkaReporterDeprecated): any;
76
+ /**
77
+ * Replaces all reporters of the Relinka instance with the specified array of reporters.
78
+ *
79
+ * @param {RelinkaReporterDeprecated[]} reporters - The new reporters to set. See {@link RelinkaReporterDeprecated}.
80
+ * @returns {Relinka} The current Relinka instance.
81
+ */
82
+ setReporters(reporters: RelinkaReporterDeprecated[]): 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: LogTypeDeprecated): 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 {RelinkaOptionsDeprecated["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link RelinkaOptionsDeprecated["mockFn"]}.
123
+ */
124
+ mockTypes(mockFn?: RelinkaOptionsDeprecated["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 RelinkaInstanceDeprecated = RelinkaInterface & Record<LogTypeDeprecated, LogFn>;
134
+ /**
135
+ * Utility for creating a new Relinka instance with optional configuration.
136
+ *
137
+ * @param {Partial<RelinkaOptionsDeprecated>} [options={}] - Optional configuration options for the new Relinka instance. See {@link RelinkaOptionsDeprecated}.
138
+ * @returns {RelinkaInstanceDeprecated} A new instance of RelinkaInterface. See {@link RelinkaInstanceDeprecated}.
139
+ */
140
+ export declare function createRelinkaDeprecated(options?: Partial<RelinkaOptionsDeprecated>): RelinkaInstanceDeprecated;
@@ -1,11 +1,11 @@
1
- import type { LogObject, RelinkaReporterDeprecated, FormatOptions, RelinkaOptionsDeprecated } from "../../../../relinka-types.js";
2
- export declare class BasicReporter implements RelinkaReporterDeprecated {
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: RelinkaOptionsDeprecated;
10
- }): any;
11
- }
1
+ import type { LogObject, RelinkaReporterDeprecated, FormatOptions, RelinkaOptionsDeprecated } from "../../types.js";
2
+ export declare class BasicReporter implements RelinkaReporterDeprecated {
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: RelinkaOptionsDeprecated;
10
+ }): any;
11
+ }
@@ -1,10 +1,10 @@
1
- import type { LogObject } from "../../../../relinka-types.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.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 { LogLevelDeprecated, LogTypeDeprecated } from "../../../../relinka-types.js";
2
- import type { FormatOptions, LogObject } from "../../../../relinka-types.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
+ import type { LogLevelDeprecated, LogTypeDeprecated } from "../../types.js";
2
+ import type { FormatOptions, LogObject } from "../../types.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,9 +1,7 @@
1
1
  import { isUnicodeSupported } from "@reliverse/runtime";
2
2
  import stringWidth from "string-width";
3
3
  import { BasicReporter } from "./basic.js";
4
- import {
5
- box
6
- } from "../../utils/box.js";
4
+ import { box } from "../../utils/box.js";
7
5
  import { colors } from "../../utils/deprecatedColors.js";
8
6
  import { parseStack } from "../../utils/error.js";
9
7
  import { stripAnsi } from "../../utils/string.js";
File without changes