1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-28 01:58:17 +03:00

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 <slow@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
Ralph Boehme 2021-11-08 19:41:50 +01:00
parent 948a82bd26
commit fa9d9974d0

View 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)