20 #ifndef OPM_LOGGER_HPP
21 #define OPM_LOGGER_HPP
35 void addMessage(int64_t messageType ,
const std::string& message)
const;
39 void addMessageType( int64_t messageType ,
const std::string& prefix);
42 void addBackend(
const std::string& name , std::shared_ptr<LogBackend> backend);
46 template <
class BackendType>
47 std::shared_ptr<BackendType>
getBackend(
const std::string& name)
const {
48 auto pair = m_backends.find( name );
49 if (pair == m_backends.end())
50 throw std::invalid_argument(
"Invalid backend name: " + name);
52 return std::static_pointer_cast<BackendType>(m_backends.find(name)->second);
55 template <
class BackendType>
56 std::shared_ptr<BackendType>
popBackend(
const std::string& name) {
57 auto pair = m_backends.find( name );
58 if (pair == m_backends.end())
59 throw std::invalid_argument(
"Invalid backend name: " + name);
61 std::shared_ptr<LogBackend> backend = (*pair).second;
63 return std::static_pointer_cast<BackendType>(backend);
69 void updateGlobalMask( int64_t mask );
73 int64_t m_enabledTypes;
74 std::map<std::string , std::shared_ptr<LogBackend> > m_backends;
bool removeBackend(const std::string &name)
std::shared_ptr< BackendType > getBackend(const std::string &name) const
Definition: Logger.hpp:47
std::shared_ptr< BackendType > popBackend(const std::string &name)
Definition: Logger.hpp:56
Definition: Logger.hpp:32
bool hasBackend(const std::string &name)
static bool enabledDefaultMessageType(int64_t messageType)
void addMessageType(int64_t messageType, const std::string &prefix)
int64_t enabledMessageTypes() const
void addMessage(int64_t messageType, const std::string &message) const
void addBackend(const std::string &name, std::shared_ptr< LogBackend > backend)
bool enabledMessageType(int64_t messageType) const