feat: add logging enhancements by integrating pino and pino-pretty for improved error tracking and debugging across the application

This commit is contained in:
Julien Froidefond
2025-10-26 06:15:47 +01:00
parent 7cc72dc13d
commit 52350a43d9
84 changed files with 455 additions and 177 deletions

View File

@@ -5,6 +5,7 @@ import { ERROR_CODES } from "@/constants/errorCodes";
import { AppError } from "@/utils/errors";
import { getErrorMessage } from "@/utils/errors";
import { findHttpStatus } from "@/utils/image-errors";
import logger from "@/lib/logger";
export async function GET(
request: NextRequest,
@@ -16,7 +17,7 @@ export async function GET(
const response = await BookService.getCover(bookId);
return response;
} catch (error) {
console.error("Erreur lors de la récupération de la miniature du livre:", error);
logger.error({ err: error }, "Erreur lors de la récupération de la miniature du livre:");
// Chercher un status HTTP 404 dans la chaîne d'erreurs
const httpStatus = findHttpStatus(error);
@@ -24,7 +25,7 @@ export async function GET(
if (httpStatus === 404) {
const bookId: string = (await params).bookId;
// eslint-disable-next-line no-console
console.log(`📷 Thumbnail not found for book: ${bookId}`);
logger.info(`📷 Thumbnail not found for book: ${bookId}`);
return NextResponse.json(
{
error: {