On 2011/08/17 22:29, Claudio Jeker wrote:
> I don't like it and the diff is wrong -- the parent process will still not
> log verbose. I think the problem should be fixed at the source and
> change the way log_init() and log_verbose() work. Currently the second
> log_init() call in ospfd.c will disable the verbose setting. I guess
> log_init needs either 2 flags or it must only or n_debug into verbose so
> that the previous call to log_verbose() is sticky.
If we or n_debug into verbose, the log_init(1) for verbose logging
at startup will never get cleared, so we will always log the debug
information. So I think we need to add an argument to log_init().
This works with ospfd (non-verbose), ospfd -v (verbose), and the
log_debug() calls from all 3 processes do get logged.
diff --git log.c log.c
index e8326b8..536c456 100644
--- log.c
+++ log.c
@@ -39,12 +39,12 @@ int verbose;
void logit(int, const char *, ...);
void
-log_init(int n_debug)
+log_init(int n_debug, int n_verbose)
{
extern char *__progname;
debug = n_debug;
- verbose = n_debug;
+ verbose = n_verbose;
if (!debug)
openlog(__progname, LOG_PID | LOG_NDELAY, LOG_DAEMON);
diff --git log.h log.h
index ff5ef25..2e95e1d 100644
--- log.h
+++ log.h
@@ -21,7 +21,7 @@
#include <stdarg.h>
-void log_init(int);
+void log_init(int, int);
void log_verbose(int);
void vlog(int, const char *, va_list);
void log_warn(const char *, ...);
diff --git ospfd.c ospfd.c
index bcead83..005e4ff 100644
--- ospfd.c
+++ ospfd.c
@@ -138,7 +138,7 @@ main(int argc, char *argv[])
ospfd_process = PROC_MAIN;
sockname = OSPFD_SOCKET;
- log_init(1); /* log to stderr until daemonized */
+ log_init(1, 1); /* log to stderr until daemonized */
while ((ch = getopt(argc, argv, "cdD:f:ns:v")) != -1) {
switch (ch) {
@@ -221,7 +221,7 @@ main(int argc, char *argv[])
if (getpwnam(OSPFD_USER) == NULL)
errx(1, "unknown user %s", OSPFD_USER);
- log_init(debug);
+ log_init(debug, opts & OSPFD_OPT_VERBOSE);
if (!debug)
daemon(1, 0);