Files
bedolaga-cabinet/src/utils/logger.ts
c0mrade bc90ba3779 refactor: migrate to eslint flat config and format codebase with prettier
- Remove legacy .eslintrc.cjs and .eslintignore
- Add eslint.config.js with flat config, security rules (no-eval, no-implied-eval, no-new-func, no-script-url)
- Add .prettierrc and .prettierignore
- Format entire codebase with prettier
2026-01-27 17:37:31 +03:00

58 lines
1.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Утилита для логирования только в development режиме
* В production логи не выводятся
*/
const isDev = import.meta.env.DEV;
export const logger = {
log: (...args: unknown[]): void => {
if (isDev) {
console.log(...args);
}
},
warn: (...args: unknown[]): void => {
if (isDev) {
console.warn(...args);
}
},
error: (...args: unknown[]): void => {
// Ошибки логируем всегда (важно для отладки в production)
console.error(...args);
},
debug: (...args: unknown[]): void => {
if (isDev) {
console.debug(...args);
}
},
/**
* Создаёт логгер с префиксом для конкретного модуля
*/
createLogger: (prefix: string) => ({
log: (...args: unknown[]): void => {
if (isDev) {
console.log(`[${prefix}]`, ...args);
}
},
warn: (...args: unknown[]): void => {
if (isDev) {
console.warn(`[${prefix}]`, ...args);
}
},
error: (...args: unknown[]): void => {
console.error(`[${prefix}]`, ...args);
},
debug: (...args: unknown[]): void => {
if (isDev) {
console.debug(`[${prefix}]`, ...args);
}
},
}),
};
export default logger;