#include "logging.h" #include #include #include "Entry.h" using namespace logging; using std::string; using std::vector; using std::shared_ptr; using std::lock_guard; std::mutex& getLogMutex() { static std::mutex mutex; return mutex; } vector>& getSinks() { static vector> sinks; return sinks; } void logging::addSink(shared_ptr sink) { lock_guard lock(getLogMutex()); getSinks().push_back(sink); } void logging::log(Level level, const string& message) { lock_guard lock(getLogMutex()); const Entry entry = Entry(level, message); for (auto& sink : getSinks()) { sink->receive(entry); } }