22 #include <string_view>
49 #define ACTS_LOCAL_LOGGER(log_object) \
50 struct __local_acts_logger \
52 __local_acts_logger(std::unique_ptr<const ::Acts::Logger> logger): \
53 m_logger(std::move(logger)) \
56 const ::Acts::Logger& operator()() const \
61 std::unique_ptr<const ::Acts::Logger> m_logger; \
63 __local_acts_logger logger(log_object);
66 #define ACTS_LOG(level, x) \
67 if (logger().doPrint(level)) { \
68 std::ostringstream os; \
70 logger().log(level, os.str()); \
83 #define ACTS_VERBOSE(x) ACTS_LOG(Acts::Logging::VERBOSE, x)
95 #define ACTS_DEBUG(x) ACTS_LOG(Acts::Logging::DEBUG, x)
107 #define ACTS_INFO(x) ACTS_LOG(Acts::Logging::INFO, x)
119 #define ACTS_WARNING(x) ACTS_LOG(Acts::Logging::WARNING, x)
131 #define ACTS_ERROR(x) ACTS_LOG(Acts::Logging::ERROR, x)
143 #define ACTS_FATAL(x) ACTS_LOG(Acts::Logging::FATAL, x)
182 throw std::invalid_argument{
"Unknown level"};
199 #ifdef ACTS_ENABLE_LOG_FAILURE_THRESHOLD
200 #ifdef ACTS_LOG_FAILURE_THRESHOLD
203 return Level::ACTS_LOG_FAILURE_THRESHOLD;
233 using std::runtime_error::runtime_error;
258 virtual std::unique_ptr<OutputPrintPolicy>
clone(
286 virtual std::unique_ptr<OutputFilterPolicy>
clone(
Level level)
const = 0;
301 "Requested debug level is incompatible with "
302 "the ACTS_LOG_FAILURE_THRESHOLD=" +
304 " configuration. See "
305 "https://acts.readthedocs.io/en/latest/core/"
306 "logging.html#logging-thresholds");
328 return std::make_unique<DefaultFilterPolicy>(
level);
394 std::ostringstream
os;
403 std::unique_ptr<OutputPrintPolicy>
clone(
405 return std::make_unique<NamedOutputDecorator>(
m_wrappee->clone(name),
name,
442 std::ostringstream
os;
450 std::unique_ptr<OutputPrintPolicy>
clone(
452 return std::make_unique<TimedOutputDecorator>(
m_wrappee->clone(name),
464 std::strftime(buffer,
sizeof(buffer),
m_format.c_str(), localtime(&
t));
491 std::ostringstream
os;
492 os <<
std::left << std::setw(20) << std::this_thread::get_id() <<
input;
499 std::unique_ptr<OutputPrintPolicy>
clone(
501 return std::make_unique<ThreadOutputDecorator>(
m_wrappee->clone(name));
524 std::ostringstream
os;
532 std::unique_ptr<OutputPrintPolicy>
clone(
534 return std::make_unique<LevelOutputDecorator>(
m_wrappee->clone(name));
544 static const char*
const buffer[] = {
"VERBOSE",
"DEBUG",
"INFO",
545 "WARNING",
"ERROR",
"FATAL"};
568 (*m_out) <<
input << std::endl;
571 "Previous debug message exceeds the "
572 "ACTS_LOG_FAILURE_THRESHOLD=" +
574 " configuration, bailing out. See "
575 "https://acts.readthedocs.io/en/latest/core/"
576 "logging.html#logging-thresholds");
587 throw std::runtime_error{
588 "Default print policy doesn't have a name. Is there no named output in "
589 "the decorator chain?"};
595 std::unique_ptr<OutputPrintPolicy>
clone(
598 return std::make_unique<DefaultPrintPolicy>(
m_out);
619 Logger(std::unique_ptr<Logging::OutputPrintPolicy> pPrint,
620 std::unique_ptr<Logging::OutputFilterPolicy> pFilter)
666 const std::optional<std::string>& _name = std::nullopt,
667 const std::optional<Logging::Level>& _level = std::nullopt)
const {
668 return std::make_unique<Logger>(
678 return clone(std::nullopt, _level);
687 std::optional<Logging::Level> _level = std::nullopt)
const {
718 std::ostream* log_stream = &std::cout);