File indexing completed on 2026-07-26 08:22:13
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "traccc/options/logging.hpp"
0010
0011 #include <Acts/Utilities/Logger.hpp>
0012
0013 #include "traccc/examples/utils/printable.hpp"
0014
0015
0016 #include <format>
0017 #include <iostream>
0018 #include <sstream>
0019 #include <stdexcept>
0020
0021 namespace {
0022 class verbosity_counter : public boost::program_options::typed_value<int> {
0023 public:
0024 verbosity_counter(int* store)
0025 : boost::program_options::typed_value<int>(store) {
0026 default_value(0);
0027 zero_tokens();
0028 }
0029
0030 virtual ~verbosity_counter() = default;
0031
0032 virtual void xparse(boost::any& store,
0033 const std::vector<std::string>&) const {
0034 store = boost::any(++m_value);
0035 }
0036
0037 private:
0038 mutable int m_value{0};
0039 };
0040 }
0041
0042 namespace traccc::opts {
0043
0044 logging::logging() : interface("Logging Options") {
0045 m_desc.add_options()("verbose,v", new verbosity_counter(&m_verbosity_decr),
0046 "Increase verbosity (can be specified multiple times)")(
0047 "quiet,q", new verbosity_counter(&m_verbosity_incr),
0048 "Decrease verbosity (can be specified multiple times)");
0049 }
0050
0051 logging::operator traccc::Logging::Level() const {
0052 int verb = m_verbosity_incr - m_verbosity_decr;
0053
0054 if (verb <= -2) {
0055 return traccc::Logging::Level::VERBOSE;
0056 } else if (verb == -1) {
0057 return traccc::Logging::Level::DEBUG;
0058 } else if (verb == 0) {
0059 return traccc::Logging::Level::INFO;
0060 } else if (verb == 1) {
0061 return traccc::Logging::Level::WARNING;
0062 } else if (verb == 2) {
0063 return traccc::Logging::Level::ERROR;
0064 } else {
0065 return traccc::Logging::Level::FATAL;
0066 }
0067 }
0068
0069 std::unique_ptr<configuration_printable> logging::as_printable() const {
0070 auto cat = std::make_unique<configuration_category>(m_description);
0071
0072 traccc::Logging::Level lvl(*this);
0073
0074 std::string verbosity_string{Acts::Logging::levelName(lvl)};
0075
0076 cat->add_child(std::make_unique<configuration_kv_pair>("Verbosity level",
0077 verbosity_string));
0078
0079 return cat;
0080 }
0081
0082 }