Compare commits

1 Commits
v1.1.1 ... main

Author SHA1 Message Date
c89bf8e410 feat(logger): add current working directory handling 2025-10-11 13:56:20 +02:00

View File

@@ -172,6 +172,21 @@ function getPid(): number {
return (globalThis as CrossPlatformGlobal).process?.pid || 0;
}
function getCwd(): string {
try {
if (runtime.isDeno) return Deno.cwd();
if (runtime.isNode || runtime.isBun) {
const requireFn = (globalThis as CrossPlatformGlobal).require ||
eval("require");
const proc = requireFn("process");
return proc?.cwd?.() ?? requireFn("path")?.resolve?.() ?? ".";
}
} catch {
// ignore
}
return ".";
}
function getHostname(): string {
if (runtime.isDeno) {
return Deno.hostname();
@@ -571,7 +586,9 @@ class Logger {
simpleFormatter(logEntry: LogEntry): string {
const levelPadded = logEntry.level.toUpperCase().padEnd(5);
const caller = logEntry.callerFile
? `${logEntry.callerFile.split("/").pop()}:${logEntry.callerLine}`
? `${
logEntry.callerFile.replace(getCwd() + "/", "")
}:${logEntry.callerLine}`
: null;
return caller