klg-asutk-app/lib/logger.ts
Yuriy a7da43be0e apply recommendations: security, get_db, exceptions, eslint, api-client
- session: set_tenant use bound param (SQL injection fix)
- health: text('SELECT 1'), REDIS_URL from config
- deps: re-export get_db from session, use settings.ENABLE_DEV_AUTH (default False)
- routes: all get_db from app.api.deps; conftest overrides deps.get_db
- main: register exception handlers from app.api.exceptions
- next.config: enable ESLint and TypeScript checks
- .eslintrc: drop @typescript-eslint/recommended; fix no-console (logger, ws-client, regulations)
- backend/.env.example added
- frontend: export apiFetch; dashboard, profile, settings, risks use api-client
- docs/ANALYSIS_AND_RECOMMENDATIONS.md

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-14 21:48:58 +03:00

40 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.

/**
* Единый логгер приложения. Используйте вместо console.log.
* В production можно заменить вывод на отправку в систему мониторинга.
*/
/* eslint-disable no-console -- this file implements the logger using console */
const isDev = typeof process !== "undefined" && process.env?.NODE_ENV === "development";
function noop(): void {}
function devLog(level: string, ...args: unknown[]): void {
if (typeof console !== "undefined" && isDev) {
const fn = level === "error" ? console.error : level === "warn" ? console.warn : console.log;
fn(`[${level}]`, ...args);
}
}
export function log(...args: unknown[]): void {
devLog("log", ...args);
}
export function logInfo(...args: unknown[]): void {
devLog("info", ...args);
}
export function logAudit(...args: unknown[]): void {
devLog("audit", ...args);
}
export function logError(...args: unknown[]): void {
if (typeof console !== "undefined") console.error("[error]", ...args);
}
export function logSecurity(...args: unknown[]): void {
if (typeof console !== "undefined") console.warn("[security]", ...args);
}
export function logWarn(...args: unknown[]): void {
if (typeof console !== "undefined") console.warn("[warn]", ...args);
}