chore(logger): implement logger utility with debug, info, warn, and error methods

This commit is contained in:
4gray committed 2026-02-14 11:44:30 +01:00
1 parent 648ba9d5b4
commit b9ac1ade78
1 file changed
+32
+32
View File
@@ -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);
},
};
}