Ensure debug logging behaves correctly by only activating when debug flags are explicitly enabled, while providing comprehensive coverage of all relevant cases when active. Debug logs should not cause application failures and should be printed for all error conditions, not just specific subsets.
Ensure debug logging behaves correctly by only activating when debug flags are explicitly enabled, while providing comprehensive coverage of all relevant cases when active. Debug logs should not cause application failures and should be printed for all error conditions, not just specific subsets.
Key principles:
-d
flag)Example of proper debug setup:
// Correct: Debug only enabled when intended
const debug = debugLib('snyk-code');
// Incorrect: Always enabling debug
debugLib.enable('snyk-code');
const debug = debugLib('snyk-code');
Example of comprehensive debug coverage:
// Print debug logs for all cases, not just specific conditions
if (debugLogs[fileData.filePath]) {
debug(
'File %s failed to parse with: %s',
fileData.filePath,
debugLogs[fileData.filePath],
);
}
Enter the URL of a public GitHub repository