Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:35:24

0001 #ifndef CondCore_CondDB_CoralMsgReporter_h
0002 #define CondCore_CondDB_CoralMsgReporter_h
0003 
0004 //#include "CondCore/CondDB/interface/Logger.h"
0005 
0006 #include <mutex>
0007 #include <set>
0008 #include "CoralBase/MessageStream.h"
0009 
0010 namespace cond {
0011 
0012   namespace persistency {
0013 
0014     class Logger;
0015 
0016     class MsgDispatcher {
0017     public:
0018       MsgDispatcher() = delete;
0019       explicit MsgDispatcher(Logger& logger);
0020       virtual ~MsgDispatcher() {}
0021 
0022       void unsubscribe();
0023 
0024       bool hasRecipient();
0025       Logger& recipient();
0026 
0027     private:
0028       Logger* m_recipient = nullptr;
0029     };
0030 
0031     class CoralMsgReporter : public coral::IMsgReporter {
0032     public:
0033       /// Default constructor
0034       CoralMsgReporter();
0035 
0036       /// Destructor
0037       ~CoralMsgReporter() override {}
0038 
0039       /// Release reference to reporter
0040       void release() override { delete this; }
0041 
0042       /// Access output level
0043       coral::MsgLevel outputLevel() const override;
0044 
0045       /// Modify output level
0046       void setOutputLevel(coral::MsgLevel lvl) override;
0047 
0048       /// Report a message
0049       void report(int lvl, const std::string& src, const std::string& msg) override;
0050 
0051       void subscribe(Logger& logger);
0052 
0053     private:
0054       // the destination of the streams...
0055       std::shared_ptr<MsgDispatcher> m_dispatcher;
0056 
0057       /// The current message level threshold
0058       coral::MsgLevel m_level;
0059 
0060       /// Use a different format output
0061       size_t m_format;
0062 
0063       /// The mutex lock
0064       std::recursive_mutex m_mutex;
0065     };
0066 
0067   }  // namespace persistency
0068 
0069 }  // namespace cond
0070 #endif