This commit is contained in:
2026-02-02 23:32:39 +08:00
parent fa6301538b
commit 76749549ff
18 changed files with 590 additions and 74 deletions

25
src/lib/logger.ts Normal file
View File

@@ -0,0 +1,25 @@
class Logger {
error(message: string, error?: unknown): void {
if (error instanceof Error) {
console.error(`[ERROR] ${message}:`, error.message, error.stack);
} else {
console.error(`[ERROR] ${message}:`, error);
}
}
warn(message: string, ...args: unknown[]): void {
console.warn(`[WARN] ${message}`, ...args);
}
info(message: string, ...args: unknown[]): void {
console.info(`[INFO] ${message}`, ...args);
}
debug(message: string, ...args: unknown[]): void {
if (process.env.NODE_ENV === "development") {
console.debug(`[DEBUG] ${message}`, ...args);
}
}
}
export const logger = new Logger();