File indexing completed on 2025-11-05 09:45:09
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #ifndef K4ACTSTRACKING_ACTSGAUDILOGGER_H
0020 #define K4ACTSTRACKING_ACTSGAUDILOGGER_H
0021
0022 #include <Acts/Utilities/Logger.hpp>
0023
0024 #include <GaudiKernel/CommonMessaging.h>
0025 #include <GaudiKernel/IMessageSvc.h>
0026 #include <GaudiKernel/MsgStream.h>
0027
0028 #include <memory>
0029 #include <optional>
0030 #include <string>
0031
0032
0033 class ActsGaudiPrintPolicy final : public Acts::Logging::OutputPrintPolicy {
0034 public:
0035 ActsGaudiPrintPolicy(IMessageSvc* svc, std::shared_ptr<MsgStream> msg, const std::string& name)
0036 : m_svc(svc), m_msg(msg), m_name(name) {}
0037
0038 void flush(const Acts::Logging::Level& lvl, const std::string& input) override;
0039
0040 const std::string& name() const override { return m_name; }
0041
0042 std::unique_ptr<Acts::Logging::OutputPrintPolicy> clone(const std::string& name) const override;
0043
0044 private:
0045 IMessageSvc* m_svc{nullptr};
0046 std::shared_ptr<MsgStream> m_msg{nullptr};
0047 std::string m_name{};
0048 };
0049
0050
0051 class ActsGaudiFilterPolicy final : public Acts::Logging::OutputFilterPolicy {
0052 public:
0053 ActsGaudiFilterPolicy(std::shared_ptr<MsgStream> msg) : m_msg(msg) {}
0054
0055 bool doPrint(const Acts::Logging::Level& lvl) const override;
0056
0057 Acts::Logging::Level level() const override;
0058
0059 std::unique_ptr<Acts::Logging::OutputFilterPolicy> clone(Acts::Logging::Level lvl) const override;
0060
0061 private:
0062 std::shared_ptr<MsgStream> m_msg{nullptr};
0063 };
0064
0065
0066
0067 std::unique_ptr<const Acts::Logger> makeActsGaudiLogger(const CommonMessagingBase* parent,
0068 std::optional<std::string> name = std::nullopt);
0069
0070
0071
0072 std::unique_ptr<const Acts::Logger> makeActsGaudiLogger(IMessageSvc* svc, const std::string& name, int level,
0073 std::optional<std::string> parentName = std::nullopt);
0074
0075
0076 inline std::unique_ptr<const Acts::Logger> makeActsGaudiLogger(const CommonMessagingBase* parent,
0077 const std::string& name) {
0078 return makeActsGaudiLogger(parent, std::optional<std::string>{name});
0079 }
0080
0081 #endif