export const LogLevels = { NOTSET: 0, DEBUG: 10, INFO: 20, WARN: 30, ERROR: 40, CRITICAL: 50,} as const;
export type LogLevel = typeof LogLevels[LevelName];
export type LevelName = Exclude<keyof typeof LogLevels, number>;
export const LogLevelNames: LevelName[] = Object.keys(LogLevels).filter((key) => isNaN(Number(key))) as LevelName[];
const byLevel: Record<LogLevel, LevelName> = { [LogLevels.NOTSET]: "NOTSET", [LogLevels.DEBUG]: "DEBUG", [LogLevels.INFO]: "INFO", [LogLevels.WARN]: "WARN", [LogLevels.ERROR]: "ERROR", [LogLevels.CRITICAL]: "CRITICAL",};
export function getLevelByName(name: LevelName): LogLevel { const level = LogLevels[name]; if (level !== undefined) { return level; } throw new Error(`no log level found for name: ${name}`);}
export function getLevelName(level: LogLevel): LevelName { const levelName = byLevel[level as LogLevel]; if (levelName) { return levelName; } throw new Error(`no level name found for level: ${level}`);}