Changeset View
Changeset View
Standalone View
Standalone View
src/logging.h
Show First 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | public: | ||||
~Logger(); | ~Logger(); | ||||
/** Send a string to the log output */ | /** Send a string to the log output */ | ||||
void LogPrintStr(const std::string &str); | void LogPrintStr(const std::string &str); | ||||
/** Returns whether logs will be written to any output */ | /** Returns whether logs will be written to any output */ | ||||
bool Enabled() const { | bool Enabled() const { | ||||
LockGuard scoped_lock(m_cs); | StdLockGuard scoped_lock(m_cs); | ||||
return m_buffering || m_print_to_console || m_print_to_file || | return m_buffering || m_print_to_console || m_print_to_file || | ||||
!m_print_callbacks.empty(); | !m_print_callbacks.empty(); | ||||
} | } | ||||
/** Connect a slot to the print signal and return the connection */ | /** Connect a slot to the print signal and return the connection */ | ||||
std::list<std::function<void(const std::string &)>>::iterator | std::list<std::function<void(const std::string &)>>::iterator | ||||
PushBackCallback(std::function<void(const std::string &)> fun) { | PushBackCallback(std::function<void(const std::string &)> fun) { | ||||
LockGuard scoped_lock(m_cs); | StdLockGuard scoped_lock(m_cs); | ||||
m_print_callbacks.push_back(std::move(fun)); | m_print_callbacks.push_back(std::move(fun)); | ||||
return --m_print_callbacks.end(); | return --m_print_callbacks.end(); | ||||
} | } | ||||
/** Delete a connection */ | /** Delete a connection */ | ||||
void DeleteCallback( | void DeleteCallback( | ||||
std::list<std::function<void(const std::string &)>>::iterator it) { | std::list<std::function<void(const std::string &)>>::iterator it) { | ||||
LockGuard scoped_lock(m_cs); | StdLockGuard scoped_lock(m_cs); | ||||
m_print_callbacks.erase(it); | m_print_callbacks.erase(it); | ||||
} | } | ||||
/** Start logging (and flush all buffered messages) */ | /** Start logging (and flush all buffered messages) */ | ||||
bool StartLogging(); | bool StartLogging(); | ||||
/** Only for testing */ | /** Only for testing */ | ||||
void DisconnectTestLogger(); | void DisconnectTestLogger(); | ||||
▲ Show 20 Lines • Show All 72 Lines • Show Last 20 Lines |