@reliverse/relinka 1.4.7 → 1.5.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/README.md +4 -0
- package/bin/alias.d.ts +8 -0
- package/bin/alias.js +8 -0
- package/bin/impl.d.ts +29 -2
- package/bin/impl.js +58 -13
- package/bin/mod.d.ts +3 -2
- package/bin/mod.js +3 -1
- package/package.json +4 -28
- package/bin/types.d.ts +0 -0
- package/bin/types.js +0 -0
package/README.md
CHANGED
|
@@ -69,6 +69,10 @@ export async function main() {
|
|
|
69
69
|
"verbose",
|
|
70
70
|
"This SYNC verbose message can be seen only if verbose=true (in user config) AND config was loaded ",
|
|
71
71
|
);
|
|
72
|
+
// --- BOX LEVEL EXAMPLES ---
|
|
73
|
+
relinka("box", "This is a boxed message using direct syntax!");
|
|
74
|
+
relinka.box("This is a boxed message using method syntax!");
|
|
75
|
+
// --- LOG LEVEL EXAMPLES ---
|
|
72
76
|
relinka("log", "Hello! 👋");
|
|
73
77
|
relinka("log", "Great to see you here!");
|
|
74
78
|
relinka("info", "Everything is running smoothly");
|
package/bin/alias.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Alias exports for the relinka logger
|
|
3
|
+
* Provides convenient aliases for common logging needs
|
|
4
|
+
*/
|
|
5
|
+
import { relinka } from "./impl.js";
|
|
6
|
+
export { relinka as log, relinka as logger };
|
|
7
|
+
export declare function message(msg: string, ...args: unknown[]): void;
|
|
8
|
+
export declare function step(msg: string, ...args: unknown[]): void;
|
package/bin/alias.js
ADDED
package/bin/impl.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export type LogLevelConfig = {
|
|
|
34
34
|
/** Configuration for all log levels. */
|
|
35
35
|
export type LogLevelsConfig = Partial<Record<LogLevel, LogLevelConfig>>;
|
|
36
36
|
/** Log level types used by the logger. */
|
|
37
|
-
export type LogLevel = "error" | "fatal" | "info" | "success" | "verbose" | "warn" | "log" | "internal" | "null";
|
|
37
|
+
export type LogLevel = "error" | "fatal" | "info" | "success" | "verbose" | "warn" | "log" | "internal" | "null" | "step" | "box";
|
|
38
38
|
/**
|
|
39
39
|
* Configuration options for the Relinka logger.
|
|
40
40
|
* All properties are optional to allow for partial configuration.
|
|
@@ -131,11 +131,34 @@ export declare function truncateString(msg: string, maxLength?: number): string;
|
|
|
131
131
|
* Exhaustiveness check. If we land here, we missed a union case.
|
|
132
132
|
*/
|
|
133
133
|
export declare function casesHandled(unexpectedCase: never): never;
|
|
134
|
+
/**
|
|
135
|
+
* Enhanced relinka function type that supports both traditional and method syntax
|
|
136
|
+
*/
|
|
137
|
+
export type RelinkaFunction = {
|
|
138
|
+
(type: LogLevel | "clear", message: string, ...args: unknown[]): undefined | never;
|
|
139
|
+
error(message: string, ...args: unknown[]): void;
|
|
140
|
+
fatal(message: string, ...args: unknown[]): never;
|
|
141
|
+
info(message: string, ...args: unknown[]): void;
|
|
142
|
+
success(message: string, ...args: unknown[]): void;
|
|
143
|
+
verbose(message: string, ...args: unknown[]): void;
|
|
144
|
+
warn(message: string, ...args: unknown[]): void;
|
|
145
|
+
log(message: string, ...args: unknown[]): void;
|
|
146
|
+
internal(message: string, ...args: unknown[]): void;
|
|
147
|
+
null(message: string, ...args: unknown[]): void;
|
|
148
|
+
step(message: string, ...args: unknown[]): void;
|
|
149
|
+
box(message: string, ...args: unknown[]): void;
|
|
150
|
+
message(message: string, ...args: unknown[]): void;
|
|
151
|
+
clear(): void;
|
|
152
|
+
};
|
|
134
153
|
/**
|
|
135
154
|
* Logs a message synchronously using the current config.
|
|
136
155
|
* If type === "fatal", logs a fatal error and throws (never returns).
|
|
156
|
+
*
|
|
157
|
+
* Can be used in two ways:
|
|
158
|
+
* - relinka("level", message, ...args) - traditional syntax
|
|
159
|
+
* - relinka.level(message, ...args) - method syntax
|
|
137
160
|
*/
|
|
138
|
-
export declare
|
|
161
|
+
export declare const relinka: RelinkaFunction;
|
|
139
162
|
/**
|
|
140
163
|
* Logs a message asynchronously, waiting for the config to be fully loaded.
|
|
141
164
|
* If type === "fatal", logs a fatal error and throws (never returns).
|
|
@@ -145,3 +168,7 @@ export declare function relinkaAsync(type: LogLevel, message: string, ...args: u
|
|
|
145
168
|
* Type helper for user config files.
|
|
146
169
|
*/
|
|
147
170
|
export declare function defineConfig(config: Partial<RelinkaConfig>): Partial<RelinkaConfig>;
|
|
171
|
+
/**
|
|
172
|
+
* Simple box formatting function
|
|
173
|
+
*/
|
|
174
|
+
export declare function formatBox(text: string): string;
|
package/bin/impl.js
CHANGED
|
@@ -74,6 +74,18 @@ const DEFAULT_RELINKA_CONFIG = {
|
|
|
74
74
|
spacing: 3
|
|
75
75
|
},
|
|
76
76
|
log: { symbol: "\u2502", fallbackSymbol: "|", color: "dim", spacing: 3 },
|
|
77
|
+
step: {
|
|
78
|
+
symbol: "\u2192",
|
|
79
|
+
fallbackSymbol: "[STEP]",
|
|
80
|
+
color: "blueBright",
|
|
81
|
+
spacing: 3
|
|
82
|
+
},
|
|
83
|
+
box: {
|
|
84
|
+
symbol: "\u25A0",
|
|
85
|
+
fallbackSymbol: "[BOX]",
|
|
86
|
+
color: "whiteBright",
|
|
87
|
+
spacing: 1
|
|
88
|
+
},
|
|
77
89
|
null: { symbol: "", fallbackSymbol: "", color: "dim", spacing: 0 }
|
|
78
90
|
}
|
|
79
91
|
};
|
|
@@ -84,7 +96,7 @@ function isUnicodeSupported() {
|
|
|
84
96
|
if (process.platform === "win32") {
|
|
85
97
|
const osRelease = os.release();
|
|
86
98
|
const match = /(\d+)\.(\d+)/.exec(osRelease);
|
|
87
|
-
if (match && Number.parseInt(match[1], 10) >= 10) {
|
|
99
|
+
if (match && Number.parseInt(match[1] ?? "0", 10) >= 10) {
|
|
88
100
|
return true;
|
|
89
101
|
}
|
|
90
102
|
if (process.env.TERM_PROGRAM === "mintty") {
|
|
@@ -170,34 +182,34 @@ initializeConfig().catch((err) => {
|
|
|
170
182
|
}
|
|
171
183
|
});
|
|
172
184
|
function isVerboseEnabled(config) {
|
|
173
|
-
return config.verbose ?? DEFAULT_RELINKA_CONFIG.verbose;
|
|
185
|
+
return config.verbose ?? DEFAULT_RELINKA_CONFIG.verbose ?? false;
|
|
174
186
|
}
|
|
175
187
|
function isColorEnabled(config) {
|
|
176
188
|
return !(config.disableColors ?? DEFAULT_RELINKA_CONFIG.disableColors);
|
|
177
189
|
}
|
|
178
190
|
function getLogDir(config) {
|
|
179
|
-
return config.dirs?.logDir ?? DEFAULT_RELINKA_CONFIG.dirs
|
|
191
|
+
return config.dirs?.logDir ?? DEFAULT_RELINKA_CONFIG.dirs?.logDir ?? "logs";
|
|
180
192
|
}
|
|
181
193
|
function isDailyLogsEnabled(config) {
|
|
182
|
-
return config.dirs?.dailyLogs ?? DEFAULT_RELINKA_CONFIG.dirs
|
|
194
|
+
return config.dirs?.dailyLogs ?? DEFAULT_RELINKA_CONFIG.dirs?.dailyLogs ?? false;
|
|
183
195
|
}
|
|
184
196
|
function shouldSaveLogs(config) {
|
|
185
|
-
return config.saveLogsToFile ?? DEFAULT_RELINKA_CONFIG.saveLogsToFile;
|
|
197
|
+
return config.saveLogsToFile ?? DEFAULT_RELINKA_CONFIG.saveLogsToFile ?? false;
|
|
186
198
|
}
|
|
187
199
|
function getMaxLogFiles(config) {
|
|
188
|
-
return config.dirs?.maxLogFiles ?? DEFAULT_RELINKA_CONFIG.dirs
|
|
200
|
+
return config.dirs?.maxLogFiles ?? DEFAULT_RELINKA_CONFIG.dirs?.maxLogFiles ?? 0;
|
|
189
201
|
}
|
|
190
202
|
function getBaseLogName(config) {
|
|
191
|
-
return config.logFilePath ?? DEFAULT_RELINKA_CONFIG.logFilePath;
|
|
203
|
+
return config.logFilePath ?? DEFAULT_RELINKA_CONFIG.logFilePath ?? "relinka.log";
|
|
192
204
|
}
|
|
193
205
|
function getBufferSize(config) {
|
|
194
|
-
return config.bufferSize ?? DEFAULT_RELINKA_CONFIG.bufferSize;
|
|
206
|
+
return config.bufferSize ?? DEFAULT_RELINKA_CONFIG.bufferSize ?? 4096;
|
|
195
207
|
}
|
|
196
208
|
function getMaxBufferAge(config) {
|
|
197
|
-
return config.maxBufferAge ?? DEFAULT_RELINKA_CONFIG.maxBufferAge;
|
|
209
|
+
return config.maxBufferAge ?? DEFAULT_RELINKA_CONFIG.maxBufferAge ?? 5e3;
|
|
198
210
|
}
|
|
199
211
|
function getCleanupInterval(config) {
|
|
200
|
-
return config.cleanupInterval ?? DEFAULT_RELINKA_CONFIG.cleanupInterval;
|
|
212
|
+
return config.cleanupInterval ?? DEFAULT_RELINKA_CONFIG.cleanupInterval ?? 1e4;
|
|
201
213
|
}
|
|
202
214
|
function isDevEnv() {
|
|
203
215
|
return process.env.NODE_ENV === "development";
|
|
@@ -273,7 +285,11 @@ function formatLogMessage(config, level, msg, details) {
|
|
|
273
285
|
const { symbol, spacing } = getLevelStyle(config, level);
|
|
274
286
|
const symbolWithSpaces = symbol ? `${symbol}${" ".repeat(spacing)}` : "";
|
|
275
287
|
const prefix = timestamp ? `[${timestamp}] ` : "";
|
|
276
|
-
|
|
288
|
+
let content = `${prefix}${symbolWithSpaces}${msg}${detailsStr}`;
|
|
289
|
+
if (level === "box") {
|
|
290
|
+
content = formatBox(content);
|
|
291
|
+
}
|
|
292
|
+
return content;
|
|
277
293
|
}
|
|
278
294
|
const consoleMethodMap = {
|
|
279
295
|
error: console.error,
|
|
@@ -283,6 +299,8 @@ const consoleMethodMap = {
|
|
|
283
299
|
success: console.log,
|
|
284
300
|
verbose: console.log,
|
|
285
301
|
log: console.log,
|
|
302
|
+
step: console.log,
|
|
303
|
+
box: console.log,
|
|
286
304
|
null: console.log
|
|
287
305
|
};
|
|
288
306
|
function logToConsole(config, level, formattedMessage) {
|
|
@@ -526,7 +544,7 @@ function registerExitHandlers() {
|
|
|
526
544
|
process.once("SIGTERM", sigtermHandler);
|
|
527
545
|
}
|
|
528
546
|
registerExitHandlers();
|
|
529
|
-
export
|
|
547
|
+
export const relinka = (type, message, ...args) => {
|
|
530
548
|
if (type === "clear") {
|
|
531
549
|
console.clear();
|
|
532
550
|
return;
|
|
@@ -571,7 +589,20 @@ export function relinka(type, message, ...args) {
|
|
|
571
589
|
});
|
|
572
590
|
}
|
|
573
591
|
}
|
|
574
|
-
}
|
|
592
|
+
};
|
|
593
|
+
relinka.error = (message, ...args) => relinka("error", message, ...args);
|
|
594
|
+
relinka.fatal = (message, ...args) => relinka("fatal", message, ...args);
|
|
595
|
+
relinka.info = (message, ...args) => relinka("info", message, ...args);
|
|
596
|
+
relinka.success = (message, ...args) => relinka("success", message, ...args);
|
|
597
|
+
relinka.verbose = (message, ...args) => relinka("verbose", message, ...args);
|
|
598
|
+
relinka.warn = (message, ...args) => relinka("warn", message, ...args);
|
|
599
|
+
relinka.log = (message, ...args) => relinka("log", message, ...args);
|
|
600
|
+
relinka.internal = (message, ...args) =>
|
|
601
|
+
relinka.null = (message, ...args) => relinka("null", message, ...args);
|
|
602
|
+
relinka.step = (message, ...args) => relinka("step", message, ...args);
|
|
603
|
+
relinka.box = (message, ...args) => relinka("box", message, ...args);
|
|
604
|
+
relinka.clear = () => relinka("clear", "");
|
|
605
|
+
relinka.message = (message, ...args) => relinka("log", message, ...args);
|
|
575
606
|
export async function relinkaAsync(type, message, ...args) {
|
|
576
607
|
if (message === "") {
|
|
577
608
|
console.log();
|
|
@@ -612,3 +643,17 @@ export async function relinkaAsync(type, message, ...args) {
|
|
|
612
643
|
export function defineConfig(config) {
|
|
613
644
|
return config;
|
|
614
645
|
}
|
|
646
|
+
export function formatBox(text) {
|
|
647
|
+
const lines = text.split("\n");
|
|
648
|
+
const maxWidth = Math.max(...lines.map((line) => line.length));
|
|
649
|
+
const width = maxWidth + 4;
|
|
650
|
+
const top = `\u250C${"\u2500".repeat(width)}\u2510`;
|
|
651
|
+
const bottom = `\u2514${"\u2500".repeat(width)}\u2518`;
|
|
652
|
+
const content = lines.map((line) => {
|
|
653
|
+
const padding = width - line.length;
|
|
654
|
+
return `\u2502 ${line}${" ".repeat(padding)}\u2502`;
|
|
655
|
+
}).join("\n");
|
|
656
|
+
return `${top}
|
|
657
|
+
${content}
|
|
658
|
+
${bottom}`;
|
|
659
|
+
}
|
package/bin/mod.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export {
|
|
1
|
+
export { message, step, log, logger } from "./alias.js";
|
|
2
|
+
export type { RelinkaSpecialDirsConfig, RelinkaDirsConfig, LogLevelConfig, LogLevelsConfig, LogLevel, RelinkaConfig, LogFileInfo, RelinkaFunction, } from "./impl.js";
|
|
3
|
+
export { relinkaConfig, relinkaShutdown, flushAllLogBuffers, shouldNeverHappen, truncateString, casesHandled, relinka, relinkaAsync, defineConfig, formatBox, } from "./impl.js";
|
package/bin/mod.js
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
-
"@reliverse/pathkit": "^1.
|
|
3
|
+
"@reliverse/pathkit": "^1.3.4",
|
|
4
4
|
"@reliverse/relico": "^1.1.2",
|
|
5
|
-
"@reliverse/relifso": "^1.
|
|
5
|
+
"@reliverse/relifso": "^1.4.5",
|
|
6
6
|
"c12": "^3.0.4"
|
|
7
7
|
},
|
|
8
8
|
"description": "@reliverse/relinka is a modern, minimal logging library that actually feels right. It's not just pretty output — it's a system: smart formatting, file-safe logging, runtime config support, and a fatal mode built for developers who care about correctness.",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"name": "@reliverse/relinka",
|
|
12
12
|
"type": "module",
|
|
13
|
-
"version": "1.
|
|
13
|
+
"version": "1.5.1",
|
|
14
14
|
"keywords": [
|
|
15
15
|
"logger",
|
|
16
16
|
"consola",
|
|
@@ -27,31 +27,7 @@
|
|
|
27
27
|
"unified",
|
|
28
28
|
"universal"
|
|
29
29
|
],
|
|
30
|
-
"devDependencies": {
|
|
31
|
-
"@biomejs/biome": "1.9.4",
|
|
32
|
-
"@eslint/js": "^9.27.0",
|
|
33
|
-
"@reliverse/dler": "^1.4.6",
|
|
34
|
-
"@reliverse/repris": "^1.0.0",
|
|
35
|
-
"@reliverse/runtime": "^1.0.3",
|
|
36
|
-
"@stylistic/eslint-plugin": "^4.2.0",
|
|
37
|
-
"@total-typescript/ts-reset": "^0.6.1",
|
|
38
|
-
"@types/bun": "^1.2.14",
|
|
39
|
-
"@types/node": "^22.15.21",
|
|
40
|
-
"@types/sentencer": "^0.2.3",
|
|
41
|
-
"defu": "^6.1.4",
|
|
42
|
-
"eslint": "^9.27.0",
|
|
43
|
-
"eslint-plugin-no-relative-import-paths": "^1.6.1",
|
|
44
|
-
"eslint-plugin-perfectionist": "^4.13.0",
|
|
45
|
-
"jiti": "^2.4.2",
|
|
46
|
-
"knip": "^5.57.2",
|
|
47
|
-
"pathe": "^2.0.3",
|
|
48
|
-
"sentencer": "^0.2.1",
|
|
49
|
-
"std-env": "^3.9.0",
|
|
50
|
-
"string-width": "^7.2.0",
|
|
51
|
-
"tsx": "^4.19.4",
|
|
52
|
-
"typescript": "^5.8.3",
|
|
53
|
-
"typescript-eslint": "^8.32.1"
|
|
54
|
-
},
|
|
30
|
+
"devDependencies": {},
|
|
55
31
|
"exports": {
|
|
56
32
|
".": "./bin/mod.js"
|
|
57
33
|
},
|
package/bin/types.d.ts
DELETED
|
File without changes
|
package/bin/types.js
DELETED
|
File without changes
|