forked from osmocom/wireshark
wslog: Be more obvious in the log that the domain is unset
Currently we are not filtering the unset (NULL) domain, on the assumption that every log call should belong to a defined domain. However there are still many places in the codebase where this isn't true and the fact that the null/default domain name is omitted from the output and never filtered is probably surprising and user-unfriendly. Users might understandably assume the filtering is buggy. Give an indication, such as (none)-MESSAGE, to make this more obvious.
This commit is contained in:
parent
39315979c6
commit
dddb33e398
|
@ -94,7 +94,7 @@ const char *ws_log_level_to_string(enum ws_log_level level)
|
||||||
{
|
{
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case LOG_LEVEL_NONE:
|
case LOG_LEVEL_NONE:
|
||||||
return "(none)";
|
return "(zero)";
|
||||||
case LOG_LEVEL_ERROR:
|
case LOG_LEVEL_ERROR:
|
||||||
return "ERROR";
|
return "ERROR";
|
||||||
case LOG_LEVEL_CRITICAL:
|
case LOG_LEVEL_CRITICAL:
|
||||||
|
@ -139,6 +139,13 @@ static enum ws_log_level string_to_log_level(const char *str_level)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
WS_RETNONNULL
|
||||||
|
static inline const char *domain_to_string(const char *domain)
|
||||||
|
{
|
||||||
|
return (domain == NULL) ? "(none)" : domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline gboolean log_level_is_active(enum ws_log_level level)
|
static inline gboolean log_level_is_active(enum ws_log_level level)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -536,6 +543,7 @@ static void log_write_do_work(FILE *fp, gboolean use_color, const char *timestam
|
||||||
const char *file, int line, const char *func,
|
const char *file, int line, const char *func,
|
||||||
const char *user_format, va_list user_ap)
|
const char *user_format, va_list user_ap)
|
||||||
{
|
{
|
||||||
|
const char *domain_str = domain_to_string(domain);
|
||||||
const char *level_str = ws_log_level_to_string(level);
|
const char *level_str = ws_log_level_to_string(level);
|
||||||
gboolean doextra = (level != LOG_LEVEL_MESSAGE);
|
gboolean doextra = (level != LOG_LEVEL_MESSAGE);
|
||||||
|
|
||||||
|
@ -552,10 +560,7 @@ static void log_write_do_work(FILE *fp, gboolean use_color, const char *timestam
|
||||||
fputc(' ', fp);
|
fputc(' ', fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DOMAIN_NOTSET(domain))
|
fprintf(fp, "[%s-%s] ", domain_str, level_str);
|
||||||
fprintf(fp, "[%s] ", level_str);
|
|
||||||
else
|
|
||||||
fprintf(fp, "[%s-%s] ", domain, level_str);
|
|
||||||
|
|
||||||
if (doextra) {
|
if (doextra) {
|
||||||
if (file && line >= 0) {
|
if (file && line >= 0) {
|
||||||
|
|
Loading…
Reference in New Issue