Files
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

96 lines
3.6 KiB
C++

// Copyright Advanced Micro Devices, Inc., or its affiliates.
// SPDX-License-Identifier: MIT
#pragma once
// Only need the forward declaration of LogLevel
#include <rocRoller/Utilities/Settings_fwd.hpp>
#include <fmt/core.h>
#include <fmt/ranges.h>
#include <memory>
#include <string>
namespace rocRoller
{
namespace Log
{
class logger
{
public:
void log(LogLevel level, const std::string& str);
template <typename... Args>
void log(LogLevel level, fmt::format_string<Args...> formatStr, Args&&... args)
{
if(should_log(level))
{
std::string buf;
fmt::vformat_to(
std::back_inserter(buf), formatStr, fmt::make_format_args(args...));
log(level, buf);
}
}
#define add_logging_method(method_name, level_name) \
inline void method_name(const std::string& str) \
{ \
log(LogLevel::level_name, str); \
} \
template <typename... Args> \
inline void method_name(fmt::format_string<Args...> formatStr, Args&&... args) \
{ \
log(LogLevel::level_name, formatStr, std::forward<Args>(args)...); \
}
add_logging_method(trace, Trace);
add_logging_method(debug, Debug);
add_logging_method(info, Info);
add_logging_method(warn, Warning);
add_logging_method(error, Error);
add_logging_method(critical, Critical);
bool should_log(LogLevel msg_level) const;
};
using LoggerPtr = std::shared_ptr<logger>;
LoggerPtr getLogger();
inline void log(LogLevel level, const std::string& str)
{
static auto defaultLog = getLogger();
defaultLog->log(level, str);
}
template <typename... Args>
inline void log(LogLevel level, fmt::format_string<Args...> formatStr, Args&&... args)
{
static auto defaultLog = getLogger();
defaultLog->log(level, formatStr, std::forward<Args>(args)...);
}
#define declare_logging_function(name) \
inline void name(const std::string& str) \
{ \
static auto defaultLog = getLogger(); \
defaultLog->name(str); \
} \
template <typename... Args> \
inline void name(fmt::format_string<Args...> formatStr, Args&&... args) \
{ \
static auto defaultLog = getLogger(); \
defaultLog->name(formatStr, std::forward<Args>(args)...); \
}
declare_logging_function(trace);
declare_logging_function(debug);
declare_logging_function(info);
declare_logging_function(warn);
declare_logging_function(error);
declare_logging_function(critical);
} // namespace Log
} // namespace rocRoller