refactor(logger): simplify logger configuration and improve file rotation

This commit is contained in:
2025-11-21 21:15:06 +08:00
parent 0612477325
commit de97fb4858
4 changed files with 65 additions and 71 deletions

View File

@@ -53,14 +53,20 @@ export const textRenderer: Renderer = (event) => {
const timeStr = event.get("timestamp") as string | undefined;
const level: string | undefined = LogLevel[event.get("level") as LogLevel];
const message = (event.get("message") as string) ?? "";
const loggerName = event.get("loggerName") as string | undefined;
// Start building the output
let output = `[${timeStr}] [${level}] ${message} \t`;
let output = `${timeStr} [${level}] ${message} \t ${loggerName !== undefined ? "[" + loggerName + "]" : ""}`;
// Add context fields (excluding the core fields we already used)
const contextFields: string[] = [];
for (const [key, value] of event.entries()) {
if (key !== "timestamp" && key !== "level" && key !== "message") {
if (
key !== "timestamp" &&
key !== "level" &&
key !== "message" &&
key !== "loggerName"
) {
contextFields.push(`${key}=${tostring(value)}`);
}
}