mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-23 02:58:11 +00:00
logging: fix inverted levelToMinLevel mapping vs tslog v4 level IDs
This commit is contained in:
@@ -16,14 +16,15 @@ export function normalizeLogLevel(level?: string, fallback: LogLevel = "info") {
|
||||
}
|
||||
|
||||
export function levelToMinLevel(level: LogLevel): number {
|
||||
// tslog level ordering: fatal=0, error=1, warn=2, info=3, debug=4, trace=5
|
||||
// Matches tslog v4 level IDs: higher number = more severe.
|
||||
// tslog logs messages with logLevelId >= minLevel.
|
||||
const map: Record<LogLevel, number> = {
|
||||
fatal: 0,
|
||||
error: 1,
|
||||
warn: 2,
|
||||
trace: 1,
|
||||
debug: 2,
|
||||
info: 3,
|
||||
debug: 4,
|
||||
trace: 5,
|
||||
warn: 4,
|
||||
error: 5,
|
||||
fatal: 6,
|
||||
silent: Number.POSITIVE_INFINITY,
|
||||
};
|
||||
return map[level];
|
||||
|
||||
@@ -96,7 +96,7 @@ export function isFileLogLevelEnabled(level: LogLevel): boolean {
|
||||
if (settings.level === "silent") {
|
||||
return false;
|
||||
}
|
||||
return levelToMinLevel(level) <= levelToMinLevel(settings.level);
|
||||
return levelToMinLevel(level) >= levelToMinLevel(settings.level);
|
||||
}
|
||||
|
||||
function buildLogger(settings: ResolvedSettings): TsLogger<LogObj> {
|
||||
|
||||
@@ -30,7 +30,7 @@ function shouldLogToConsole(level: LogLevel, settings: { level: LogLevel }): boo
|
||||
}
|
||||
const current = levelToMinLevel(level);
|
||||
const min = levelToMinLevel(settings.level);
|
||||
return current <= min;
|
||||
return current >= min;
|
||||
}
|
||||
|
||||
type ChalkInstance = InstanceType<typeof Chalk>;
|
||||
|
||||
Reference in New Issue
Block a user