fixed some errors preventing request logging
This commit is contained in:
@@ -20,12 +20,14 @@ const CURRENT_DEPTH: LogDepth = (process.env.LOG_DEPTH as LogDepth) || 'normal';
|
||||
|
||||
const DEPTH_ORDER: Record<LogDepth, number> = { normal: 0, verbose: 1 };
|
||||
|
||||
function shouldLog(level: LogLevel, depth: LogDepth) {
|
||||
return DEPTH_ORDER[depth] >= DEPTH_ORDER[CURRENT_DEPTH];
|
||||
function shouldLog(depth: LogDepth) {
|
||||
let should = DEPTH_ORDER[depth] <= DEPTH_ORDER[CURRENT_DEPTH]
|
||||
return should;
|
||||
}
|
||||
|
||||
function emitLog(header: LogHeader, payload: LogPayload = {}) {
|
||||
if (!shouldLog(header.level, header.depth)) return;
|
||||
if (!shouldLog(header.depth)) return;
|
||||
console.log(header, payload);
|
||||
|
||||
const logLine = { ...header, ...payload };
|
||||
console.log(JSON.stringify(logLine));
|
||||
|
||||
Reference in New Issue
Block a user