ffffng/server/types/logger.ts
baldo 002ae4419f Implement custom logger to replace scribe.js.
* scribe.js is unmaintained and adds unnecessary complexity.
2022-02-09 18:02:59 +01:00

27 lines
722 B
TypeScript

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;
}
export interface TaggedLogger {
log(level: LogLevel, ...args: any[]): void;
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;
}