14#include <boost/assign.hpp>
15#include <boost/bimap.hpp>
19#include <spdlog/spdlog.h>
20#include <spdlog/fmt/fmt.h>
22#include <Acts/Utilities/Logger.hpp>
26using namespace Acts::Logging;
30 boost::assign::list_of<SpdlogToActsLevel_t::relation>(
31 spdlog::level::trace, Acts::Logging::VERBOSE)(spdlog::level::debug, Acts::Logging::DEBUG)(
32 spdlog::level::info, Acts::Logging::INFO)(spdlog::level::warn, Acts::Logging::WARNING)(
33 spdlog::level::err, Acts::Logging::ERROR)(spdlog::level::critical, Acts::Logging::FATAL);
37 return kSpdlogToActsLevel.left.at(input);
40 fmt::format(
"SpdlogToActsLevel doesn't know this log level: '{}'", fmt::underlying(input));
41 throw std::runtime_error(err_msg);
47 return kSpdlogToActsLevel.right.at(input);
50 fmt::format(
"ActsToSpdlogLevel doesn't know this log level: '{}'", fmt::underlying(input));
51 throw std::runtime_error(err_msg);
75 void flush(
const Level& lvl,
const std::string& input)
final {
77 if (lvl >= getFailureThreshold()) {
78 throw ThresholdFailure(
"Previous debug message exceeds the "
79 "ACTS_LOG_FAILURE_THRESHOLD=" +
80 std::string{levelName(getFailureThreshold())} +
81 " configuration, bailing out. See "
82 "https://acts.readthedocs.io/en/latest/core/"
83 "logging.html#logging-thresholds");
93 const std::string&
name()
const override {
94 throw std::runtime_error{
95 "Default print policy doesn't have a name. Is there no named output in "
96 "the decorator chain?"};
102 std::unique_ptr<OutputPrintPolicy>
clone(
const std::string&
name)
const override {
104 return std::make_unique<SpdlogPrintPolicy>(m_out);
109 std::shared_ptr<spdlog::logger> m_out;
113 std::shared_ptr<spdlog::logger> log) {
116 auto output = std::make_unique<Acts::Logging::NamedOutputDecorator>(
117 std::make_unique<SpdlogPrintPolicy>(log), name);
118 auto print = std::make_unique<DefaultFilterPolicy>(lvl);
119 return std::make_unique<const Acts::Logger>(std::move(output), std::move(print));
default print policy for debug messages
Definition SpdlogToActs.h:59
SpdlogPrintPolicy(std::shared_ptr< spdlog::logger > out)
constructor
Definition SpdlogToActs.h:66
std::unique_ptr< OutputPrintPolicy > clone(const std::string &name) const override
Definition SpdlogToActs.h:102
~SpdlogPrintPolicy()=default
destructor
const std::string & name() const override
Definition SpdlogToActs.h:93
void flush(const Level &lvl, const std::string &input) final
flush the debug message to the destination stream
Definition SpdlogToActs.h:75
-client
Definition CalorimeterClusterRecoCoG.cc:37
spdlog::level::level_enum ActsToSpdlogLevel(Acts::Logging::Level input)
Definition SpdlogToActs.h:45
boost::bimap< spdlog::level::level_enum, Acts::Logging::Level > SpdlogToActsLevel_t
Definition SpdlogToActs.h:28
std::unique_ptr< const Acts::Logger > getSpdlogLogger(const std::string &name, std::shared_ptr< spdlog::logger > log)
Definition SpdlogToActs.h:112
Acts::Logging::Level SpdlogToActsLevel(spdlog::level::level_enum input)
Definition SpdlogToActs.h:35