Implement logger changes (#5914)

* Implement logger changes, and make default log level dynamic based on debug/release.

* Bump LUS.

* typo

Co-authored-by: Eblo <7004497+Eblo@users.noreply.github.com>

---------

Co-authored-by: Eblo <7004497+Eblo@users.noreply.github.com>
This commit is contained in:
Malkierian
2025-11-03 18:54:01 -07:00
committed by GitHub
parent 0014f40676
commit cf275b1a6c
6 changed files with 33 additions and 6 deletions

20
CMake/logging.cmake Normal file
View File

@@ -0,0 +1,20 @@
set(SPDLOG_LEVEL_TRACE 0)
set(SPDLOG_LEVEL_DEBUG 1)
set(SPDLOG_LEVEL_INFO 2)
set(SPDLOG_LEVEL_WARN 3)
set(SPDLOG_LEVEL_ERROR 4)
set(SPDLOG_LEVEL_CRITICAL 5)
set(SPDLOG_LEVEL_OFF 6)
set(LOG_LEVELS "SPDLOG_LEVEL_TRACE;SPDLOG_LEVEL_DEBUG;SPDLOG_LEVEL_INFO;SPDLOG_LEVEL_WARN;SPDLOG_LEVEL_ERROR;SPDLOG_LEVEL_CRITICAL;SPDLOG_LEVEL_OFF")
set(LOG_LEVEL SPDLOG_LEVEL_TRACE CACHE STRING "The spdlog level that prints will be logged out. Overridden to SPDLOG_LEVEL_ERROR on Release builds.")
set_property(CACHE LOG_LEVEL PROPERTY STRINGS ${LOG_LEVELS})
if(NOT LOG_LEVEL IN_LIST LOG_LEVELS)
message(FATAL_ERROR "LOG_LEVEL must be one of ${LOG_LEVELS}")
endif()
set(SPDLOG_ACTIVE_LEVEL ${${LOG_LEVEL}})
set(LOG_LEVEL_GAME_PRINTS ${SPDLOG_LEVEL_OFF})
add_compile_definitions(
LOG_LEVEL_GAME_PRINTS=${LOG_LEVEL_GAME_PRINTS}
SPDLOG_ACTIVE_LEVEL=${SPDLOG_ACTIVE_LEVEL}
)