forked from osmocom/wireshark
wslog: Use NULL for empty/default domain
This commit is contained in:
parent
49ec11f5aa
commit
051a74378d
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#define WS_LOG_DOMAIN "packet-http2"
|
||||
|
||||
#include <epan/packet.h>
|
||||
#include <epan/expert.h>
|
||||
|
|
|
@ -944,7 +944,7 @@ void MainWindow::pipeTimeout() {
|
|||
|
||||
/* And call the real handler */
|
||||
if (!pipe_input_cb_(pipe_source_, pipe_user_data_)) {
|
||||
ws_log(LOG_DOMAIN_DEFAULT, LOG_LEVEL_DEBUG, "pipe_timer_cb: input pipe closed, iterations: %u", iterations);
|
||||
ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_DEBUG, "pipe_timer_cb: input pipe closed, iterations: %u", iterations);
|
||||
/* pipe closed, return false so that the old timer is not run again */
|
||||
delete pipe_timer_;
|
||||
return;
|
||||
|
|
|
@ -12,25 +12,28 @@
|
|||
#define __WS_LOG_DOMAINS_H__
|
||||
|
||||
/*
|
||||
* Which log domain to use is a matter of policy. Any string is valid (names
|
||||
* using parenthesis should be avoided). There are no hard rules but using a
|
||||
* non-default pre-defined log domain is a good rule of thumb.
|
||||
* Which log domain to use is a matter of policy. Any string is valid.
|
||||
* There are no hard rules but using a pre-defined log domain is a good
|
||||
* rule of thumb (there is no pre-defined domain below for dissectors
|
||||
* though).
|
||||
*/
|
||||
|
||||
/* Null domain */
|
||||
#define LOG_DOMAIN_NONE "(notset)"
|
||||
/* Default domain */
|
||||
#define LOG_DOMAIN_DEFAULT "()"
|
||||
/* Main execution domain (wireshark, tshark, etc) */
|
||||
/* Main execution domain (wireshark, tshark, etc) */
|
||||
#define LOG_DOMAIN_MAIN "Main"
|
||||
/* Capture domain (except for capture child, see below) */
|
||||
|
||||
/* Capture domain (except for capture child, see below) */
|
||||
#define LOG_DOMAIN_CAPTURE "Capture"
|
||||
/* Capture child domain (the capture child might also contain
|
||||
* file domain messages!) */
|
||||
|
||||
/* Capture child domain (the capture child might also contain
|
||||
* file domain messages!) */
|
||||
#define LOG_DOMAIN_CAPCHILD "Capchild"
|
||||
|
||||
#define LOG_DOMAIN_WIRETAP "Wiretap"
|
||||
|
||||
#define LOG_DOMAIN_EPAN "Epan"
|
||||
|
||||
#define LOG_DOMAIN_WSUTIL "WSUtil"
|
||||
|
||||
#define LOG_DOMAIN_QTUI "GUI"
|
||||
|
||||
/*
|
||||
|
|
|
@ -44,9 +44,10 @@
|
|||
* domain filter. */
|
||||
#define ENV_VAR_NOISY "WIRESHARK_LOG_NOISY"
|
||||
|
||||
|
||||
#define DEFAULT_LOG_LEVEL LOG_LEVEL_MESSAGE
|
||||
|
||||
#define DOMAIN_NOTSET(domain) ((domain) == NULL || *(domain) == '\0')
|
||||
|
||||
|
||||
static enum ws_log_level current_log_level = LOG_LEVEL_NONE;
|
||||
|
||||
|
@ -145,6 +146,9 @@ gboolean ws_log_level_is_active(enum ws_log_level level)
|
|||
|
||||
static inline gboolean filter_contains(GPtrArray *filter, const char *domain)
|
||||
{
|
||||
if (filter == NULL || DOMAIN_NOTSET(domain))
|
||||
return FALSE;
|
||||
|
||||
for (guint i = 0; i < filter->len; i++) {
|
||||
if (g_ascii_strcasecmp(filter->pdata[i], domain) == 0) {
|
||||
return TRUE;
|
||||
|
@ -156,12 +160,11 @@ static inline gboolean filter_contains(GPtrArray *filter, const char *domain)
|
|||
|
||||
gboolean ws_log_domain_is_active(const char *domain)
|
||||
{
|
||||
if (domain_filter == NULL)
|
||||
return TRUE;
|
||||
|
||||
/* We don't filter the default domain. Default means undefined, pretty much
|
||||
* every permanent call to ws_log should be using a chosen domain. */
|
||||
if (strcmp(domain, LOG_DOMAIN_DEFAULT) == 0)
|
||||
/*
|
||||
* We don't filter the undefined domain, pretty much every permanent
|
||||
* call to ws_log should be using a set domain.
|
||||
*/
|
||||
if (DOMAIN_NOTSET(domain))
|
||||
return TRUE;
|
||||
|
||||
if (filter_contains(domain_filter, domain))
|
||||
|
@ -515,12 +518,10 @@ static void log_write_do_work(FILE *fp, gboolean use_color, const char *timestam
|
|||
fputc(' ', fp);
|
||||
}
|
||||
|
||||
if (strcmp(domain, LOG_DOMAIN_DEFAULT) != 0) {
|
||||
fprintf(fp, "[%s-%s] ", domain, level_str);
|
||||
}
|
||||
else {
|
||||
if (DOMAIN_NOTSET(domain))
|
||||
fprintf(fp, "[%s] ", level_str);
|
||||
}
|
||||
else
|
||||
fprintf(fp, "[%s-%s] ", domain, level_str);
|
||||
|
||||
if (doextra) {
|
||||
if (file && line >= 0) {
|
||||
|
@ -581,8 +582,6 @@ static void log_write_dispatch(const char *domain, enum ws_log_level level,
|
|||
void ws_logv(const char *domain, enum ws_log_level level,
|
||||
const char *format, va_list ap)
|
||||
{
|
||||
if (domain == NULL || domain[0] == '\0')
|
||||
domain = LOG_DOMAIN_DEFAULT;
|
||||
|
||||
if (log_drop_message(domain, level))
|
||||
return;
|
||||
|
@ -595,9 +594,6 @@ void ws_logv_full(const char *domain, enum ws_log_level level,
|
|||
const char *file, int line, const char *func,
|
||||
const char *format, va_list ap)
|
||||
{
|
||||
if (domain == NULL || domain[0] == '\0')
|
||||
domain = LOG_DOMAIN_DEFAULT;
|
||||
|
||||
if (log_drop_message(domain, level))
|
||||
return;
|
||||
|
||||
|
@ -610,9 +606,6 @@ void ws_log(const char *domain, enum ws_log_level level,
|
|||
{
|
||||
va_list ap;
|
||||
|
||||
if (domain == NULL || domain[0] == '\0')
|
||||
domain = LOG_DOMAIN_DEFAULT;
|
||||
|
||||
if (log_drop_message(domain, level))
|
||||
return;
|
||||
|
||||
|
@ -628,9 +621,6 @@ void ws_log_full(const char *domain, enum ws_log_level level,
|
|||
{
|
||||
va_list ap;
|
||||
|
||||
if (domain == NULL || domain[0] == '\0')
|
||||
domain = LOG_DOMAIN_DEFAULT;
|
||||
|
||||
if (log_drop_message(domain, level))
|
||||
return;
|
||||
|
||||
|
|
|
@ -15,10 +15,11 @@
|
|||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifndef WS_LOG_DOMAIN
|
||||
/* Should this be an error instead? */
|
||||
#define WS_LOG_DOMAIN LOG_DOMAIN_DEFAULT
|
||||
#endif
|
||||
/*
|
||||
* Define the macro WS_LOG_DOMAIN *before* including this header,
|
||||
* for example:
|
||||
* #define WS_LOG_DOMAIN LOG_DOMAIN_MAIN
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -196,8 +197,13 @@ void ws_logv_full(const char *domain, enum ws_log_level level,
|
|||
const char *format, va_list ap);
|
||||
|
||||
|
||||
#ifdef WS_LOG_DOMAIN
|
||||
#define _LOG_FULL(level, ...) ws_log_full(WS_LOG_DOMAIN, level, \
|
||||
__FILE__, __LINE__, G_STRFUNC, __VA_ARGS__)
|
||||
#else
|
||||
#define _LOG_FULL(level, ...) ws_log_full(NULL, level, \
|
||||
__FILE__, __LINE__, G_STRFUNC, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
/** Logs with "error" level.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue