X-Git-Url: http://git.code-monkey.de/?p=pulseview.git;a=blobdiff_plain;f=pv%2Flogging.cpp;h=b747ab5452c5f4ee7b2aef633a65fc1e02986f47;hp=83577af200cee7afff6b0cb384a485d63883256a;hb=16ae9b03b8456d14bc64ce30c8c9a0093eebab9d;hpb=4b9234088f56c5b0e22f8aa5b18ef346285a7fc6 diff --git a/pv/logging.cpp b/pv/logging.cpp index 83577af..b747ab5 100644 --- a/pv/logging.cpp +++ b/pv/logging.cpp @@ -20,6 +20,8 @@ #include "logging.hpp" #include "globalsettings.hpp" +#include + #ifdef ENABLE_DECODE #include /* First, so we avoid a _POSIX_C_SOURCE warning. */ #endif @@ -28,6 +30,8 @@ #include +using std::cout; +using std::endl; using std::lock_guard; namespace pv { @@ -48,13 +52,15 @@ static void *prev_srd_log_cb_data; Logging::~Logging() { qInstallMessageHandler(nullptr); - sr_log_callback_set(prev_sr_log_cb, prev_sr_log_cb_data); - prev_sr_log_cb = NULL; - prev_sr_log_cb_data = NULL; + if (prev_sr_log_cb) + sr_log_callback_set(prev_sr_log_cb, prev_sr_log_cb_data); + prev_sr_log_cb = nullptr; + prev_sr_log_cb_data = nullptr; #ifdef ENABLE_DECODE - srd_log_callback_set(prev_srd_log_cb, prev_srd_log_cb_data); - prev_srd_log_cb = NULL; - prev_srd_log_cb_data = NULL; + if (prev_srd_log_cb) + srd_log_callback_set(prev_srd_log_cb, prev_srd_log_cb_data); + prev_srd_log_cb = nullptr; + prev_srd_log_cb_data = nullptr; #endif GlobalSettings::remove_change_handler(this); @@ -120,10 +126,10 @@ void Logging::log(const QString &text, int source) switch (source) { case LogSource_pv: - s = QString("pv: ") + text; // black is default color + s = QString("pv: %1").arg(text); break; case LogSource_sr: - s = QString("sr: %1").arg(text); + s = QString("sr: %1").arg(text); break; case LogSource_srd: s = QString("srd: %1").arg(text); @@ -148,6 +154,8 @@ void Logging::log_pv(QtMsgType type, const QMessageLogContext &context, const QS (void)context; logging.log(msg, LogSource_pv); + + cout << msg.toUtf8().data() << endl; } int Logging::log_sr(void *cb_data, int loglevel, const char *format, va_list args)