From fa9d9974d068897d35539e5316f606a15e8b38de Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Mon, 8 Nov 2021 19:41:50 +0100 Subject: [PATCH] lib/debug: in debug_set_logfile() call reopen_logs_internal() 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 Reviewed-by: Andreas Schneider --- lib/util/debug.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/util/debug.c b/lib/util/debug.c index 4ed1543ef4b..784357e9370 100644 --- a/lib/util/debug.c +++ b/lib/util/debug.c @@ -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) -- 2.47.3