debug: add support for per debug-class logfiles
authorRalph Boehme <slow@samba.org>
Wed, 12 Dec 2018 12:11:26 +0000 (13:11 +0100)
committerJeremy Allison <jra@samba.org>
Thu, 20 Dec 2018 02:19:27 +0000 (03:19 +0100)
This adds support for per debug-class logfiles to the function parsing
the "log level" option.

The enhanced syntax is:

  log level = CLASS:LEVEL[@PATH] [CLASS:LEVEL[@PATH] ... ]

Eg

  log level = full_audit:1@/var/log/audit.logfile

While the option is already parsed and stored in in the dbgc_config[]
array, the feature is still effectively disabled, as
reopen_logs_internal() still doesn't open the per debug-class logfiles.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/util/debug.c

index 780ce9a..c315222 100644 (file)
@@ -810,6 +810,7 @@ static void debug_dump_status(int level)
 static bool debug_parse_param(char *param)
 {
        char *class_name;
+       char *class_file = NULL;
        char *class_level;
        char *saveptr = NULL;
        int ndx;
@@ -819,11 +820,13 @@ static bool debug_parse_param(char *param)
                return false;
        }
 
-       class_level = strtok_r(NULL, "\0", &saveptr);
+       class_level = strtok_r(NULL, "@\0", &saveptr);
        if (class_level == NULL) {
                return false;
        }
 
+       class_file = strtok_r(NULL, "\0", &saveptr);
+
        ndx = debug_lookup_classname(class_name);
        if (ndx == -1) {
                return false;
@@ -831,6 +834,16 @@ static bool debug_parse_param(char *param)
 
        dbgc_config[ndx].loglevel = atoi(class_level);
 
+       if (class_file == NULL) {
+               return true;
+       }
+
+       TALLOC_FREE(dbgc_config[ndx].logfile);
+
+       dbgc_config[ndx].logfile = talloc_strdup(NULL, class_file);
+       if (dbgc_config[ndx].logfile == NULL) {
+               return false;
+       }
        return true;
 }