aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2021-12-05 20:51:49 +0000
committerJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2021-12-06 18:51:42 +0000
commit290234f3f5c9114952d80906503bddaec5ad539f (patch)
treed6958465d8c34adfb0c6c3bd1bcadb91fe494208
parent1a65cf05339b3879c2be69b115912094d0e4d2d7 (diff)
Extcap: Improve the log handler logic
If we have a log file write everything to the file, to provide a complete picture in the log. Debug information cannot be written to the parent process when running in child mode.
-rw-r--r--extcap/extcap-base.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/extcap/extcap-base.c b/extcap/extcap-base.c
index 5df8977084..2ea4ad8f0a 100644
--- a/extcap/extcap-base.c
+++ b/extcap/extcap-base.c
@@ -107,18 +107,26 @@ void extcap_base_set_running_with(extcap_parameters * extcap, const char *fmt, .
va_end(ap);
}
+/* This is only active with a debug log file. */
static void extcap_custom_log(const char *domain, enum ws_log_level level,
ws_log_time_t timestamp,
const char *file, int line, const char *func,
const char *user_format, va_list user_ap,
void *user_data _U_)
{
- if (level <= LOG_LEVEL_DEBUG) {
- if (!custom_log)
- return;
- ws_log_file_writer(custom_log, domain, level, timestamp, file, line, func, user_format, user_ap);
- } else {
- ws_log_console_writer(domain, level, timestamp, file, line, func, user_format, user_ap);
+ if (!ws_log_msg_is_active(domain, level)) {
+ return;
+ }
+ if (custom_log) {
+ va_list user_ap_copy;
+
+ G_VA_COPY(user_ap_copy, user_ap);
+ ws_log_file_writer(custom_log, domain, level, timestamp, file, line, func, user_format, user_ap_copy);
+ va_end(user_ap_copy);
+ }
+ if (level > LOG_LEVEL_INFO) {
+ /* This writes errors and warnings to the parent process. */
+ vfprintf(stderr, user_format, user_ap);
}
}