fix(logging): register custom Winston levels so verbose captures debug
Winston's default npm levels assign debug=5 and verbose=4, so setting
level to 'verbose' (threshold 4) filtered out debug (5 > 4). Register
PROJECT_LEVELS { error:0, warn:1, info:2, debug:3, verbose:4 } so
Winston's <= threshold filter aligns with the project's intended
semantics where verbose is the most detailed level.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,17 @@ import { getContext, run } from './request-context'
|
|||||||
import { createSeqTransportSync } from './seq-transport'
|
import { createSeqTransportSync } from './seq-transport'
|
||||||
import type { SeqConfig } from '../../types/config.schema'
|
import type { SeqConfig } from '../../types/config.schema'
|
||||||
|
|
||||||
|
// Custom log levels matching project semantics:
|
||||||
|
// verbose (most detailed) → error (most severe)
|
||||||
|
// Winston rule: logs with level value <= threshold are emitted.
|
||||||
|
const PROJECT_LEVELS = {
|
||||||
|
error: 0,
|
||||||
|
warn: 1,
|
||||||
|
info: 2,
|
||||||
|
debug: 3,
|
||||||
|
verbose: 4
|
||||||
|
} as const
|
||||||
|
|
||||||
// Cache isProduction() at module load — app.isPackaged never changes at runtime
|
// Cache isProduction() at module load — app.isPackaged never changes at runtime
|
||||||
const IS_PROD = isProduction()
|
const IS_PROD = isProduction()
|
||||||
|
|
||||||
@@ -156,6 +167,7 @@ const createFileTransport = (level?: string, maxFiles?: string): DailyRotateFile
|
|||||||
// Create the logger instance with default level - Console only initially
|
// Create the logger instance with default level - Console only initially
|
||||||
// File transports are added after config is loaded via applyLoggingConfig()
|
// File transports are added after config is loaded via applyLoggingConfig()
|
||||||
const logger = winston.createLogger({
|
const logger = winston.createLogger({
|
||||||
|
levels: PROJECT_LEVELS,
|
||||||
level: 'info', // Default level, can be updated via setLogLevel()
|
level: 'info', // Default level, can be updated via setLogLevel()
|
||||||
defaultMeta: {
|
defaultMeta: {
|
||||||
service: 'erpauto',
|
service: 'erpauto',
|
||||||
|
|||||||
Reference in New Issue
Block a user