2022-08-23 20:08:53 +02:00
|
|
|
export type LogLevel = "debug" | "info" | "warn" | "error" | "profile";
|
|
|
|
export const LogLevels: LogLevel[] = [
|
|
|
|
"debug",
|
|
|
|
"info",
|
|
|
|
"warn",
|
|
|
|
"error",
|
|
|
|
"profile",
|
|
|
|
];
|
2022-02-09 18:01:44 +01:00
|
|
|
|
2022-08-23 20:08:53 +02:00
|
|
|
export function isLogLevel(arg: unknown): arg is LogLevel {
|
2022-02-09 18:01:44 +01:00
|
|
|
if (typeof arg !== "string") {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
for (const level of LogLevels) {
|
|
|
|
if (level === arg) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-06-30 01:10:18 +02:00
|
|
|
export interface TaggedLogger {
|
2022-08-23 20:08:53 +02:00
|
|
|
log(level: LogLevel, ...args: unknown[]): void;
|
|
|
|
debug(...args: unknown[]): void;
|
|
|
|
info(...args: unknown[]): void;
|
|
|
|
warn(...args: unknown[]): void;
|
|
|
|
error(...args: unknown[]): void;
|
|
|
|
profile(...args: unknown[]): void;
|
2020-06-30 01:10:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface Logger {
|
|
|
|
tag(...tags: string[]): TaggedLogger;
|
|
|
|
}
|