Implement custom logger to replace scribe.js.
* scribe.js is unmaintained and adds unnecessary complexity.
This commit is contained in:
parent
2df8539c46
commit
002ae4419f
13 changed files with 284 additions and 171 deletions
server/types
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue