libdlog: detect and notify about empty tagged messages 78/196578/3
authorMaciej Slodczyk <m.slodczyk2@partner.samsung.com>
Wed, 2 Jan 2019 11:18:46 +0000 (12:18 +0100)
committerMaciej Slodczyk <m.slodczyk2@partner.samsung.com>
Fri, 4 Jan 2019 15:03:30 +0000 (16:03 +0100)
It is an error for an application to send a message with empty tag. To
make it easy to catch such situation and fix it in the app, empty-tagged
messages are exluded from limiter and marked with DLOG_ERROR_NOTAG tag.

Change-Id: I5ca0e0ef0e20f9d7cabcec11dad379023b7f0630
Signed-off-by: Maciej Slodczyk <m.slodczyk2@partner.samsung.com>
src/libdlog/loglimiter.c
src/shared/logprint.c

index 351ec3a..d9b2a54 100644 (file)
@@ -353,6 +353,10 @@ int __log_limiter_pass_log(const char* tag, int prio)
        if (!rules_hashmap)
                return 1;
 
+       /* allow empty-tagged messages and make it easy to catch an application that does that */
+       if (!strlen(tag))
+               return 1;
+
        const char prio_c = util_prio_to_char(prio);
        struct rule *r =
                hashmap_search(rules_hashmap, tag, prio_c) ?:
index 78c50b9..59cc446 100644 (file)
@@ -647,6 +647,10 @@ char *log_format_log_line(
        priChar = filter_pri_to_char((log_priority)entry->priority);
 
        tag = log_buffer_get_tag(entry);
+       /* mark empty-tagged messages and make it easy to catch an application that does that */
+       if (!tag || !strlen(tag))
+               tag = "DLOG_ERROR_NOTAG";
+
        msg = log_buffer_get_message(entry);
 
        /*