- Remove .prettierrc (dead config, Biome replaces Prettier) - Rename lighthouserc.json to lighthouserc.cjs with module.exports for ESM compat - Add logger.warn to empty catch blocks in auth, register, site-settings, prisma-cache, redis, security, rate-limit - Unify ActionResult type: action-helper.ts uses 'ok' consistent with safe-action-shared.ts - Add noUnusedLocals + noUnusedParameters to tsconfig + fix 25 pre-existing unused vars - Replace barrel export src/types/index.ts with direct @/types/common imports - Make trustHost conditional (development only) in auth.ts - Add pre-flight URL validation to update-Nitrov3.sh to catch image.library.url misconfigurations - Improve NITRO_IMAGE_LIBRARY_URL content validation in pre-flight & post-compute checks
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import pino from "pino";
|
|
import { env } from "@/env";
|
|
|
|
type LogLevel = "debug" | "info" | "warn" | "error";
|
|
|
|
const level: LogLevel =
|
|
(env.LOG_LEVEL as LogLevel | undefined) ??
|
|
(env.NODE_ENV === "production" ? "info" : "debug");
|
|
|
|
const isProd = env.NODE_ENV === "production";
|
|
const isTest = env.NODE_ENV === "test" || process.env.VITEST === "true";
|
|
|
|
const pinoLogger = pino({
|
|
level,
|
|
base: { service: "atomcms-next" },
|
|
...(isProd || isTest
|
|
? {}
|
|
: {
|
|
transport: {
|
|
target: "pino-pretty",
|
|
options: { colorize: true, translateTime: "SYS:standard" },
|
|
},
|
|
}),
|
|
});
|
|
|
|
let requestIdCounter = 0;
|
|
|
|
export function generateRequestId(): string {
|
|
requestIdCounter += 1;
|
|
return `${Date.now().toString(36)}-${requestIdCounter.toString(36)}`;
|
|
}
|
|
|
|
/** Compatibility wrapper — existing call sites use (message, meta). */
|
|
export const logger = {
|
|
debug(message: string, meta: Record<string, unknown> = {}): void {
|
|
pinoLogger.debug(meta, message);
|
|
},
|
|
info(message: string, meta: Record<string, unknown> = {}): void {
|
|
pinoLogger.info(meta, message);
|
|
},
|
|
warn(message: string, meta: Record<string, unknown> = {}): void {
|
|
pinoLogger.warn(meta, message);
|
|
},
|
|
error(message: string, meta: Record<string, unknown> = {}): void {
|
|
pinoLogger.error(meta, message);
|
|
},
|
|
};
|