Skip to content

Fix LogLevel ordering so Warn threshold correctly suppresses Info messages#280

Merged
syoyo merged 2 commits into
releasefrom
copilot/fix-loglevel-ordering-issue
Jul 15, 2026
Merged

Fix LogLevel ordering so Warn threshold correctly suppresses Info messages#280
syoyo merged 2 commits into
releasefrom
copilot/fix-loglevel-ordering-issue

Conversation

Copilot AI commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

LogLevel had Warn=1, Info=2, so shouldLog() (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): defines tinyusdz::logging::LogLevel with monotonically-increasing severity values, a Logger singleton (default threshold: Warn), and TUSDZ_LOG_D/I/W/E/C macros with file/func/line context. Production builds (TINYUSDZ_PRODUCTION_BUILD) omit file paths.

    enum class LogLevel {
      Debug    = 0,
      Info     = 1,  // was 2 — caused Info to bypass Warn threshold
      Warn     = 2,  // was 1
      Error    = 3,
      Critical = 4,
      Off      = 5
    };
  • tests/unit/unit-logger.cc (new): unit tests covering enum ordinal values and shouldLog() correctness across all threshold levels (Debug, Info, Warn, Off).

  • tests/unit/unit-main.cc, CMakeLists.txt: wire logger_test into the existing unit-test binary.

…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
Copilot finished work on behalf of syoyo July 14, 2026 16:41
Copilot AI requested a review from syoyo July 14, 2026 16:41
@syoyo
syoyo marked this pull request as ready for review July 15, 2026 04:42
@syoyo
syoyo merged commit 4b522a6 into release Jul 15, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LogLevel ordering causes INFO messages to pass the default WARN threshold

2 participants