summaryrefslogtreecommitdiff
path: root/sysdep/unix/log.c
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2018-12-04 16:55:25 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2018-12-04 16:55:25 +0100
commit3fda08e40532245ba69e14cdac0623a138b939f9 (patch)
tree0332e47c73ab22c92df09518de90fefa89453b2a /sysdep/unix/log.c
parent0642fb4d456fe12e1bbeb2ffc2149433f228c02e (diff)
Unix: Change debugging options
The old behavior was that enabling debugging did many nontrivial changes in BIRD behavior. The patch changes it that these changes are generally independent. Compiling with --enable-debug now just enables compile-time debug macros, but do not automatically activate debug mode (-d) nor local mode (-l). Debug mode with output to file (-D) do not force foreground mode (-f), therefore there is no need for backgroud option (-b), which is removed. Also fixes a bug when the default log target in -D mode was stderr instead of given debug file.
Diffstat (limited to 'sysdep/unix/log.c')
-rw-r--r--sysdep/unix/log.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/sysdep/unix/log.c b/sysdep/unix/log.c
index 9a0fa550..c9064834 100644
--- a/sysdep/unix/log.c
+++ b/sysdep/unix/log.c
@@ -170,7 +170,8 @@ log_commit(int class, buffer *buf)
else
{
byte tbuf[TM_DATETIME_BUFFER_SIZE];
- if (!tm_format_real_time(tbuf, sizeof(tbuf), config->tf_log.fmt1, current_real_time()))
+ const char *fmt = config ? config->tf_log.fmt1 : "%F %T.%3f";
+ if (!tm_format_real_time(tbuf, sizeof(tbuf), fmt, current_real_time()))
strcpy(tbuf, "<error>");
if (l->limit)
@@ -322,36 +323,45 @@ debug(const char *msg, ...)
}
static list *
-default_log_list(int debug, int init, char **syslog_name)
+default_log_list(int initial, char **syslog_name)
{
- static list init_log_list;
- init_list(&init_log_list);
+ static list log_list;
+ init_list(&log_list);
*syslog_name = NULL;
#ifdef HAVE_SYSLOG_H
- if (!debug)
+ if (!dbgf)
{
static struct log_config lc_syslog = { .mask = ~0 };
- add_tail(&init_log_list, &lc_syslog.n);
+ add_tail(&log_list, &lc_syslog.n);
*syslog_name = bird_name;
- if (!init)
- return &init_log_list;
}
#endif
- static struct log_config lc_stderr = { .mask = ~0, .terminal_flag = 1 };
- lc_stderr.fh = stderr;
- add_tail(&init_log_list, &lc_stderr.n);
- return &init_log_list;
+ if (dbgf && (dbgf != stderr))
+ {
+ static struct log_config lc_debug = { .mask = ~0 };
+ lc_debug.fh = dbgf;
+ add_tail(&log_list, &lc_debug.n);
+ }
+
+ if (initial || (dbgf == stderr))
+ {
+ static struct log_config lc_stderr = { .mask = ~0, .terminal_flag = 1};
+ lc_stderr.fh = stderr;
+ add_tail(&log_list, &lc_stderr.n);
+ }
+
+ return &log_list;
}
void
-log_switch(int debug, list *logs, char *new_syslog_name)
+log_switch(int initial, list *logs, char *new_syslog_name)
{
struct log_config *l;
if (!logs || EMPTY_LIST(*logs))
- logs = default_log_list(debug, !logs, &new_syslog_name);
+ logs = default_log_list(initial, &new_syslog_name);
/* Close the logs to avoid pinning them on disk when deleted */
if (current_log_list)