onnxruntime
5a5fec04 - Fix logs getting skipped in single-line conditionals. (#7589)

Commit
5 years ago
Fix logs getting skipped in single-line conditionals. (#7589) Fix an issue where a log message got skipped. A log call like this: ``` LOGS(...) << "message"; ``` expands to something like this: ``` if (<output enabled>) logging::Capture(...).Stream() << "message"; ``` This if statement without brackets is handy for logging arbitrary arguments with the `<<` operator. However, it has other drawbacks like possibly associating with a subsequent `else`. ``` if (cond) LOGS(...) << "a"; else <do something> // not run when !cond // equivalently: if (cond) if (<output enabled>) logging::Capture(...).Stream() << "a"; else <do something> // not run when !cond ``` Updated the logging macros to handle this case by replacing `if (<enabled>) logging::Capture(...).Stream()` with `if (!<enabled>) {} else logging::Capture(...).Stream()`. Thanks @tlh20 for the idea for the fix!
Author
Parents
Loading