Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
c89bf8e410
|
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user