#endif /* S_SPLINT_S */
}
-/** set default logfile identity based on value from argv[0] at startup **/
-static void
-log_ident_set_fromdefault(struct config_file* cfg,
- const char *log_default_identity)
-{
- if(cfg->log_identity == NULL || cfg->log_identity[0] == 0)
- log_ident_set(log_default_identity);
- else
- log_ident_set(cfg->log_identity);
-}
-
/** set verbosity, check rlimits, cache settings */
static void
-apply_settings(struct daemon* daemon, struct config_file* cfg,
- int cmdline_verbose, int debug_mode, const char* log_default_identity)
+apply_settings(struct daemon* daemon, struct config_file* cfg,
+ int cmdline_verbose, int debug_mode)
{
/* apply if they have changed */
verbosity = cmdline_verbose + cfg->verbosity;
log_warn("use-systemd and do-daemonize should not be enabled at the same time");
}
- log_ident_set_fromdefault(cfg, log_default_identity);
+ log_ident_set_or_default(cfg->log_identity);
}
#ifdef HAVE_KILL
* @param cmdline_verbose: verbosity resulting from commandline -v.
* These increase verbosity as specified in the config file.
* @param debug_mode: if set, do not daemonize.
- * @param log_default_identity: Default identity to report in logs
* @param need_pidfile: if false, no pidfile is checked or created.
*/
static void
-run_daemon(const char* cfgfile, int cmdline_verbose, int debug_mode, const char* log_default_identity, int need_pidfile)
+run_daemon(const char* cfgfile, int cmdline_verbose, int debug_mode, int need_pidfile)
{
struct config_file* cfg = NULL;
struct daemon* daemon = NULL;
"or unbound-checkconf", cfgfile);
log_warn("Continuing with default config settings");
}
- apply_settings(daemon, cfg, cmdline_verbose, debug_mode, log_default_identity);
+ apply_settings(daemon, cfg, cmdline_verbose, debug_mode);
if(!done_setup)
config_lookup_uid(cfg);
log_init(NULL, 0, NULL);
log_ident_default = strrchr(argv[0],'/')?strrchr(argv[0],'/')+1:argv[0];
+ log_ident_set_default(log_ident_default);
log_ident_set(log_ident_default);
/* parse the options */
while( (c=getopt(argc, argv, "c:dhpvw:V")) != -1) {
return 1;
}
- run_daemon(cfgfile, cmdline_verbose, debug_mode, log_ident_default, need_pidfile);
+ run_daemon(cfgfile, cmdline_verbose, debug_mode, need_pidfile);
log_init(NULL, 0, NULL); /* close logfile */
#ifndef unbound_testbound
if(log_get_lock()) {
#endif
/** the identity of this executable/process */
static const char* ident="unbound";
+static const char* default_ident="unbound";
#if defined(HAVE_SYSLOG_H) || defined(UB_ON_WINDOWS)
/** are we using syslog(3) to log to */
static int logging_to_syslog = 0;
ident = id;
}
+void log_ident_set_default(const char* id)
+{
+ default_ident = id;
+}
+
+void log_ident_revert_to_default()
+{
+ ident = default_ident;
+}
+
+void log_ident_set_or_default(const char* identity)
+ //const char* default_identity)
+{
+ if(identity == NULL || identity[0] == 0)
+ //log_ident_set(default_identity);
+ log_ident_set(default_ident);
+ else
+ log_ident_set(identity);
+}
+
void log_set_time_asc(int use_asc)
{
log_time_asc = use_asc;
int log_thread_get(void);
/**
- * Set identity to print, default is 'unbound'.
+ * Set identity to print, default is 'unbound'.
* @param id: string to print. Name of executable.
*/
void log_ident_set(const char* id);
+/**
+ * Set default identity to print, default is 'unbound'.
+ * @param id: string to print. Name of executable.
+ */
+void log_ident_set_default(const char* id);
+
+/**
+ * Revert identity to print, back to the recorded default value.
+ */
+void log_ident_revert_to_default();
+
+/**
+ * Set identity to print if there is an identity, otherwise
+ * set the default.
+ * @param identity: the identity to set.
+ */
+void log_ident_set_or_default(const char* identity);
+
/**
* Set if the time value is printed ascii or decimal in log entries.
* @param use_asc: if true, ascii is printed, otherwise decimal.