Fix logger.warn calls.

This commit is contained in:
Patrick Fic
2025-11-10 15:22:05 -08:00
parent 05c325f696
commit 75d1f7199b
2 changed files with 8 additions and 7 deletions

View File

@@ -208,7 +208,7 @@ app.get("/jobs/analysis", ValidateImsToken, async (req, res) => {
const analysis = await analyzeJobsDirectory(); const analysis = await analyzeJobsDirectory();
res.json(analysis); res.json(analysis);
} catch (error) { } 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"; const errorMessage = error instanceof Error ? error.message : "Unknown error";
res.status(500).json({ success: false, message: "Jobs analysis failed", error: errorMessage }); res.status(500).json({ success: false, message: "Jobs analysis failed", error: errorMessage });
} }

View File

@@ -91,7 +91,7 @@ export class S3Sync {
} }
if (stderr) { if (stderr) {
logger.warn("S3 sync warnings:", stderr); logger.warning("S3 sync warnings:", stderr);
} }
logger.info("S3 sync completed successfully using AWS CLI"); 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"; const keyPrefix = process.env.S3_KEY_PREFIX || "prefix";
if (!bucketName || !accessKeyId || !secretAccessKey) { 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" "S3 configuration incomplete. Required env vars: S3_BUCKET_NAME, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY"
); );
return null; return null;
@@ -198,7 +198,7 @@ export async function analyzeJobsDirectory(): Promise<JobsDirectoryAnalysis> {
// Check if Jobs directory exists // Check if Jobs directory exists
if (!(await fs.pathExists(jobsPath))) { if (!(await fs.pathExists(jobsPath))) {
logger.warn(`Jobs directory does not exist: ${jobsPath}`); logger.warning(`Jobs directory does not exist: ${jobsPath}`);
return { return {
bodyshopid, bodyshopid,
total_jobs: 0, total_jobs: 0,
@@ -284,13 +284,14 @@ export async function analyzeJobsDirectory(): Promise<JobsDirectoryAnalysis> {
: "https://api.imex.online/analytics/documents"; : "https://api.imex.online/analytics/documents";
const result = await axios.post(apiURL, { data: analysis }); const result = await axios.post(apiURL, { data: analysis });
logger.info(`Uploaded analysis results, response status: ${result.status}`);
// Clean up temporary file // Clean up temporary file
await fsPromises.unlink(tempFilePath); await fsPromises.unlink(tempFilePath);
logger.info("Cleaned up temporary analysis file"); logger.info("Cleaned up temporary analysis file");
return analysis; return analysis;
} catch (error) { } 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 // Attempt to clean up temp file on error
try { try {
if (await fs.pathExists(tempFilePath)) { if (await fs.pathExists(tempFilePath)) {
@@ -298,7 +299,7 @@ export async function analyzeJobsDirectory(): Promise<JobsDirectoryAnalysis> {
logger.info("Cleaned up temporary file after error"); logger.info("Cleaned up temporary file after error");
} }
} catch (cleanupError) { } catch (cleanupError) {
logger.warn("Failed to clean up temporary file:", cleanupError); logger.warning("Failed to clean up temporary file:", cleanupError);
} }
throw error; throw error;
} }
@@ -319,7 +320,7 @@ async function analyzeJobFolder(jobsPath: string, jobid: string, bodyshopid: UUI
} else if (uuidRegex.test(jobid)) { } else if (uuidRegex.test(jobid)) {
validJobid = jobid as UUID; validJobid = jobid as UUID;
} else { } else {
logger.warn(`Invalid jobid encountered in analyzeJobFolder: ${jobid}`); logger.warning(`Invalid jobid encountered in analyzeJobFolder: ${jobid}`);
validJobid = null; validJobid = null;
} }
return { return {