Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-26 08:22:03

0001 /** TRACCC library, part of the ACTS project (R&D line)
0002  *
0003  * (c) 2025 CERN for the benefit of the ACTS project
0004  *
0005  * Mozilla Public License Version 2.0
0006  */
0007 
0008 // Local include(s).
0009 #include "traccc/utils/logging.hpp"
0010 
0011 // System include(s).
0012 #include <functional>
0013 #include <iostream>
0014 #include <sstream>
0015 #include <stdexcept>
0016 
0017 namespace {
0018 
0019 /// Decorator to split the output into separate lines
0020 class split_output_decorator final : public traccc::Logging::OutputDecorator {
0021  public:
0022   explicit split_output_decorator(
0023       std::unique_ptr<traccc::Logging::OutputPrintPolicy> print_policy)
0024       : traccc::Logging::OutputDecorator(std::move(print_policy)) {}
0025 
0026   void flush(const traccc::Logging::Level& lvl,
0027              const std::string& input) override {
0028     // Split the message into separate lines.
0029     std::istringstream iss(input);
0030     for (std::string line; std::getline(iss, line);) {
0031       m_wrappee->flush(lvl, line);
0032     }
0033   }
0034 
0035   std::unique_ptr<OutputPrintPolicy> clone(
0036       const std::string& name) const override {
0037     return std::make_unique<split_output_decorator>(m_wrappee->clone(name));
0038   }
0039 };
0040 
0041 }  // namespace
0042 
0043 namespace traccc {
0044 
0045 std::unique_ptr<const Logger> getDefaultLogger(const std::string& name,
0046                                                const Logging::Level& lvl,
0047                                                std::ostream* log_stream) {
0048   return std::make_unique<const Logger>(
0049       std::make_unique<::split_output_decorator>(
0050           std::make_unique<Logging::LevelOutputDecorator>(
0051               std::make_unique<Logging::NamedOutputDecorator>(
0052                   std::make_unique<Logging::TimedOutputDecorator>(
0053                       std::make_unique<Logging::DefaultPrintPolicy>(
0054                           log_stream)),
0055                   name, 30))),
0056       std::make_unique<Logging::DefaultFilterPolicy>(lvl));
0057 }
0058 
0059 const Logger& getDummyLogger() {
0060   return ::Acts::getDummyLogger();
0061 }
0062 
0063 }  // namespace traccc