feature/IO-3303-logging - Logging

This commit is contained in:
Dave Richer
2025-07-14 19:28:29 -04:00
parent fbd6766dcd
commit 5f621e1ae0
2 changed files with 111 additions and 94 deletions

View File

@@ -19,7 +19,7 @@ async function JobCosting(req, res) {
const client = req.userGraphQLClient; const client = req.userGraphQLClient;
//Uncomment for further testing //Uncomment for further testing
// logger.log("job-costing-start", "DEBUG", req.user.email, jobid, null); logger.log("job-costing-start", "DEBUG", req.user.email, jobid, null);
try { try {
const resp = await client.setHeaders({ Authorization: BearerToken }).request(queries.QUERY_JOB_COSTING_DETAILS, { const resp = await client.setHeaders({ Authorization: BearerToken }).request(queries.QUERY_JOB_COSTING_DETAILS, {
@@ -47,9 +47,9 @@ async function JobCostingMulti(req, res) {
const client = req.userGraphQLClient; const client = req.userGraphQLClient;
//Uncomment for further testing //Uncomment for further testing
// logger.log("job-costing-multi-start", "DEBUG", req?.user?.email, null, { logger.log("job-costing-multi-start", "DEBUG", req?.user?.email, null, {
// jobids jobids
// }); });
try { try {
const resp = await client const resp = await client

View File

@@ -8,6 +8,7 @@ const getLifecycleStatusColor = require("../utils/getLifecycleStatusColor");
const jobLifecycle = async (req, res) => { const jobLifecycle = async (req, res) => {
// Grab the jobids and statuses from the request body // Grab the jobids and statuses from the request body
const { jobids, statuses } = req.body; const { jobids, statuses } = req.body;
const { logger } = req;
if (!jobids) { if (!jobids) {
return res.status(400).json({ return res.status(400).json({
@@ -16,6 +17,12 @@ const jobLifecycle = async (req, res) => {
} }
const jobIDs = _.isArray(jobids) ? jobids : [jobids]; const jobIDs = _.isArray(jobids) ? jobids : [jobids];
logger.log("job-lifecycle-start", "DEBUG", req?.user?.email, null, {
jobids: jobIDs
});
try {
const client = req.userGraphQLClient; const client = req.userGraphQLClient;
const resp = await client.request(queries.QUERY_TRANSITIONS_BY_JOBID, { jobids: jobIDs }); const resp = await client.request(queries.QUERY_TRANSITIONS_BY_JOBID, { jobids: jobIDs });
@@ -112,6 +119,16 @@ const jobLifecycle = async (req, res) => {
: durationToHumanReadable(moment.duration(0)) : durationToHumanReadable(moment.duration(0))
} }
}); });
} catch (error) {
logger.log("job-lifecycle-error", "ERROR", req?.user?.email, null, {
jobids: jobIDs,
statuses: statuses ? JSON.stringify(statuses) : "N/A",
error: error.message
});
return res.status(500).json({
error: "Internal server error"
});
}
}; };
module.exports = jobLifecycle; module.exports = jobLifecycle;