@reliverse/relinka 1.3.8 → 1.4.1
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/LICENSE +1 -1
- package/README.md +206 -70
- package/bin/{core-impl/deprecated → deprecated}/components/levels/levels.d.ts +1 -1
- package/bin/{core-impl/deprecated → deprecated}/components/modes/basic.d.ts +1 -1
- package/bin/{core-impl/deprecated → deprecated}/components/modes/browser.d.ts +1 -1
- package/bin/deprecated/components/modes/shared.d.ts +2 -0
- package/bin/deprecated/components/modes/shared.js +1 -0
- package/bin/{core-impl/deprecated → deprecated}/components/relinka-deprecated/mod.d.ts +1 -1
- package/bin/{core-impl/deprecated → deprecated}/components/relinka-deprecated/relinka.d.ts +2 -2
- package/bin/{core-impl/deprecated → deprecated}/components/reporters/basic.d.ts +1 -1
- package/bin/{core-impl/deprecated → deprecated}/components/reporters/browser.d.ts +1 -1
- package/bin/{core-impl/deprecated → deprecated}/components/reporters/fancy.d.ts +2 -2
- package/bin/{core-impl/deprecated → deprecated}/components/reporters/fancy.js +1 -3
- package/bin/deprecated/impl-old.js +0 -0
- package/bin/{core-types.d.ts → deprecated/types.d.ts} +0 -32
- package/bin/deprecated/types.js +0 -0
- package/bin/deprecated/utils/format-new.d.ts +15 -0
- package/bin/deprecated/utils/format-new.js +13 -0
- package/bin/{core-impl/deprecated → deprecated}/utils/format.d.ts +2 -2
- package/bin/{core-impl/deprecated → deprecated}/utils/format.js +4 -4
- package/bin/impl.d.ts +147 -0
- package/bin/impl.js +600 -0
- package/bin/main.d.ts +24 -22
- package/bin/main.js +26 -23
- package/bin/types.d.ts +0 -0
- package/bin/types.js +0 -0
- package/package.json +43 -7
- package/bin/core-impl/deprecated/components/modes/shared.d.ts +0 -2
- package/bin/core-impl/deprecated/components/modes/shared.js +0 -4
- package/bin/core-impl/deprecated/components/relinka-deprecated/relinka.test.d.ts +0 -1
- package/bin/core-impl/deprecated/components/relinka-deprecated/relinka.test.js +0 -57
- package/bin/core-impl/impl-mod.d.ts +0 -19
- package/bin/core-impl/impl-mod.js +0 -321
- /package/bin/{core-impl/deprecated → deprecated}/components/levels/levels.js +0 -0
- /package/bin/{core-impl/deprecated → deprecated}/components/modes/basic.js +0 -0
- /package/bin/{core-impl/deprecated → deprecated}/components/modes/browser.js +0 -0
- /package/bin/{core-impl/deprecated → deprecated}/components/relinka-deprecated/logger.d.ts +0 -0
- /package/bin/{core-impl/deprecated → deprecated}/components/relinka-deprecated/logger.js +0 -0
- /package/bin/{core-impl/deprecated → deprecated}/components/relinka-deprecated/mod.js +0 -0
- /package/bin/{core-impl/deprecated → deprecated}/components/relinka-deprecated/relinka.js +0 -0
- /package/bin/{core-impl/deprecated → deprecated}/components/reporters/basic.js +0 -0
- /package/bin/{core-impl/deprecated → deprecated}/components/reporters/browser.js +0 -0
- /package/bin/{core-types.js → deprecated/impl-old.d.ts} +0 -0
- /package/bin/{core-impl/deprecated → deprecated}/utils/box.d.ts +0 -0
- /package/bin/{core-impl/deprecated → deprecated}/utils/box.js +0 -0
- /package/bin/{core-impl/deprecated → deprecated}/utils/deprecatedColors.d.ts +0 -0
- /package/bin/{core-impl/deprecated → deprecated}/utils/deprecatedColors.js +0 -0
- /package/bin/{core-impl/deprecated → deprecated}/utils/error.d.ts +0 -0
- /package/bin/{core-impl/deprecated → deprecated}/utils/error.js +0 -0
- /package/bin/{core-impl/deprecated → deprecated}/utils/log.d.ts +0 -0
- /package/bin/{core-impl/deprecated → deprecated}/utils/log.js +0 -0
- /package/bin/{core-impl/deprecated → deprecated}/utils/stream.d.ts +0 -0
- /package/bin/{core-impl/deprecated → deprecated}/utils/stream.js +0 -0
- /package/bin/{core-impl/deprecated → deprecated}/utils/string.d.ts +0 -0
- /package/bin/{core-impl/deprecated → deprecated}/utils/string.js +0 -0
- /package/bin/{core-impl/deprecated → deprecated}/utils/tree.d.ts +0 -0
- /package/bin/{core-impl/deprecated → deprecated}/utils/tree.js +0 -0
package/bin/impl.d.ts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type { DefaultColorKeys } from "@reliverse/relico";
|
|
2
|
+
/** Configuration for special directory handling. */
|
|
3
|
+
export type RelinkaSpecialDirsConfig = {
|
|
4
|
+
distDirNames?: string[];
|
|
5
|
+
useParentConfigInDist?: boolean;
|
|
6
|
+
};
|
|
7
|
+
/** Configuration for directory-related settings. */
|
|
8
|
+
export type RelinkaDirsConfig = {
|
|
9
|
+
dailyLogs?: boolean;
|
|
10
|
+
logDir?: string;
|
|
11
|
+
maxLogFiles?: number;
|
|
12
|
+
specialDirs?: RelinkaSpecialDirsConfig;
|
|
13
|
+
};
|
|
14
|
+
/** Configuration for a single log level. */
|
|
15
|
+
export type LogLevelConfig = {
|
|
16
|
+
/**
|
|
17
|
+
* Symbol to display for this log level.
|
|
18
|
+
* @see https://symbl.cc
|
|
19
|
+
*/
|
|
20
|
+
symbol: string;
|
|
21
|
+
/**
|
|
22
|
+
* Fallback symbol to use if Unicode is not supported.
|
|
23
|
+
*/
|
|
24
|
+
fallbackSymbol: string;
|
|
25
|
+
/**
|
|
26
|
+
* Color to use for this log level.
|
|
27
|
+
*/
|
|
28
|
+
color: DefaultColorKeys;
|
|
29
|
+
/**
|
|
30
|
+
* Number of spaces after the symbol/fallback
|
|
31
|
+
*/
|
|
32
|
+
spacing?: number;
|
|
33
|
+
};
|
|
34
|
+
/** Configuration for all log levels. */
|
|
35
|
+
export type LogLevelsConfig = Partial<Record<LogLevel, LogLevelConfig>>;
|
|
36
|
+
/** Log level types used by the logger. */
|
|
37
|
+
export type LogLevel = "error" | "fatal" | "info" | "success" | "verbose" | "warn" | "log";
|
|
38
|
+
/**
|
|
39
|
+
* Configuration options for the Relinka logger.
|
|
40
|
+
* All properties are optional to allow for partial configuration.
|
|
41
|
+
* Defaults will be applied during initialization.
|
|
42
|
+
*/
|
|
43
|
+
export type RelinkaConfig = {
|
|
44
|
+
/**
|
|
45
|
+
* Enables verbose (aka debug) mode for detailed logging.
|
|
46
|
+
*
|
|
47
|
+
* `true` here works only for end-users of CLIs/libs when theirs developers
|
|
48
|
+
* has been awaited for user's config via `@reliverse/relinka`'s `await relinkaConfig;`
|
|
49
|
+
*/
|
|
50
|
+
verbose?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Configuration for directory-related settings.
|
|
53
|
+
* - `dailyLogs`: If true, logs will be stored in a daily subdirectory.
|
|
54
|
+
* - `logDir`: The base directory for logs.
|
|
55
|
+
* - `maxLogFiles`: The maximum number of log files to keep before cleanup.
|
|
56
|
+
* - `specialDirs`: Configuration for special directory handling.
|
|
57
|
+
* - `distDirNames`: An array of directory names to check for special handling.
|
|
58
|
+
* - `useParentConfigInDist`: If true, use the parent config in dist directories.
|
|
59
|
+
*/
|
|
60
|
+
dirs?: RelinkaDirsConfig;
|
|
61
|
+
/**
|
|
62
|
+
* Disables color output in the console.
|
|
63
|
+
*/
|
|
64
|
+
disableColors?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Path to the log file.
|
|
67
|
+
*/
|
|
68
|
+
logFilePath?: string;
|
|
69
|
+
/**
|
|
70
|
+
* If true, logs will be saved to a file.
|
|
71
|
+
*/
|
|
72
|
+
saveLogsToFile?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Configuration for timestamp in log messages.
|
|
75
|
+
*/
|
|
76
|
+
timestamp?: {
|
|
77
|
+
/**
|
|
78
|
+
* If true, timestamps will be added to log messages.
|
|
79
|
+
*/
|
|
80
|
+
enabled: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* The format for timestamps. Default is YYYY-MM-DD HH:mm:ss.SSS
|
|
83
|
+
*/
|
|
84
|
+
format?: string;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Allows to customize the log levels.
|
|
88
|
+
*/
|
|
89
|
+
levels?: LogLevelsConfig;
|
|
90
|
+
/**
|
|
91
|
+
* Controls how often the log cleanup runs (in milliseconds)
|
|
92
|
+
* Default: 10000 (10 seconds)
|
|
93
|
+
*/
|
|
94
|
+
cleanupInterval?: number;
|
|
95
|
+
/**
|
|
96
|
+
* Maximum size of the log write buffer before flushing to disk (in bytes)
|
|
97
|
+
* Default: 4096 (4KB)
|
|
98
|
+
*/
|
|
99
|
+
bufferSize?: number;
|
|
100
|
+
/**
|
|
101
|
+
* Maximum time to hold logs in buffer before flushing to disk (in milliseconds)
|
|
102
|
+
* Default: 5000 (5 seconds)
|
|
103
|
+
*/
|
|
104
|
+
maxBufferAge?: number;
|
|
105
|
+
};
|
|
106
|
+
/** Represents information about a log file for cleanup purposes. */
|
|
107
|
+
export type LogFileInfo = {
|
|
108
|
+
path: string;
|
|
109
|
+
mtime: number;
|
|
110
|
+
};
|
|
111
|
+
/** Promise resolved once the user's config (if any) is merged. */
|
|
112
|
+
export declare const relinkaConfig: Promise<RelinkaConfig>;
|
|
113
|
+
/**
|
|
114
|
+
* Shuts down the logger, flushing all buffers and clearing timers.
|
|
115
|
+
* As Relinka user - call this at the end of your program to prevent hanging.
|
|
116
|
+
*/
|
|
117
|
+
export declare function relinkaShutdown(): Promise<void>;
|
|
118
|
+
/**
|
|
119
|
+
* Flushes all log buffers to disk. Used before process exit or on demand.
|
|
120
|
+
*/
|
|
121
|
+
export declare function flushAllLogBuffers(): Promise<void>;
|
|
122
|
+
/**
|
|
123
|
+
* If something truly impossible happened, log + throw.
|
|
124
|
+
*/
|
|
125
|
+
export declare function shouldNeverHappen(message: string, ...args: unknown[]): never;
|
|
126
|
+
/**
|
|
127
|
+
* Truncates a string to a specified length, adding "…" if truncated.
|
|
128
|
+
*/
|
|
129
|
+
export declare function truncateString(msg: string, maxLength?: number): string;
|
|
130
|
+
/**
|
|
131
|
+
* Exhaustiveness check. If we land here, we missed a union case.
|
|
132
|
+
*/
|
|
133
|
+
export declare function casesHandled(unexpectedCase: never): never;
|
|
134
|
+
/**
|
|
135
|
+
* Logs a message synchronously using the current config.
|
|
136
|
+
* If type === "fatal", logs a fatal error and throws (never returns).
|
|
137
|
+
*/
|
|
138
|
+
export declare function relinka(type: LogLevel | "clear", message: string, ...args: unknown[]): undefined | never;
|
|
139
|
+
/**
|
|
140
|
+
* Logs a message asynchronously, waiting for the config to be fully loaded.
|
|
141
|
+
* If type === "fatal", logs a fatal error and throws (never returns).
|
|
142
|
+
*/
|
|
143
|
+
export declare function relinkaAsync(type: LogLevel, message: string, ...args: unknown[]): Promise<void>;
|
|
144
|
+
/**
|
|
145
|
+
* Type helper for user config files.
|
|
146
|
+
*/
|
|
147
|
+
export declare function defineConfig(config: Partial<RelinkaConfig>): Partial<RelinkaConfig>;
|