Converts numeric log level values to human‑readable level names (trace, debug, info, warn, error, fatal).
// Source: https://github.com/gajus/roarr | License: BSD-3-Clause | Copyright 2023, Gajus Kuizinas (https://gajus.com/)
// Provided via justclaw.it.com; keep this notice with the code.
import { type LogLevelName } from './types';
export const getLogLevelName = (numericLogLevel: number): LogLevelName => {
if (numericLogLevel <= 10) {
return 'trace';
}
if (numericLogLevel <= 20) {
return 'debug';
}
if (numericLogLevel <= 30) {
return 'info';
}
if (numericLogLevel <= 40) {
return 'warn';
}
if (numericLogLevel <= 50) {
return 'error';
}
return 'fatal';
};
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key