" -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"
"\n", PV_BIN_NAME);
}
vector<string> open_files;
bool restore_sessions = true;
bool do_scan = true;
- bool do_logging = true;
Application a(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);
if (c == -1)
break;
case 'c':
restore_sessions = false;
break;
-
- case 's':
- do_logging = false;
- break;
}
}
argc -= optind;
pv::GlobalSettings settings;
settings.set_defaults_where_needed();
- if (do_logging)
- pv::logging.init();
+ pv::logging.init();
// Initialise libsigrok
context = sigrok::Context::create();
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);
- 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;
#ifdef ENABLE_DECODE
- 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);
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
+ srd_log_callback_get(&prev_srd_log_cb, &prev_srd_log_cb_data);
srd_log_callback_set(log_srd, nullptr);
#endif
int Logging::log_sr(void *cb_data, int loglevel, const char *format, va_list args)
{
+ va_list args2;
+
(void)cb_data;
- (void)loglevel;
+
+ 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);
#ifdef ENABLE_DECODE
int Logging::log_srd(void *cb_data, int loglevel, const char *format, va_list args)
{
+ va_list args2;
+
(void)cb_data;
- (void)loglevel;
+
+ 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);