Query the sr and srd libraries' current log routines before registering
PV's own log callback which queues messages in an internal buffer. This
allows duplication of messages to the internal buffer _and_ stdout, and
thus obsoletes the -s option.
" -i, --input-file Load input from file\n"
" -I, --input-format Input format\n"
" -c, --clean Don't restore previous sessions on startup\n"
" -i, --input-file Load input from file\n"
" -I, --input-format Input format\n"
" -c, --clean Don't restore previous sessions on startup\n"
- " -s, --log-to-stdout Don't use logging, output to stdout instead\n"
vector<string> open_files;
bool restore_sessions = true;
bool do_scan = true;
vector<string> open_files;
bool restore_sessions = true;
bool do_scan = true;
- bool do_logging = true;
Application a(argc, argv);
Application a(argc, argv);
};
const int c = getopt_long(argc, argv,
};
const int c = getopt_long(argc, argv,
- "h?VDcsl:d:i:I:", long_options, nullptr);
+ "h?VDcl:d:i:I:", long_options, nullptr);
case 'c':
restore_sessions = false;
break;
case 'c':
restore_sessions = false;
break;
-
- case 's':
- do_logging = false;
- break;
pv::GlobalSettings settings;
settings.set_defaults_where_needed();
pv::GlobalSettings settings;
settings.set_defaults_where_needed();
- if (do_logging)
- pv::logging.init();
// Initialise libsigrok
context = sigrok::Context::create();
// Initialise libsigrok
context = sigrok::Context::create();
const int Logging::MIN_BUFFER_SIZE = 10;
const int Logging::MAX_BUFFER_SIZE = 50000;
const int Logging::MIN_BUFFER_SIZE = 10;
const int Logging::MAX_BUFFER_SIZE = 50000;
+static sr_log_callback prev_sr_log_cb;
+static void *prev_sr_log_cb_data;
+
+#ifdef ENABLE_DECODE
+static srd_log_callback prev_srd_log_cb;
+static void *prev_srd_log_cb_data;
+#endif
+
Logging::~Logging()
{
qInstallMessageHandler(nullptr);
Logging::~Logging()
{
qInstallMessageHandler(nullptr);
- sr_log_callback_set_default();
+ sr_log_callback_set(prev_sr_log_cb, prev_sr_log_cb_data);
+ prev_sr_log_cb = NULL;
+ prev_sr_log_cb_data = NULL;
- srd_log_callback_set_default();
+ srd_log_callback_set(prev_srd_log_cb, prev_srd_log_cb_data);
+ prev_srd_log_cb = NULL;
+ prev_srd_log_cb_data = NULL;
#endif
GlobalSettings::remove_change_handler(this);
#endif
GlobalSettings::remove_change_handler(this);
buffer_.reserve(buffer_size_);
qInstallMessageHandler(log_pv);
buffer_.reserve(buffer_size_);
qInstallMessageHandler(log_pv);
+ sr_log_callback_get(&prev_sr_log_cb, &prev_sr_log_cb_data);
sr_log_callback_set(log_sr, nullptr);
#ifdef ENABLE_DECODE
sr_log_callback_set(log_sr, nullptr);
#ifdef ENABLE_DECODE
+ srd_log_callback_get(&prev_srd_log_cb, &prev_srd_log_cb_data);
srd_log_callback_set(log_srd, nullptr);
#endif
srd_log_callback_set(log_srd, nullptr);
#endif
int Logging::log_sr(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)
{
+
+ va_copy(args2, args);
+ if (prev_sr_log_cb)
+ prev_sr_log_cb(prev_sr_log_cb_data, loglevel, format, args2);
+ va_end(args2);
char *text = g_strdup_vprintf(format, args);
logging.log(QString::fromUtf8(text), LogSource_sr);
char *text = g_strdup_vprintf(format, args);
logging.log(QString::fromUtf8(text), LogSource_sr);
#ifdef ENABLE_DECODE
int Logging::log_srd(void *cb_data, int loglevel, const char *format, va_list args)
{
#ifdef ENABLE_DECODE
int Logging::log_srd(void *cb_data, int loglevel, const char *format, va_list args)
{
+
+ va_copy(args2, args);
+ if (prev_srd_log_cb)
+ prev_srd_log_cb(prev_srd_log_cb_data, loglevel, format, args2);
+ va_end(args2);
char *text = g_strdup_vprintf(format, args);
logging.log(QString::fromUtf8(text), LogSource_srd);
char *text = g_strdup_vprintf(format, args);
logging.log(QString::fromUtf8(text), LogSource_srd);