diff --git a/server.ts b/server.ts index b5d6c39..3b665aa 100644 --- a/server.ts +++ b/server.ts @@ -208,7 +208,7 @@ app.get("/jobs/analysis", ValidateImsToken, async (req, res) => { const analysis = await analyzeJobsDirectory(); res.json(analysis); } catch (error) { - logger.error("Failed to analyze jobs directory:", error); + logger.error("Failed to analyze jobs directory:", JSON.stringify(error, null, 2)); const errorMessage = error instanceof Error ? error.message : "Unknown error"; res.status(500).json({ success: false, message: "Jobs analysis failed", error: errorMessage }); } diff --git a/util/s3Sync.ts b/util/s3Sync.ts index 9cede37..3965d04 100644 --- a/util/s3Sync.ts +++ b/util/s3Sync.ts @@ -91,7 +91,7 @@ export class S3Sync { } if (stderr) { - logger.warn("S3 sync warnings:", stderr); + logger.warning("S3 sync warnings:", stderr); } logger.info("S3 sync completed successfully using AWS CLI"); @@ -167,7 +167,7 @@ export function createS3SyncFromEnv(): S3Sync | null { const keyPrefix = process.env.S3_KEY_PREFIX || "prefix"; if (!bucketName || !accessKeyId || !secretAccessKey) { - logger.warn( + logger.warning( "S3 configuration incomplete. Required env vars: S3_BUCKET_NAME, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY" ); return null; @@ -198,7 +198,7 @@ export async function analyzeJobsDirectory(): Promise { // Check if Jobs directory exists if (!(await fs.pathExists(jobsPath))) { - logger.warn(`Jobs directory does not exist: ${jobsPath}`); + logger.warning(`Jobs directory does not exist: ${jobsPath}`); return { bodyshopid, total_jobs: 0, @@ -284,13 +284,14 @@ export async function analyzeJobsDirectory(): Promise { : "https://api.imex.online/analytics/documents"; const result = await axios.post(apiURL, { data: analysis }); + logger.info(`Uploaded analysis results, response status: ${result.status}`); // Clean up temporary file await fsPromises.unlink(tempFilePath); logger.info("Cleaned up temporary analysis file"); return analysis; } catch (error) { - logger.error("Failed to analyze Jobs directory:", JSON.stringify(error, null, 4)); + logger.error("Failed to analyze Jobs directory:", (error as Error).message, (error as Error).stack); // Attempt to clean up temp file on error try { if (await fs.pathExists(tempFilePath)) { @@ -298,7 +299,7 @@ export async function analyzeJobsDirectory(): Promise { logger.info("Cleaned up temporary file after error"); } } catch (cleanupError) { - logger.warn("Failed to clean up temporary file:", cleanupError); + logger.warning("Failed to clean up temporary file:", cleanupError); } throw error; } @@ -319,7 +320,7 @@ async function analyzeJobFolder(jobsPath: string, jobid: string, bodyshopid: UUI } else if (uuidRegex.test(jobid)) { validJobid = jobid as UUID; } else { - logger.warn(`Invalid jobid encountered in analyzeJobFolder: ${jobid}`); + logger.warning(`Invalid jobid encountered in analyzeJobFolder: ${jobid}`); validJobid = null; } return {