diff --git a/apps/backend/backend_main.c b/apps/backend/backend_main.c index 3b018dcc..07617e93 100644 --- a/apps/backend/backend_main.c +++ b/apps/backend/backend_main.c @@ -73,7 +73,7 @@ #include "backend_handle.h" /* Command line options to be passed to getopt(3) */ -#define BACKEND_OPTS "hD:f:d:b:Fzu:a:P:1s:c:g:l:y:x:" /* substitute s: for IRCc:r */ +#define BACKEND_OPTS "hD:f:l:d:b:Fza:u:P:1s:c:g:y:x:" /* substitute s: for IRCc:r */ #define BACKEND_LOGFILE "/usr/local/var/clixon_backend.log" @@ -132,19 +132,20 @@ usage(clicon_handle h, "where options are\n" " -h\t\tHelp\n" " -D \tDebug level\n" - " -f \tCLICON config file (mandatory)\n" + " -f \tCLICON config file\n" + " -l > \tLog on (s)yslog, std(e)rr or std(o)ut (stderr is default) Only valid if -F, if background syslog is on syslog.\n" " -d \tSpecify backend plugin directory (default: %s)\n" " -b \tSpecify XMLDB database directory\n" - " -z\t\tKill other config daemon and exit\n" " -F\t\tRun in foreground, do not run as daemon\n" - " -1\t\tRun once and then quit (dont wait for events)\n" + " -z\t\tKill other config daemon and exit\n" " -a UNIX|IPv4|IPv6\tInternal backend socket family\n" " -u \tInternal socket domain path or IP addr (see -a)(default: %s)\n" " -P \tPid filename (default: %s)\n" + " -1\t\tRun once and then quit (dont wait for events)\n" " -s \tSpecify backend startup mode: none|startup|running|init (replaces -IRCr\n" " -c \tLoad extra xml configuration, but don't commit.\n" " -g \tClient membership required to this group (default: %s)\n" - " -l > \tLog on (s)yslog, std(e)rr or std(o)ut (stderr is default) Only valid if -F, if background syslog is on syslog.\n" + " -y \tOverride yang spec file (dont include .yang suffix)\n" " -x \tXMLDB plugin\n", argv0, @@ -577,7 +578,6 @@ main(int argc, optind = 1; while ((c = getopt(argc, argv, BACKEND_OPTS)) != -1) switch (c) { - case '?': case 'h': /* Defer the call to usage() to later. Reason is that for helpful text messages, default dirs, etc, are not set until later. @@ -631,8 +631,10 @@ main(int argc, optind = 1; while ((c = getopt(argc, argv, BACKEND_OPTS)) != -1) switch (c) { + case 'h' : /* help */ case 'D' : /* debug */ case 'f': /* config file */ + case 'l' : break; /* see above */ case 'd': /* Plugin directory */ if (!strlen(optarg)) @@ -647,9 +649,6 @@ main(int argc, case 'F' : /* foreground */ foreground = 1; break; - case '1' : /* Quit after reading database once - dont wait for events */ - once = 1; - break; case 'z': /* Zap other process */ zap++; break; @@ -664,6 +663,9 @@ main(int argc, case 'P': /* pidfile */ clicon_option_str_set(h, "CLICON_BACKEND_PIDFILE", optarg); break; + case '1' : /* Quit after reading database once - dont wait for events */ + once = 1; + break; case 's' : /* startup mode */ clicon_option_str_set(h, "CLICON_STARTUP_MODE", optarg); if (clicon_startup_mode(h) < 0){ @@ -685,8 +687,6 @@ main(int argc, clicon_option_str_set(h, "CLICON_XMLDB_PLUGIN", optarg); break; } - case 'l' : - break; default: usage(h, argv[0]); break; diff --git a/lib/src/clixon_log.c b/lib/src/clixon_log.c index 589eb796..9e8e2f1a 100644 --- a/lib/src/clixon_log.c +++ b/lib/src/clixon_log.c @@ -89,11 +89,14 @@ clicon_log_init(char *ident, int upto, int flags) { - if (setlogmask(LOG_UPTO(upto)) < 0) - /* Cant syslog here */ - fprintf(stderr, "%s: setlogmask: %s\n", __FUNCTION__, strerror(errno)); + _logflags = flags; - openlog(ident, LOG_PID, LOG_USER); /* LOG_PUSER is achieved by direct stderr logs in clicon_log */ + if (flags & CLICON_LOG_SYSLOG){ + if (setlogmask(LOG_UPTO(upto)) < 0) + /* Cant syslog here */ + fprintf(stderr, "%s: setlogmask: %s\n", __FUNCTION__, strerror(errno)); + openlog(ident, LOG_PID, LOG_USER); /* LOG_PUSER is achieved by direct stderr logs in clicon_log */ + } return 0; }