[grade=A] DC-065: Sweep 15 console.* calls to process.stderr.write
Replace all non-logger console.error/warn calls with process.stderr.write using tagged prefixes ([AuditLogger], [CSRF], [DNS Registry], etc.) for grep-ability. All in fallback/catch paths where structured logger may be unavailable. Test updated to use jest.spyOn with try/finally for clean mock restoration. Codex grade: pass (22,402 tokens). All 1539 tests pass.
This commit is contained in:
@@ -34,7 +34,7 @@ function errorMiddleware(err, req, res, next) {
|
||||
userId: req.user?.id,
|
||||
body: req.body
|
||||
}
|
||||
).catch(e => console.error('Failed to write to error log:', e.message));
|
||||
).catch(e => process.stderr.write(`[error-handler] Failed to write to error log: ${e.message}\n`));
|
||||
|
||||
// Determine if this is an operational error (AppError) or programming error
|
||||
const isOperational = err.isOperational || err instanceof AppError;
|
||||
@@ -65,11 +65,7 @@ function errorMiddleware(err, req, res, next) {
|
||||
|
||||
// For non-operational errors, log as fatal
|
||||
if (!isOperational) {
|
||||
console.error('FATAL: Non-operational error detected', {
|
||||
error: err.message,
|
||||
stack: err.stack,
|
||||
path: req.path
|
||||
});
|
||||
process.stderr.write(`[FATAL] Non-operational error detected: ${JSON.stringify({ error: err.message, stack: err.stack, path: req.path })}\n`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user