forked from adamlaska/ts-graphql-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.ts
More file actions
29 lines (26 loc) · 719 Bytes
/
logger.ts
File metadata and controls
29 lines (26 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
export interface Logger {
debug(...args: string[]): void;
info(...args: string[]): void;
error(...args: any[]): void;
}
export type LogLevel = 'silent' | 'error' | 'info' | 'debug';
export class ConsoleLogger implements Logger {
constructor(public logLevel: LogLevel = 'info') {}
/* eslint-disable no-console */
error(...args: any[]): void {
if (this.logLevel !== 'silent') {
console.error(...args);
}
}
info(...args: string[]): void {
if (this.logLevel !== 'silent' && this.logLevel !== 'error') {
console.log(...args);
}
}
debug(...args: string[]): void {
if (this.logLevel === 'debug') {
console.log(...args);
}
}
/* eslint-enable no-console */
}