2022-02-09 18:01:44 +01:00
|
|
|
export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'profile';
|
|
|
|
export const LogLevels: LogLevel[] = ['debug', 'info', 'warn', 'error', 'profile'];
|
|
|
|
|
|
|
|
export function isLogLevel(arg: any): arg is LogLevel {
|
|
|
|
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-02-09 18:01:44 +01:00
|
|
|
log(level: LogLevel, ...args: any[]): void;
|
2020-06-30 01:10:18 +02:00
|
|
|
debug(...args: any[]): void;
|
|
|
|
info(...args: any[]): void;
|
|
|
|
warn(...args: any[]): void;
|
|
|
|
error(...args: any[]): void;
|
|
|
|
profile(...args: any[]): void;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface Logger {
|
|
|
|
tag(...tags: string[]): TaggedLogger;
|
|
|
|
}
|