cherry-studio/packages/shared/config/logger.ts
fullex 5204438c0c
refactor[Logger]: filtering logs with environment variable (#8299)
refactor(Logger): enhance logging with environment variable support

- Updated LoggerService to utilize environment variables for filtering logs by level and module in development mode.
- Modified the logging level handling to use constants from the logger configuration.
- Enhanced documentation to include details on using environment variables for log filtering in both English and Chinese documentation files.
- Cleaned up unused type definitions related to logging.
2025-07-21 09:37:48 +08:00

29 lines
582 B
TypeScript

export type LogSourceWithContext = {
process: 'main' | 'renderer'
window?: string // only for renderer process
module?: string
context?: Record<string, any>
}
export type LogLevel = 'error' | 'warn' | 'info' | 'debug' | 'verbose' | 'silly' | 'none'
export const LEVEL = {
ERROR: 'error',
WARN: 'warn',
INFO: 'info',
DEBUG: 'debug',
VERBOSE: 'verbose',
SILLY: 'silly',
NONE: 'none'
} satisfies Record<string, LogLevel>
export const LEVEL_MAP: Record<LogLevel, number> = {
error: 10,
warn: 8,
info: 6,
debug: 4,
verbose: 2,
silly: 0,
none: -1
}