comparison freeDiameterd/main.c @ 1409:cbd9dbc85476

freeDiameter: improve syslog logging Change -d and -q to control syslog level, as per stdout logging. Syslog to LOG_DAEMON. Actually syslog to LOG_DEBUG, now that -d/-q are used.
author Luke Mewburn <luke@mewburn.net>
date Tue, 18 Feb 2020 17:09:13 +1100
parents 23e224d22f45
children 4ddd4dcd6bb6
comparison
equal deleted inserted replaced
1408:23e224d22f45 1409:cbd9dbc85476
63 } 63 }
64 64
65 65
66 static void syslog_logger(int loglevel, const char * format, va_list args) 66 static void syslog_logger(int loglevel, const char * format, va_list args)
67 { 67 {
68 if (loglevel < fd_g_debug_lvl) {
69 return;
70 }
71
68 int level; 72 int level;
69 73
70 switch (loglevel) { 74 switch (loglevel) {
71 case FD_LOG_INFO: 75 case FD_LOG_INFO:
72 level = LOG_INFO; 76 level = LOG_INFO;
80 case FD_LOG_FATAL: 84 case FD_LOG_FATAL:
81 level = LOG_CRIT; 85 level = LOG_CRIT;
82 break; 86 break;
83 default: 87 default:
84 /* fallthrough */ 88 /* fallthrough */
89 case FD_LOG_ANNOYING:
85 case FD_LOG_DEBUG: 90 case FD_LOG_DEBUG:
86 /* some systems log LOG_DEBUG to a file; but
87 * freeDiameter debug output is too verbose */
88 return;
89 #if 0
90 level = LOG_DEBUG; 91 level = LOG_DEBUG;
91 break; 92 break;
92 #endif 93 }
93 } 94
94 95 vsyslog(level | LOG_DAEMON, format, args);
95 vsyslog(level, format, args);
96 } 96 }
97 97
98 98
99 /* freeDiameter starting point */ 99 /* freeDiameter starting point */
100 int main(int argc, char * argv[]) 100 int main(int argc, char * argv[])
186 " default location (" DEFAULT_CONF_PATH "/" FD_DEFAULT_CONF_FILENAME ")\n" 186 " default location (" DEFAULT_CONF_PATH "/" FD_DEFAULT_CONF_FILENAME ")\n"
187 " -D, --daemon Start program in background\n" 187 " -D, --daemon Start program in background\n"
188 " -s, --syslog Write log output to syslog (instead of stdout)\n"); 188 " -s, --syslog Write log output to syslog (instead of stdout)\n");
189 printf( "\nDebug:\n" 189 printf( "\nDebug:\n"
190 " These options are mostly useful for developers\n" 190 " These options are mostly useful for developers\n"
191 " -d, --debug Increase verbosity of debug messages if default logger is used\n" 191 " -d, --debug Increase verbosity of log messages\n"
192 " -f, --dbg_func <func> Enable all traces within the function <func>\n" 192 " -f, --dbg_func <func> Enable all traces within the function <func>\n"
193 " -F, --dbg_file <file.c> Enable all traces within the file <file.c> (basename match)\n" 193 " -F, --dbg_file <file.c> Enable all traces within the file <file.c> (basename match)\n"
194 " -g, --dbg_gnutls <int> Enable GNU TLS debug at level <int>\n" 194 " -g, --dbg_gnutls <int> Enable GNU TLS debug at level <int>\n"
195 " -l, --dbglocale Set the locale for error messages\n" 195 " -l, --dbglocale Set the locale for error messages\n"
196 " -q, --quiet Decrease verbosity if default logger is used\n" 196 " -q, --quiet Decrease verbosity of log messages\n"
197 ); 197 );
198 } 198 }
199 199
200 /* Parse the command-line */ 200 /* Parse the command-line */
201 static int main_cmdline(int argc, char *argv[]) 201 static int main_cmdline(int argc, char *argv[])
"Welcome to our mercurial repository"