Fix LogLevel ordering so Warn threshold correctly suppresses Info messages#280
Merged
Conversation
…sages The LogLevel enum had Warn=1 and Info=2, causing shouldLog() to pass Info messages through a Warn threshold (2 >= 1) and incorrectly suppress Warn messages when the threshold was set to Info. Fix: reorder enum to Debug=0, Info=1, Warn=2, Error=3, Critical=4, Off=5 so that severity increases monotonically and the >= comparison works correctly. Also adds: - src/logger.hh: Logger singleton, TUSDZ_LOG_D/I/W/E/C macros - tests/unit/unit-logger.cc/.h: unit tests for enum values and shouldLog() - Wire new test into unit-main.cc and CMakeLists.txt Closes #279
Copilot
AI
changed the title
[WIP] Fix LogLevel ordering to prevent INFO messages passing WARN threshold
Fix LogLevel ordering so Warn threshold correctly suppresses Info messages
Jul 14, 2026
syoyo
marked this pull request as ready for review
July 15, 2026 04:42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LogLevelhadWarn=1, Info=2, soshouldLog()(using>=) would pass Info messages through a Warn threshold and block Warn messages when the threshold was Info — the opposite of correct behaviour.Changes
src/logger.hh(new): definestinyusdz::logging::LogLevelwith monotonically-increasing severity values, aLoggersingleton (default threshold:Warn), andTUSDZ_LOG_D/I/W/E/Cmacros with file/func/line context. Production builds (TINYUSDZ_PRODUCTION_BUILD) omit file paths.tests/unit/unit-logger.cc(new): unit tests covering enum ordinal values andshouldLog()correctness across all threshold levels (Debug,Info,Warn,Off).tests/unit/unit-main.cc,CMakeLists.txt: wirelogger_testinto the existing unit-test binary.