1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-27 17:49:08 -05:00
denoland-deno/log/levels.ts

36 lines
733 B
TypeScript
Raw Normal View History

2019-02-07 11:45:47 -05:00
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
2018-12-19 13:16:45 -05:00
export const LogLevel = {
2019-01-02 09:12:48 -05:00
NOTSET: 0,
2018-12-19 13:16:45 -05:00
DEBUG: 10,
INFO: 20,
WARNING: 30,
ERROR: 40,
CRITICAL: 50
};
const byName = {
2019-01-02 09:12:48 -05:00
NOTSET: LogLevel.NOTSET,
2018-12-19 13:16:45 -05:00
DEBUG: LogLevel.DEBUG,
INFO: LogLevel.INFO,
WARNING: LogLevel.WARNING,
ERROR: LogLevel.ERROR,
2019-01-02 09:12:48 -05:00
CRITICAL: LogLevel.CRITICAL
2018-12-19 13:16:45 -05:00
};
const byLevel = {
2019-01-02 09:12:48 -05:00
[LogLevel.NOTSET]: "NOTSET",
2018-12-19 13:16:45 -05:00
[LogLevel.DEBUG]: "DEBUG",
[LogLevel.INFO]: "INFO",
[LogLevel.WARNING]: "WARNING",
[LogLevel.ERROR]: "ERROR",
[LogLevel.CRITICAL]: "CRITICAL"
};
2019-01-02 09:12:48 -05:00
export function getLevelByName(name: string): number {
2018-12-19 13:16:45 -05:00
return byName[name];
}
2019-01-02 09:12:48 -05:00
export function getLevelName(level: number): string {
2018-12-19 13:16:45 -05:00
return byLevel[level];
}