#ifndef INVENTORY_LOG_HH_ #define INVENTORY_LOG_HH_ #include "logstream.hh" #include "cxx-semantics.hh" #include #define LIBINVDB_LOG(lvl, str) Log::instance()(lvl, "[" + \ std::string(__func__) + " @ " + std::string(__FILE__) + ":" + \ std::to_string(__LINE__) + "] " + std::string(str)) namespace inventory { class Log : public semantics::singleton { public: Log() : m_loglevel(Loglevel::WARNING) {} void set_stream(std::shared_ptr stream) { mp_logstream = stream; } void set_loglevel(Loglevel lvl) { m_loglevel = lvl; } void operator()(Loglevel lvl, const std::string &msg) { if ((int)(lvl) <= (int)(m_loglevel)) (*mp_logstream)(lvl, msg); } private: static std::shared_ptr mp_logstream; Loglevel m_loglevel; }; } #endif