Log at debug level
georgii-tishenin opened this issue · 1 comments
georgii-tishenin commented
Issue Summary
It is somewhat challenging to configure logging at the debug level. Additionally, there seems to be a mismatch between the intended and actual use of the Logger
class.
Example Scenario
I am working with the DP_VS_RL1 example and I want to see the SPDLOG_LOGGER_DEBUG
messages in the log files of components and the solver. I have implemented this in the log-at-debug-level branch.
Steps Taken:
- Set debug logging level for components and simulation objects in the DP_VS_RL1 example.
- This step is intuitive.
- Set
SPDLOG_ACTIVE_LEVEL
toDEBUG
inLogger.h
.- This step is less intuitive. But I do understand this is necessary to compile out debug logging statements for performance reasons.
- Set log level for
mSLog
inTopologicalPowerComp
andSolver
.- This step is not intuitive to me and suggests a mismatch between the intended and actual use of the
Logger
class byTopologicalPowerComp
,Solver
, and other classes.
- This step is not intuitive to me and suggests a mismatch between the intended and actual use of the
Identified Mismatch
- The
Logger
class has a staticLogger::setLogLevel
function to set the log level for aspdlog::logger
object, but this function is never used (at least, I couldn't find any references). TopologicalPowerComp
andSolver
call the staticLogger::get
function to create/get thespdlog::logger
object. However, the log level of thespdlog::logger
object is not set within the scope of theLogger::get
function, resulting in a default log level ofinfo
.
Suggestions for Improvement
-
Eliminate the need for Step 3.
- Either adjust the
Logger
class or it's usage, so that the log level is set appropriately when creating or retrieving aspdlog::logger
object.
- Either adjust the
-
Address the less intuitive aspects of Step 2:
- Document the need to set
SPDLOG_ACTIVE_LEVEL
toDEBUG
. - Automatically set
SPDLOG_ACTIVE_LEVEL
toDEBUG
for Debug builds.
- Document the need to set
Discussion
What do you think? I look forward to your feedback and discussion on these points.
leonardocarreras commented