2020-01-07 04:09:44 +08:00
|
|
|
// Severities in order of importance.
|
|
|
|
import { enum_values } from "./enums";
|
|
|
|
import { assert } from "./util";
|
|
|
|
|
|
|
|
export enum Severity {
|
|
|
|
Trace,
|
|
|
|
Debug,
|
|
|
|
Info,
|
2020-01-07 06:32:14 +08:00
|
|
|
Warning,
|
2020-01-07 04:09:44 +08:00
|
|
|
Error,
|
|
|
|
Off,
|
|
|
|
}
|
|
|
|
|
2020-04-27 04:19:26 +08:00
|
|
|
export const Severities: readonly Severity[] = enum_values(Severity);
|
2020-01-07 04:09:44 +08:00
|
|
|
|
|
|
|
export function severity_from_string(str: string): Severity {
|
|
|
|
const severity = (Severity as any)[str.slice(0, 1).toUpperCase() + str.slice(1).toLowerCase()];
|
|
|
|
assert(severity != undefined, () => `"${str}" is not a valid severity.`);
|
|
|
|
return severity;
|
|
|
|
}
|