.. _program_listing_file_src_sirius_utils_log.h: Program Listing for File log.h ============================== - Return to documentation for :ref:`file_src_sirius_utils_log.h` .. code-block:: cpp #ifndef SIRIUS_UTILS_LOG_H_ #define SIRIUS_UTILS_LOG_H_ #include #ifdef SIRIUS_ENABLE_LOGS #include #include #include #include namespace sirius { namespace utils { class LoggerManager { public: using Logger = spdlog::logger; using LoggerSPtr = std::shared_ptr; public: static LoggerManager& Instance(); void SetLogLevel(spdlog::level::level_enum level); Logger* Get(const std::string& channel); private: LoggerManager() = default; private: std::mutex loggers_mutex_; std::map loggers_; spdlog::level::level_enum log_level_{spdlog::level::info}; }; } // namespace utils } // namespace sirius #define LOG_SET_LEVEL_ENUM(lvl_enum) \ sirius::utils::LoggerManager::Instance().SetLogLevel(lvl_enum) #define LOG_SET_LEVEL(lvl) LOG_SET_LEVEL_ENUM(spdlog::level::lvl) #define LOG(channel, level, ...) \ sirius::utils::LoggerManager::Instance().Get(channel)->level(__VA_ARGS__) #else #define LOG_SET_LEVEL_ENUM(lvl_enum) #define LOG_SET_LEVEL(lvl) #define LOG(channel, level, ...) #endif // SIRIUS_ENABLE_LOGS namespace sirius { namespace utils { void SetVerbosityLevel(const std::string& level); } // namespace utils } // namespace sirius #endif // SIRIUS_UTILS_LOG_H_