added stack trace to some logging

This commit is contained in:
jackiettran
2025-12-25 18:41:42 -05:00
parent b02ec19d5c
commit 76e4039ba8
15 changed files with 307 additions and 173 deletions

View File

@@ -49,17 +49,29 @@ const logFormat = winston.format.combine(
const { timestamp, level, message, stack, ...metadata } = info;
let output = `${timestamp} ${level}: ${message}`;
// Check for stack trace in the info object itself
if (stack) {
output += `\n${stack}`;
// Include relevant metadata in console output
const metaKeys = Object.keys(metadata).filter(key =>
!['splat', 'Symbol(level)', 'Symbol(message)'].includes(key) &&
!key.startsWith('Symbol')
);
if (metaKeys.length > 0) {
const metaOutput = {};
metaKeys.forEach(key => {
// For Error objects, extract message and stack
if (metadata[key] && metadata[key].stack) {
metaOutput[key] = { message: metadata[key].message, stack: metadata[key].stack };
} else {
metaOutput[key] = metadata[key];
}
});
output += ` ${JSON.stringify(metaOutput, null, 2)}`;
}
// Check for Error objects in metadata
Object.keys(metadata).forEach(key => {
if (metadata[key] && metadata[key].stack) {
output += `\n${key}: ${metadata[key].message}\n${metadata[key].stack}`;
}
});
// Check for stack trace in the info object itself
if (stack) {
output += `\nStack: ${stack}`;
}
return output;
}),