Implement custom logger to replace scribe.js.

* scribe.js is unmaintained and adds unnecessary complexity.
This commit is contained in:
baldo 2022-02-09 18:01:44 +01:00
parent 2df8539c46
commit 002ae4419f
13 changed files with 284 additions and 171 deletions
server/types

View file

@ -1,4 +1,20 @@
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;
@ -7,6 +23,5 @@ export interface TaggedLogger {
}
export interface Logger {
init(): void;
tag(...tags: string[]): TaggedLogger;
}