SIDN / spin

SPIN Core Software
https://spin.sidnlabs.nl
GNU General Public License v2.0
77 stars 9 forks source link

Calling spin_log() before calling spin_log_init() #70

Closed cschutijser closed 3 years ago

cschutijser commented 4 years ago

We call spin_log() in main() (while processing the command line arguments). spin_log_init() is called afterwards. This means that we potentially call spin_log() while the log has not been initialized yet. In particular, this means that log messages generated while processing the command line arguments do not appear on stdout even if we specify -o (but go to syslog instead).

Should we just use printf() while processing the command line arguments? We could also print the messages we want to print after we initialized the log. A pseudodiff follows to illustrate what I mean:

 while ((c = getopt (argc, argv, "dehLlm:op:v")) != -1) {
     switch (c) {
         case 'l':
-            spin_log(LOG_INFO, "Running in local mode; traffic without either entry in arp cache will be shown too\n");
             local_mode = 1;
             break;
      }
 }

 spin_log_init(use_syslog, log_verbosity, "spind");
+
+if (local_mode) {
+    spin_log(LOG_INFO, "Running in local mode; traffic without either entry in arp cache will be shown too\n");
+}