@reliverse/relinka 1.3.5 → 1.3.7
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 +114 -76
- package/bin/main.d.ts +22 -1
- package/bin/main.js +58 -1
- package/bin/relinka-impl/deprecated/components/levels/levels.d.ts +13 -0
- package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/modes/basic.d.ts +3 -3
- package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/modes/browser.d.ts +4 -4
- package/bin/relinka-impl/deprecated/components/modes/shared.d.ts +2 -0
- package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/relinka-deprecated/mod.d.ts +3 -3
- package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/relinka-deprecated/relinka.d.ts +18 -18
- package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/relinka-deprecated/relinka.js +6 -6
- package/bin/relinka-impl/deprecated/components/relinka-deprecated/relinka.test.d.ts +1 -0
- package/bin/relinka-impl/deprecated/components/relinka-deprecated/relinka.test.js +57 -0
- package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/reporters/basic.d.ts +3 -3
- package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/reporters/browser.d.ts +1 -1
- package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/reporters/fancy.d.ts +2 -2
- package/bin/relinka-impl/impl-mod.d.ts +19 -0
- package/bin/relinka-impl/impl-mod.js +317 -0
- package/bin/{types.d.ts → relinka-types.d.ts} +51 -7
- package/package.json +9 -26
- package/bin/libs/core/core-impl/deprecated/components/levels/levels.d.ts +0 -26
- package/bin/libs/core/core-impl/deprecated/components/modes/shared.d.ts +0 -3
- package/bin/libs/core/core-main.d.ts +0 -23
- package/bin/libs/core/core-main.js +0 -49
- package/bin/libs/core/core-types.d.ts +0 -1
- package/bin/libs/core/core-types.js +0 -1
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/levels/levels.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/modes/basic.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/modes/browser.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/modes/shared.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/relinka-deprecated/logger.d.ts +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/relinka-deprecated/logger.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/relinka-deprecated/mod.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/reporters/basic.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/reporters/browser.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/reporters/fancy.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/box.d.ts +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/box.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/deprecatedColors.d.ts +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/deprecatedColors.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/error.d.ts +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/error.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/format.d.ts +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/format.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/log.d.ts +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/log.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/stream.d.ts +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/stream.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/string.d.ts +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/string.js +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/tree.d.ts +0 -0
- /package/bin/{libs/core/core-impl → relinka-impl}/deprecated/utils/tree.js +0 -0
- /package/bin/{types.js → relinka-types.js} +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { RelinkaConfig, LogLevel } from "../relinka-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Promise that resolves once c12 loads and merges the config.
|
|
4
|
+
*/
|
|
5
|
+
export declare const relinkaConfig: Promise<RelinkaConfig>;
|
|
6
|
+
/**
|
|
7
|
+
* Logs a message synchronously using the current config.
|
|
8
|
+
* Skips debug-level logs unless `debug` is true in the config.
|
|
9
|
+
*/
|
|
10
|
+
export declare function relinka(type: LogLevel, message: string, ...args: unknown[]): void;
|
|
11
|
+
/**
|
|
12
|
+
* Logs a message asynchronously, waiting for the config to be fully loaded.
|
|
13
|
+
* Also handles file writing and log cleanup if enabled.
|
|
14
|
+
*/
|
|
15
|
+
export declare function relinkaAsync(type: LogLevel, message: string, ...args: unknown[]): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Type helper for user config files.
|
|
18
|
+
*/
|
|
19
|
+
export declare function defineConfig(config: Partial<RelinkaConfig>): Partial<RelinkaConfig>;
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import { re } from "@reliverse/relico";
|
|
2
|
+
import { loadConfig } from "c12";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
import path from "pathe";
|
|
5
|
+
const DEV_VERBOSE = false;
|
|
6
|
+
const DEFAULT_RELINKA_CONFIG = {
|
|
7
|
+
debug: false,
|
|
8
|
+
dirs: {
|
|
9
|
+
dailyLogs: false,
|
|
10
|
+
logDir: ".reliverse/logs",
|
|
11
|
+
maxLogFiles: 0,
|
|
12
|
+
specialDirs: {
|
|
13
|
+
distDirNames: ["dist", "dist-jsr", "dist-npm", "dist-libs"],
|
|
14
|
+
useParentConfigInDist: true
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
disableColors: false,
|
|
18
|
+
logFilePath: "relinka.log",
|
|
19
|
+
saveLogsToFile: false,
|
|
20
|
+
withTimestamp: false
|
|
21
|
+
};
|
|
22
|
+
let currentConfig = { ...DEFAULT_RELINKA_CONFIG };
|
|
23
|
+
let isConfigInitialized = false;
|
|
24
|
+
let resolveRelinkaConfig;
|
|
25
|
+
export const relinkaConfig = new Promise((resolve) => {
|
|
26
|
+
resolveRelinkaConfig = resolve;
|
|
27
|
+
});
|
|
28
|
+
async function initializeConfig() {
|
|
29
|
+
try {
|
|
30
|
+
const result = await loadConfig({
|
|
31
|
+
name: "relinka",
|
|
32
|
+
// base name => tries relinka.config.*, .relinkarc, etc.
|
|
33
|
+
cwd: process.cwd(),
|
|
34
|
+
// working directory
|
|
35
|
+
dotenv: false,
|
|
36
|
+
packageJson: false,
|
|
37
|
+
rcFile: false,
|
|
38
|
+
globalRc: false,
|
|
39
|
+
defaults: DEFAULT_RELINKA_CONFIG
|
|
40
|
+
// lowest priority
|
|
41
|
+
// overrides: {}, // highest priority if we would need to forcibly override
|
|
42
|
+
});
|
|
43
|
+
currentConfig = result.config;
|
|
44
|
+
isConfigInitialized = true;
|
|
45
|
+
if (DEV_VERBOSE) {
|
|
46
|
+
console.log(
|
|
47
|
+
"[Relinka Config Debug] Config file used:",
|
|
48
|
+
result.configFile
|
|
49
|
+
);
|
|
50
|
+
console.log("[Relinka Config Debug] All merged layers:", result.layers);
|
|
51
|
+
console.log("[Relinka Config Debug] Final configuration:", currentConfig);
|
|
52
|
+
}
|
|
53
|
+
if (resolveRelinkaConfig) {
|
|
54
|
+
resolveRelinkaConfig(currentConfig);
|
|
55
|
+
}
|
|
56
|
+
} catch (err) {
|
|
57
|
+
console.error(
|
|
58
|
+
`[Relinka Config Error] Failed to load config: ${err instanceof Error ? err.message : String(err)}`
|
|
59
|
+
);
|
|
60
|
+
currentConfig = { ...DEFAULT_RELINKA_CONFIG };
|
|
61
|
+
isConfigInitialized = true;
|
|
62
|
+
if (resolveRelinkaConfig) {
|
|
63
|
+
resolveRelinkaConfig(currentConfig);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
initializeConfig().catch((err) => {
|
|
68
|
+
console.error(
|
|
69
|
+
`[Relinka Config Error] Unhandled error: ${err instanceof Error ? err.message : String(err)}`
|
|
70
|
+
);
|
|
71
|
+
if (!isConfigInitialized) {
|
|
72
|
+
currentConfig = { ...DEFAULT_RELINKA_CONFIG };
|
|
73
|
+
isConfigInitialized = true;
|
|
74
|
+
if (resolveRelinkaConfig) {
|
|
75
|
+
resolveRelinkaConfig(currentConfig);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
function isDebugEnabled(config) {
|
|
80
|
+
return config.debug ?? DEFAULT_RELINKA_CONFIG.debug;
|
|
81
|
+
}
|
|
82
|
+
function isColorEnabled(config) {
|
|
83
|
+
return !(config.disableColors ?? DEFAULT_RELINKA_CONFIG.disableColors);
|
|
84
|
+
}
|
|
85
|
+
function getLogDir(config) {
|
|
86
|
+
return config.dirs?.logDir ?? DEFAULT_RELINKA_CONFIG.dirs.logDir;
|
|
87
|
+
}
|
|
88
|
+
function isDailyLogsEnabled(config) {
|
|
89
|
+
return config.dirs?.dailyLogs ?? DEFAULT_RELINKA_CONFIG.dirs.dailyLogs;
|
|
90
|
+
}
|
|
91
|
+
function shouldSaveLogs(config) {
|
|
92
|
+
return config.saveLogsToFile ?? DEFAULT_RELINKA_CONFIG.saveLogsToFile;
|
|
93
|
+
}
|
|
94
|
+
function getMaxLogFiles(config) {
|
|
95
|
+
return config.dirs?.maxLogFiles ?? DEFAULT_RELINKA_CONFIG.dirs.maxLogFiles;
|
|
96
|
+
}
|
|
97
|
+
function getBaseLogName(config) {
|
|
98
|
+
return config.logFilePath ?? DEFAULT_RELINKA_CONFIG.logFilePath;
|
|
99
|
+
}
|
|
100
|
+
function getTimestamp(config) {
|
|
101
|
+
if (!config.withTimestamp) return "";
|
|
102
|
+
const now = /* @__PURE__ */ new Date();
|
|
103
|
+
return `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-${String(now.getDate()).padStart(2, "0")} ${String(now.getHours()).padStart(2, "0")}:${String(
|
|
104
|
+
now.getMinutes()
|
|
105
|
+
).padStart(2, "0")}:${String(now.getSeconds()).padStart(2, "0")}.${String(now.getMilliseconds()).padStart(3, "0")}`;
|
|
106
|
+
}
|
|
107
|
+
function getLogFilePath(config) {
|
|
108
|
+
const logDir = getLogDir(config);
|
|
109
|
+
const daily = isDailyLogsEnabled(config);
|
|
110
|
+
let finalLogName = getBaseLogName(config);
|
|
111
|
+
if (daily) {
|
|
112
|
+
const now = /* @__PURE__ */ new Date();
|
|
113
|
+
const datePrefix = `${now.getFullYear()}-${String(
|
|
114
|
+
now.getMonth() + 1
|
|
115
|
+
).padStart(2, "0")}-${String(now.getDate()).padStart(2, "0")}-`;
|
|
116
|
+
finalLogName = datePrefix + finalLogName;
|
|
117
|
+
}
|
|
118
|
+
if (finalLogName && !finalLogName.endsWith(".log")) {
|
|
119
|
+
finalLogName += ".log";
|
|
120
|
+
}
|
|
121
|
+
const effectiveLogName = finalLogName || "relinka.log";
|
|
122
|
+
return path.resolve(process.cwd(), logDir, effectiveLogName);
|
|
123
|
+
}
|
|
124
|
+
function formatLogMessage(config, level, msg, details) {
|
|
125
|
+
const timestamp = getTimestamp(config);
|
|
126
|
+
let detailsStr = "";
|
|
127
|
+
if (details !== void 0) {
|
|
128
|
+
if (details instanceof Error) {
|
|
129
|
+
detailsStr = `
|
|
130
|
+
Stack Trace: ${details.stack || details.message}`;
|
|
131
|
+
} else if (typeof details === "object" && details !== null) {
|
|
132
|
+
try {
|
|
133
|
+
detailsStr = ` ${JSON.stringify(details)}`;
|
|
134
|
+
} catch {
|
|
135
|
+
detailsStr = " [object Object]";
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
detailsStr = ` ${String(details)}`;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const paddedLevel = level.padEnd(7, " ");
|
|
142
|
+
return timestamp ? `[${timestamp}] ${paddedLevel} ${msg}${detailsStr}` : `${paddedLevel} ${msg}${detailsStr}`;
|
|
143
|
+
}
|
|
144
|
+
function logToConsole(config, level, formattedMessage) {
|
|
145
|
+
const COLOR_RESET = "\x1B[0m";
|
|
146
|
+
if (!isColorEnabled(config)) {
|
|
147
|
+
if (level === "ERROR") {
|
|
148
|
+
console.error(formattedMessage);
|
|
149
|
+
} else {
|
|
150
|
+
console.log(formattedMessage);
|
|
151
|
+
}
|
|
152
|
+
} else {
|
|
153
|
+
switch (level) {
|
|
154
|
+
case "ERROR":
|
|
155
|
+
console.error(re.redBright(formattedMessage) + COLOR_RESET);
|
|
156
|
+
break;
|
|
157
|
+
case "WARN":
|
|
158
|
+
console.warn(re.yellowBright(formattedMessage) + COLOR_RESET);
|
|
159
|
+
break;
|
|
160
|
+
case "SUCCESS":
|
|
161
|
+
console.log(re.greenBright(formattedMessage) + COLOR_RESET);
|
|
162
|
+
break;
|
|
163
|
+
case "INFO":
|
|
164
|
+
console.log(re.cyanBright(formattedMessage) + COLOR_RESET);
|
|
165
|
+
break;
|
|
166
|
+
default:
|
|
167
|
+
console.log(re.dim(formattedMessage) + COLOR_RESET);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
async function getLogFilesSortedByDate(config) {
|
|
172
|
+
const logDirectoryPath = path.resolve(process.cwd(), getLogDir(config));
|
|
173
|
+
if (!await fs.pathExists(logDirectoryPath)) {
|
|
174
|
+
if (isDebugEnabled(config)) {
|
|
175
|
+
console.log(
|
|
176
|
+
`[Relinka FS Debug] Log directory not found: ${logDirectoryPath}`
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
return [];
|
|
180
|
+
}
|
|
181
|
+
try {
|
|
182
|
+
const files = await fs.readdir(logDirectoryPath);
|
|
183
|
+
const logFilesPromises = files.filter((f) => f.endsWith(".log")).map(async (f) => {
|
|
184
|
+
const filePath = path.join(logDirectoryPath, f);
|
|
185
|
+
try {
|
|
186
|
+
const stats = await fs.stat(filePath);
|
|
187
|
+
if (stats.isFile()) {
|
|
188
|
+
return { path: filePath, mtime: stats.mtime.getTime() };
|
|
189
|
+
}
|
|
190
|
+
return null;
|
|
191
|
+
} catch (err) {
|
|
192
|
+
if (isDebugEnabled(config)) {
|
|
193
|
+
console.error(
|
|
194
|
+
`[Relinka FS Debug] Error reading stats for ${filePath}: ${err instanceof Error ? err.message : String(err)}`
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
const logFiles = (await Promise.all(logFilesPromises)).filter(
|
|
201
|
+
(f) => Boolean(f)
|
|
202
|
+
);
|
|
203
|
+
return logFiles.sort((a, b) => b.mtime - a.mtime);
|
|
204
|
+
} catch (readErr) {
|
|
205
|
+
if (isDebugEnabled(config)) {
|
|
206
|
+
console.error(
|
|
207
|
+
`[Relinka FS Error] Failed reading log directory ${logDirectoryPath}: ${readErr instanceof Error ? readErr.message : String(readErr)}`
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
return [];
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
async function deleteFiles(filePaths, config) {
|
|
214
|
+
await Promise.all(
|
|
215
|
+
filePaths.map(async (filePath) => {
|
|
216
|
+
try {
|
|
217
|
+
await fs.unlink(filePath);
|
|
218
|
+
} catch (err) {
|
|
219
|
+
if (isDebugEnabled(config)) {
|
|
220
|
+
console.error(
|
|
221
|
+
`[Relinka FS Error] Failed to delete log file ${filePath}: ${err instanceof Error ? err.message : String(err)}`
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
})
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
async function cleanupOldLogFiles(config) {
|
|
229
|
+
if (!shouldSaveLogs(config) || getMaxLogFiles(config) <= 0) return;
|
|
230
|
+
try {
|
|
231
|
+
const sortedLogFiles = await getLogFilesSortedByDate(config);
|
|
232
|
+
const maxFiles = getMaxLogFiles(config);
|
|
233
|
+
if (sortedLogFiles.length > maxFiles) {
|
|
234
|
+
const filesToDelete = sortedLogFiles.slice(maxFiles).map((f) => f.path);
|
|
235
|
+
if (filesToDelete.length > 0) {
|
|
236
|
+
await deleteFiles(filesToDelete, config);
|
|
237
|
+
if (isDebugEnabled(config)) {
|
|
238
|
+
console.log(
|
|
239
|
+
`[Relinka Cleanup] Deleted ${filesToDelete.length} old log file(s). Kept ${maxFiles}.`
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
} catch (err) {
|
|
245
|
+
if (isDebugEnabled(config)) {
|
|
246
|
+
console.error(
|
|
247
|
+
`[Relinka Cleanup Error] Failed during log cleanup: ${err instanceof Error ? err.message : String(err)}`
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
async function appendToLogFile(config, absoluteLogFilePath, logMessage) {
|
|
253
|
+
try {
|
|
254
|
+
await fs.ensureDir(path.dirname(absoluteLogFilePath));
|
|
255
|
+
await fs.appendFile(absoluteLogFilePath, `${logMessage}
|
|
256
|
+
`);
|
|
257
|
+
} catch (err) {
|
|
258
|
+
if (isDebugEnabled(config)) {
|
|
259
|
+
console.error(
|
|
260
|
+
`[Relinka File Error] Failed to write to log file ${absoluteLogFilePath}: ${err instanceof Error ? err.message : String(err)}`
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
export function relinka(type, message, ...args) {
|
|
266
|
+
if (message === "") {
|
|
267
|
+
console.log();
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
const logLevelLabel = type === "verbose" ? "DEBUG" : type.toUpperCase();
|
|
271
|
+
if (logLevelLabel === "DEBUG" && !isDebugEnabled(currentConfig)) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
const details = args.length > 1 ? args : args[0];
|
|
275
|
+
const formatted = formatLogMessage(
|
|
276
|
+
currentConfig,
|
|
277
|
+
logLevelLabel,
|
|
278
|
+
message,
|
|
279
|
+
details
|
|
280
|
+
);
|
|
281
|
+
logToConsole(currentConfig, logLevelLabel, formatted);
|
|
282
|
+
}
|
|
283
|
+
export async function relinkaAsync(type, message, ...args) {
|
|
284
|
+
await relinkaConfig;
|
|
285
|
+
if (message === "") {
|
|
286
|
+
console.log();
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const logLevelLabel = type === "verbose" ? "DEBUG" : type.toUpperCase();
|
|
290
|
+
if (logLevelLabel === "DEBUG" && !isDebugEnabled(currentConfig)) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
const details = args.length > 1 ? args : args[0];
|
|
294
|
+
const formatted = formatLogMessage(
|
|
295
|
+
currentConfig,
|
|
296
|
+
logLevelLabel,
|
|
297
|
+
message,
|
|
298
|
+
details
|
|
299
|
+
);
|
|
300
|
+
logToConsole(currentConfig, logLevelLabel, formatted);
|
|
301
|
+
if (shouldSaveLogs(currentConfig)) {
|
|
302
|
+
const absoluteLogFilePath = getLogFilePath(currentConfig);
|
|
303
|
+
try {
|
|
304
|
+
await appendToLogFile(currentConfig, absoluteLogFilePath, formatted);
|
|
305
|
+
await cleanupOldLogFiles(currentConfig);
|
|
306
|
+
} catch (err) {
|
|
307
|
+
if (isDebugEnabled(currentConfig)) {
|
|
308
|
+
console.error(
|
|
309
|
+
`[Relinka File Async Error] Error during file logging/cleanup: ${err instanceof Error ? err.message : String(err)}`
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
export function defineConfig(config) {
|
|
316
|
+
return config;
|
|
317
|
+
}
|
|
@@ -1,10 +1,54 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
|
|
3
|
-
export type
|
|
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
|
+
/**
|
|
15
|
+
* Configuration options for the Relinka logger.
|
|
16
|
+
* All properties are optional to allow for partial configuration.
|
|
17
|
+
* Defaults will be applied during initialization.
|
|
18
|
+
*/
|
|
19
|
+
export type RelinkaConfig = {
|
|
20
|
+
debug?: boolean;
|
|
21
|
+
dirs?: RelinkaDirsConfig;
|
|
22
|
+
disableColors?: boolean;
|
|
23
|
+
logFilePath?: string;
|
|
24
|
+
saveLogsToFile?: boolean;
|
|
25
|
+
withTimestamp?: boolean;
|
|
26
|
+
};
|
|
27
|
+
/** Represents information about a log file for cleanup purposes. */
|
|
28
|
+
export type LogFileInfo = {
|
|
29
|
+
path: string;
|
|
30
|
+
mtime: number;
|
|
31
|
+
};
|
|
32
|
+
/** Log level types used by the logger. */
|
|
33
|
+
export type LogLevel = "error" | "info" | "success" | "verbose" | "warn";
|
|
34
|
+
/**
|
|
35
|
+
* Defines the level of logs as specific numbers or special number types.
|
|
36
|
+
*
|
|
37
|
+
* @type {0 | 1 | 2 | 3 | 4 | 5 | (number & {})} LogLevelDeprecated - Represents the log level.
|
|
38
|
+
* @default 0 - Represents the default log level.
|
|
39
|
+
*/
|
|
40
|
+
export type LogLevelDeprecated = 0 | 1 | 2 | 3 | 4 | 5 | (number & {});
|
|
41
|
+
/**
|
|
42
|
+
* Lists the types of log messages supported by the system.
|
|
43
|
+
*
|
|
44
|
+
* @type {"silent" | "fatal" | "error" | "warn" | "log" | "info" | "success" | "fail" | "ready" | "start" | "box" | "debug" | "trace" | "verbose"} LogTypeDeprecated - Represents the specific type of log message.
|
|
45
|
+
*/
|
|
46
|
+
export type LogTypeDeprecated = "silent" | "fatal" | "error" | "warn" | "log" | "info" | "success" | "fail" | "ready" | "start" | "box" | "debug" | "trace" | "verbose";
|
|
47
|
+
export type RelinkaOptionsDeprecated = {
|
|
4
48
|
/**
|
|
5
|
-
* An array of
|
|
49
|
+
* An array of RelinkaReporterDeprecated instances used to handle and output log messages.
|
|
6
50
|
*/
|
|
7
|
-
reporters:
|
|
51
|
+
reporters: RelinkaReporterDeprecated[];
|
|
8
52
|
/**
|
|
9
53
|
* A record mapping LogTypeDeprecated to InputLogObject, defining the log configuration for each log type.
|
|
10
54
|
* See {@link LogTypeDeprecated} and {@link InputLogObject}.
|
|
@@ -138,13 +182,13 @@ export type LogObject = {
|
|
|
138
182
|
*/
|
|
139
183
|
[key: string]: unknown;
|
|
140
184
|
} & InputLogObject;
|
|
141
|
-
export type
|
|
185
|
+
export type RelinkaReporterDeprecated = {
|
|
142
186
|
/**
|
|
143
187
|
* Defines how a log message is processed and displayed by this reporter.
|
|
144
188
|
* @param logObj The LogObject containing the log information to process. See {@link LogObject}.
|
|
145
|
-
* @param ctx An object containing context information such as options. See {@link
|
|
189
|
+
* @param ctx An object containing context information such as options. See {@link RelinkaOptionsDeprecated}.
|
|
146
190
|
*/
|
|
147
191
|
log: (logObj: LogObject, ctx: {
|
|
148
|
-
options:
|
|
192
|
+
options: RelinkaOptionsDeprecated;
|
|
149
193
|
}) => void;
|
|
150
194
|
};
|
package/package.json
CHANGED
|
@@ -1,38 +1,21 @@
|
|
|
1
1
|
{
|
|
2
|
+
"description": "@reliverse/relinka is your next favorite logging library — built to make your terminal (and browser console — soon) output look good, stay clean, and be actually helpful. It’s styled, structured, and smart. Oh, and it works with configs, files, and colors out of the box.",
|
|
3
|
+
"license": "MIT",
|
|
4
|
+
"name": "@reliverse/relinka",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"version": "1.3.7",
|
|
2
7
|
"dependencies": {
|
|
3
|
-
"@reliverse/relico": "^1.0
|
|
8
|
+
"@reliverse/relico": "^1.1.0",
|
|
4
9
|
"@reliverse/runtime": "^1.0.3",
|
|
10
|
+
"c12": "^3.0.2",
|
|
5
11
|
"defu": "^6.1.4",
|
|
12
|
+
"fs-extra": "^11.3.0",
|
|
6
13
|
"pathe": "^2.0.3",
|
|
7
14
|
"printj": "^1.3.1",
|
|
8
15
|
"std-env": "^3.8.1",
|
|
9
16
|
"string-width": "^7.2.0"
|
|
10
17
|
},
|
|
11
|
-
"
|
|
12
|
-
"homepage": "https://docs.reliverse.org",
|
|
13
|
-
"license": "MIT",
|
|
14
|
-
"name": "@reliverse/relinka",
|
|
15
|
-
"type": "module",
|
|
16
|
-
"version": "1.3.5",
|
|
17
|
-
"devDependencies": {
|
|
18
|
-
"@biomejs/biome": "1.9.4",
|
|
19
|
-
"@eslint/js": "^9.23.0",
|
|
20
|
-
"@reliverse/relidler-cfg": "^1.1.3",
|
|
21
|
-
"@stylistic/eslint-plugin": "^4.2.0",
|
|
22
|
-
"@total-typescript/ts-reset": "^0.6.1",
|
|
23
|
-
"@types/bun": "^1.2.8",
|
|
24
|
-
"@types/node": "^22.13.16",
|
|
25
|
-
"@types/sentencer": "^0.2.3",
|
|
26
|
-
"eslint": "^9.23.0",
|
|
27
|
-
"eslint-plugin-no-relative-import-paths": "^1.6.1",
|
|
28
|
-
"eslint-plugin-perfectionist": "^4.10.1",
|
|
29
|
-
"jiti": "^2.4.2",
|
|
30
|
-
"knip": "^5.46.4",
|
|
31
|
-
"sentencer": "^0.2.1",
|
|
32
|
-
"typescript": "^5.8.2",
|
|
33
|
-
"typescript-eslint": "^8.29.0",
|
|
34
|
-
"vitest": "^3.1.1"
|
|
35
|
-
},
|
|
18
|
+
"devDependencies": {},
|
|
36
19
|
"exports": {
|
|
37
20
|
".": "./bin/main.js"
|
|
38
21
|
},
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { LogObject } from "../../../../core-types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Defines the level of logs as specific numbers or special number types.
|
|
4
|
-
*
|
|
5
|
-
* @type {0 | 1 | 2 | 3 | 4 | 5 | (number & {})} LogLevelDeprecated - Represents the log level.
|
|
6
|
-
* @default 0 - Represents the default log level.
|
|
7
|
-
*/
|
|
8
|
-
export type LogLevelDeprecated = 0 | 1 | 2 | 3 | 4 | 5 | (number & {});
|
|
9
|
-
/**
|
|
10
|
-
* A mapping of `LogTypeDeprecated` to its corresponding numeric log level.
|
|
11
|
-
*
|
|
12
|
-
* @type {Record<LogTypeDeprecated, number>} LogLevelsDeprecated - key-value pairs of log types to their numeric levels. See {@link LogTypeDeprecated}.
|
|
13
|
-
*/
|
|
14
|
-
export declare const LogLevelsDeprecated: Record<LogTypeDeprecated, number>;
|
|
15
|
-
/**
|
|
16
|
-
* Lists the types of log messages supported by the system.
|
|
17
|
-
*
|
|
18
|
-
* @type {"silent" | "fatal" | "error" | "warn" | "log" | "info" | "success" | "fail" | "ready" | "start" | "box" | "debug" | "trace" | "verbose"} LogTypeDeprecated - Represents the specific type of log message.
|
|
19
|
-
*/
|
|
20
|
-
export type LogTypeDeprecated = "silent" | "fatal" | "error" | "warn" | "log" | "info" | "success" | "fail" | "ready" | "start" | "box" | "debug" | "trace" | "verbose";
|
|
21
|
-
/**
|
|
22
|
-
* Maps `LogTypeDeprecated` to a `Partial<LogObject>`, primarily defining the log level.
|
|
23
|
-
*
|
|
24
|
-
* @type {Record<LogTypeDeprecated, Partial<LogObject>>} LogTypesDeprecated - key-value pairs of log types to partial log objects, specifying log levels. See {@link LogTypeDeprecated} and {@link LogObject}.
|
|
25
|
-
*/
|
|
26
|
-
export declare const LogTypesDeprecated: Record<LogTypeDeprecated, Partial<LogObject>>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export type { LogLevelDeprecated, LogTypeDeprecated, } from "./core-impl/deprecated/components/levels/levels.js";
|
|
2
|
-
export { LogLevelsDeprecated, LogTypesDeprecated, } from "./core-impl/deprecated/components/levels/levels.js";
|
|
3
|
-
export { createRelinkaBaseDeprecated, relinkaBasicDeprecated, } from "./core-impl/deprecated/components/modes/basic.js";
|
|
4
|
-
export { createRelinkaBrowserDeprecatedDeprecated, relinkaBrowserDeprecated, } from "./core-impl/deprecated/components/modes/browser.js";
|
|
5
|
-
export { relinkaDeprecated } from "./core-impl/deprecated/components/relinka-deprecated/logger.js";
|
|
6
|
-
export { createRelinkaSharedDeprecated, relinkaInstanceDeprecated, } from "./core-impl/deprecated/components/relinka-deprecated/mod.js";
|
|
7
|
-
export type { LogFn, RelinkaInstanceDeprecated, } from "./core-impl/deprecated/components/relinka-deprecated/relinka.js";
|
|
8
|
-
export { RelinkaInterface, createRelinkaDeprecated, } from "./core-impl/deprecated/components/relinka-deprecated/relinka.js";
|
|
9
|
-
export { BasicReporter } from "./core-impl/deprecated/components/reporters/basic.js";
|
|
10
|
-
export { BrowserReporter } from "./core-impl/deprecated/components/reporters/browser.js";
|
|
11
|
-
export { TYPE_COLOR_MAP, LEVEL_COLOR_MAP, FancyReporter, } from "./core-impl/deprecated/components/reporters/fancy.js";
|
|
12
|
-
export type { RelinkaOptions, FormatOptions, InputLogObject, LogObject, RelinkaReporter, } from "./core-types.js";
|
|
13
|
-
export type { BoxBorderStyle, BoxStyle, BoxOpts, } from "./core-impl/deprecated/utils/box.js";
|
|
14
|
-
export { box } from "./core-impl/deprecated/utils/box.js";
|
|
15
|
-
export type { ColorName, ColorFunction, } from "./core-impl/deprecated/utils/deprecatedColors.js";
|
|
16
|
-
export { colors, getColor, colorize, } from "./core-impl/deprecated/utils/deprecatedColors.js";
|
|
17
|
-
export { parseStack } from "./core-impl/deprecated/utils/error.js";
|
|
18
|
-
export { compileFormat, formatString, } from "./core-impl/deprecated/utils/format.js";
|
|
19
|
-
export { isPlainObject, isLogObj } from "./core-impl/deprecated/utils/log.js";
|
|
20
|
-
export { writeStream } from "./core-impl/deprecated/utils/stream.js";
|
|
21
|
-
export { stripAnsi, centerAlign, rightAlign, leftAlign, align, } from "./core-impl/deprecated/utils/string.js";
|
|
22
|
-
export type { TreeItemObject, TreeItem, TreeOptions, } from "./core-impl/deprecated/utils/tree.js";
|
|
23
|
-
export { formatTree } from "./core-impl/deprecated/utils/tree.js";
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
LogLevelsDeprecated,
|
|
3
|
-
LogTypesDeprecated
|
|
4
|
-
} from "./core-impl/deprecated/components/levels/levels.js";
|
|
5
|
-
export {
|
|
6
|
-
createRelinkaBaseDeprecated,
|
|
7
|
-
relinkaBasicDeprecated
|
|
8
|
-
} from "./core-impl/deprecated/components/modes/basic.js";
|
|
9
|
-
export {
|
|
10
|
-
createRelinkaBrowserDeprecatedDeprecated,
|
|
11
|
-
relinkaBrowserDeprecated
|
|
12
|
-
} from "./core-impl/deprecated/components/modes/browser.js";
|
|
13
|
-
export { relinkaDeprecated } from "./core-impl/deprecated/components/relinka-deprecated/logger.js";
|
|
14
|
-
export {
|
|
15
|
-
createRelinkaSharedDeprecated,
|
|
16
|
-
relinkaInstanceDeprecated
|
|
17
|
-
} from "./core-impl/deprecated/components/relinka-deprecated/mod.js";
|
|
18
|
-
export {
|
|
19
|
-
RelinkaInterface,
|
|
20
|
-
createRelinkaDeprecated
|
|
21
|
-
} from "./core-impl/deprecated/components/relinka-deprecated/relinka.js";
|
|
22
|
-
export { BasicReporter } from "./core-impl/deprecated/components/reporters/basic.js";
|
|
23
|
-
export { BrowserReporter } from "./core-impl/deprecated/components/reporters/browser.js";
|
|
24
|
-
export {
|
|
25
|
-
TYPE_COLOR_MAP,
|
|
26
|
-
LEVEL_COLOR_MAP,
|
|
27
|
-
FancyReporter
|
|
28
|
-
} from "./core-impl/deprecated/components/reporters/fancy.js";
|
|
29
|
-
export { box } from "./core-impl/deprecated/utils/box.js";
|
|
30
|
-
export {
|
|
31
|
-
colors,
|
|
32
|
-
getColor,
|
|
33
|
-
colorize
|
|
34
|
-
} from "./core-impl/deprecated/utils/deprecatedColors.js";
|
|
35
|
-
export { parseStack } from "./core-impl/deprecated/utils/error.js";
|
|
36
|
-
export {
|
|
37
|
-
compileFormat,
|
|
38
|
-
formatString
|
|
39
|
-
} from "./core-impl/deprecated/utils/format.js";
|
|
40
|
-
export { isPlainObject, isLogObj } from "./core-impl/deprecated/utils/log.js";
|
|
41
|
-
export { writeStream } from "./core-impl/deprecated/utils/stream.js";
|
|
42
|
-
export {
|
|
43
|
-
stripAnsi,
|
|
44
|
-
centerAlign,
|
|
45
|
-
rightAlign,
|
|
46
|
-
leftAlign,
|
|
47
|
-
align
|
|
48
|
-
} from "./core-impl/deprecated/utils/string.js";
|
|
49
|
-
export { formatTree } from "./core-impl/deprecated/utils/tree.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../../types.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "../../types.js";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/relinka-deprecated/logger.js
RENAMED
|
File without changes
|
/package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/relinka-deprecated/mod.js
RENAMED
|
File without changes
|
|
File without changes
|
/package/bin/{libs/core/core-impl → relinka-impl}/deprecated/components/reporters/browser.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|