mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-10 18:36:15 -08:00
chore(logger): implement logger utility with debug, info, warn, and error methods
This commit is contained in:
1 parent
648ba9d5b4
commit
b9ac1ade78
1 file changed
+32
@@ -0,0 +1,32 @@
|
||||
import { AppConfig } from '../../../environments/environment';
|
||||
|
||||
export interface Logger {
|
||||
debug: (...args: unknown[]) => void;
|
||||
info: (...args: unknown[]) => void;
|
||||
warn: (...args: unknown[]) => void;
|
||||
error: (...args: unknown[]) => void;
|
||||
}
|
||||
|
||||
export function createLogger(scope: string): Logger {
|
||||
const prefix = `[${scope}]`;
|
||||
const debugEnabled = !AppConfig.production;
|
||||
|
||||
return {
|
||||
debug: (...args: unknown[]) => {
|
||||
if (debugEnabled) {
|
||||
console.debug(prefix, ...args);
|
||||
}
|
||||
},
|
||||
info: (...args: unknown[]) => {
|
||||
if (debugEnabled) {
|
||||
console.info(prefix, ...args);
|
||||
}
|
||||
},
|
||||
warn: (...args: unknown[]) => {
|
||||
console.warn(prefix, ...args);
|
||||
},
|
||||
error: (...args: unknown[]) => {
|
||||
console.error(prefix, ...args);
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user