[rocprofiler-systems] Update logging to use spdlog library (#2428)

## Motivation

- Structured logging with proper log levels (TRACE, DEBUG, INFO, WARNING, ERROR, CRITICAL)
- Better performance through compile-time formatting
- Consistent formatting using fmt library
- Runtime log level control via arguments and environment variables
- Easier maintenance and debugging capabilities

## Technical Details

- Added spdlog as a submodule and integrated it into CMake build system
- Created new `rocprofiler-systems-logger` library wrapping spdlog functionality
- Replaced custom logging macros (`ROCPROFSYS_VERBOSE`, `ROCPROFSYS_DEBUG`, `ROCPROFSYS_FATAL`, `ROCPROFSYS_REQUIRE`, `ROCPROFSYS_CI_THROW`, etc.) with spdlog equivalents (`LOG_DEBUG`, `LOG_WARNING`, `LOG_CRITICAL`, etc.)
- Implemented log level control through command-line arguments and environment variables
- Converted assertion macros to proper error handling with exceptions and std::abort()
This commit is contained in:
Milan Radosavljevic
2026-01-14 21:27:51 +01:00
committed by GitHub
parent 499127c0b9
commit 318d13870f
111 changed files with 2657 additions and 2602 deletions
@@ -22,11 +22,12 @@
#include "library/process_sampler.hpp"
#include "core/config.hpp"
#include "core/debug.hpp"
#include "library/amd_smi.hpp"
#include "library/cpu_freq.hpp"
#include "library/runtime.hpp"
#include "logger/debug.hpp"
#include <memory>
#include <vector>
@@ -83,8 +84,8 @@ sampler::poll(std::atomic<State>* _state, nsec_t _interval, promise_t* _ready)
for(auto& itr : instances)
itr->config();
ROCPROFSYS_VERBOSE(
1, "Background process sampling polling at an interval of %f seconds...\n",
LOG_DEBUG(
"Background process sampling polling at an interval of {:.2f} seconds...",
std::chrono::duration_cast<std::chrono::duration<double>>(_interval).count());
auto _duration = config::get_process_sampling_duration();
@@ -113,15 +114,12 @@ sampler::poll(std::atomic<State>* _state, nsec_t _interval, promise_t* _ready)
if(_has_duration && _now >= _end && get_state() < State::Finalized)
{
ROCPROFSYS_VERBOSE(
1,
"Background process sampling duration of %f seconds has elapsed. "
"Shutting down process sampling...\n",
_duration);
LOG_DEBUG("Background process sampling duration of {:.2f} seconds has elapsed. "
"Shutting down process sampling...",
_duration);
}
ROCPROFSYS_CONDITIONAL_BASIC_PRINT(get_debug(),
"Thread sampler polling completed...\n");
LOG_DEBUG("Thread sampler polling completed...");
if(polling_finished) polling_finished->set_value();
}
@@ -131,11 +129,11 @@ sampler::setup()
{
if(!get_use_process_sampling())
{
ROCPROFSYS_DEBUG("Background sampler is disabled...\n");
LOG_DEBUG("Background sampler is disabled...");
return;
}
ROCPROFSYS_VERBOSE(1, "Setting up background sampler...\n");
LOG_DEBUG("Setting up background sampler...");
// shutdown if already running
shutdown();
@@ -204,7 +202,10 @@ sampler::shutdown()
}
// during CI, throw an error if polling_finished is not valid
ROCPROFSYS_CI_THROW(!polling_finished, "polling_finished is not valid\n");
if(!polling_finished && get_is_continuous_integration())
{
throw std::runtime_error("polling_finished is not valid");
}
if(polling_finished)
{
// wait for the thread to finish