lib/debug: in debug_set_logfile() call reopen_logs_internal()
authorRalph Boehme <slow@samba.org>
Mon, 8 Nov 2021 18:41:50 +0000 (19:41 +0100)
committerRalph Boehme <slow@samba.org>
Thu, 11 Nov 2021 13:49:32 +0000 (13:49 +0000)
This simplifies the logging API for callers that typically would want to set
logging by just setup_logging() once without bothering that typically
configuration is loaded (via some lpcfg_load*() or lp_load*() varient) which
will only then pick up the configured logfile from smb.conf without actually
applying the new logifle to the logging subsytem.

Therefor our daemons will additionally call reopen_logs() explicitly in their
startup code after config is loaded, eg

setup_logging(getprogname(), DEBUG_FILE);
...
lpcfg_load(lp_ctx, config_file);
...
reopen_logs();

By calling reopen_logs_internal() implicitly from debug_set_logfile() there's no
need to call reopen_logs() explicitly anymore to apply the logfile.

As reopen_logs() will also apply other logging configuration options, we have to
keep the explicit calls in the daemon code. But at least this allows consistent
logging setup wrt to the logfile in the new cmdline library.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14897

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
lib/util/debug.c

index 4ed1543ef4bec378d985ad4ddd9bddd1f2e2ee60..784357e937058eab8eb1d9ba86cc4eb2562845c1 100644 (file)
@@ -1143,6 +1143,8 @@ void debug_set_logfile(const char *name)
        }
        TALLOC_FREE(dbgc_config[DBGC_ALL].logfile);
        dbgc_config[DBGC_ALL].logfile = talloc_strdup(NULL, name);
+
+       reopen_logs_internal();
 }
 
 static void debug_close_fd(int fd)