logger: Print warning when dlogutil config line did not come with -f (required) 03/143603/6
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Thu, 10 Aug 2017 12:09:14 +0000 (14:09 +0200)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Fri, 11 Aug 2017 12:58:22 +0000 (12:58 +0000)
Change-Id: I8d317c258950fc5e3ec3adcf0372ef49fe90d4ee

src/logger/logger.c

index 294d678..39afcd5 100644 (file)
@@ -1243,6 +1243,11 @@ static int parse_command_line(const char* cmdl, struct writer* wr, struct reader
                if (retval < 0)
                        goto cleanup;
        } else {
+               // we have got no file path nor dlogutil connection to write to - unable to proceed
+               retval = wr ? 0 : -EINVAL;
+               if (retval < 0)
+                       goto cleanup;
+
                int fds[2];
                if (pipe2(fds, O_CLOEXEC | O_NONBLOCK) < 0) {
                        retval = -errno;
@@ -1256,7 +1261,6 @@ static int parse_command_line(const char* cmdl, struct writer* wr, struct reader
                        goto cleanup;
        }
 
-
 cleanup:
        /* recycle for further usage */
        optarg = NULL;
@@ -2146,9 +2150,16 @@ void parse_logfile_config(void *value, void *userdata)
 
        struct logger *server = (struct logger *) userdata;
        struct reader *rd = NULL;
+       char *configline = (char *) value;
 
-       if (parse_command_line((char *)value, NULL, &rd) == 0)
+       int r = parse_command_line(configline, NULL, &rd);
+       if (r == 0)
                add_reader(server, rd);
+       else
+               printf("Warning: unable to add logutil reader for provided configuration. Ignoring.\n"
+                      "  Config line: %s\n"
+                      "  Reason given: %s\n",
+                      configline, strerror(-r));
 }
 
 /**