X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Flogging.cpp;h=ab0594c342e5b58a0d7bf63ec91693640adbba50;hp=b0355168dbb640438db4f62e1b6661e9a2e3826d;hb=ff046cb6c42a2382ee281e83955b7ae44030b42e;hpb=d1c343c8dcbde4c3c9c4d85c62457d3bcbf5bde6 diff --git a/pv/logging.cpp b/pv/logging.cpp index b0355168..ab0594c3 100644 --- a/pv/logging.cpp +++ b/pv/logging.cpp @@ -28,6 +28,8 @@ #include +using std::lock_guard; + namespace pv { Logging logging; @@ -36,7 +38,7 @@ const int Logging::MAX_BUFFER_SIZE = 50000; Logging::~Logging() { - qInstallMessageHandler(0); + qInstallMessageHandler(nullptr); sr_log_callback_set_default(); #ifdef ENABLE_DECODE srd_log_callback_set_default(); @@ -55,9 +57,9 @@ void Logging::init() buffer_.reserve(buffer_size_); qInstallMessageHandler(log_pv); - sr_log_callback_set(log_libsigrok, nullptr); + sr_log_callback_set(log_sr, nullptr); #ifdef ENABLE_DECODE - srd_log_callback_set(log_libsrd, nullptr); + srd_log_callback_set(log_srd, nullptr); #endif GlobalSettings::add_change_handler(this); @@ -72,7 +74,9 @@ int Logging::get_log_level() const void Logging::set_log_level(int level) { sr_log_loglevel_set(level); +#ifdef ENABLE_DECODE srd_log_loglevel_set(level); +#endif } QString Logging::get_log() const @@ -82,6 +86,8 @@ QString Logging::get_log() const void Logging::log(const QString &text, int source) { + lock_guard log_lock(log_mutex_); + if (buffer_.size() >= buffer_size_) buffer_.removeFirst(); @@ -129,7 +135,7 @@ void Logging::log_pv(QtMsgType type, const QMessageLogContext &context, const QS logging.log(msg, LogSource_pv); } -int Logging::log_libsigrok(void *cb_data, int loglevel, const char *format, va_list args) +int Logging::log_sr(void *cb_data, int loglevel, const char *format, va_list args) { (void)cb_data; (void)loglevel; @@ -142,7 +148,7 @@ int Logging::log_libsigrok(void *cb_data, int loglevel, const char *format, va_l } #ifdef ENABLE_DECODE -int Logging::log_libsrd(void *cb_data, int loglevel, const char *format, va_list args) +int Logging::log_srd(void *cb_data, int loglevel, const char *format, va_list args) { (void)cb_data; (void)loglevel;