diff --git a/conf.c b/conf.c index 3b68875f..ed5bdd3b 100644 --- a/conf.c +++ b/conf.c @@ -59,7 +59,7 @@ static int reload(const char *path, int *resultp) } if (cmp_file_meta(&meta, &conffile_meta) == 0) return 0; - if (conffile_meta.mtime.tv_sec != -1 && serverMode) + if (conffile_meta.mtime.tv_sec != -1) INFOF("config file %s -- detected new version", conffile_path()); char *buf = NULL; if (meta.mtime.tv_sec == -1) { @@ -93,8 +93,8 @@ static int reload(const char *path, int *resultp) free(buf); return -1; } - if (serverMode) - INFOF("config file %s successfully read %ld bytes", path, (long) meta.size); + if (config.debug.config) + DEBUGF("config file %s successfully read %ld bytes", path, (long) meta.size); } conffile_meta = meta; if (config.debug.config) diff --git a/log.c b/log.c index 62b44cb1..a7ff5338 100644 --- a/log.c +++ b/log.c @@ -43,7 +43,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "strbuf_helpers.h" #include "xprintf.h" -int serverMode = 0; +int logLevel_NoLogFileConfigured = LOG_LEVEL_INFO; #define NO_FILE ((FILE *)1) @@ -487,7 +487,7 @@ static void _open_log_file(_log_iterator *it) if (cf_limbo) return; _log_file = NO_FILE; - _logs_printf_nl(serverMode ? LOG_LEVEL_WARN : LOG_LEVEL_INFO, __NOWHERE__, "No log file configured"); + _logs_printf_nl(logLevel_NoLogFileConfigured, __NOWHERE__, "No log file configured"); } else { // Create the new log file. size_t dirsiz = strlen(_log_file_path) + 1; diff --git a/log.h b/log.h index aef63b17..3d760fea 100644 --- a/log.h +++ b/log.h @@ -48,7 +48,7 @@ const char *log_level_as_string(int level); int string_to_log_level(const char *text); // Log output control. -extern int serverMode; +extern int logLevel_NoLogFileConfigured; void close_log_file(); void disable_log_stderr(); void logFlush(); diff --git a/log_stderr.c b/log_stderr.c index 7756e4dc..26f5a85e 100644 --- a/log_stderr.c +++ b/log_stderr.c @@ -26,8 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * using stdio buffered output. */ -int serverMode=0; - static const char *_trimbuildpath(const char *path) { /* Remove common path prefix */ diff --git a/mdp_filter.c b/mdp_filter.c index 8a9f2c66..837df772 100644 --- a/mdp_filter.c +++ b/mdp_filter.c @@ -18,6 +18,7 @@ */ #include // for PRIx64 on Android +#include "serval.h" // for serverMode #include "serval_types.h" #include "instance.h" #include "overlay_address.h" diff --git a/serval.h b/serval.h index 616f3a51..4d7f9d13 100644 --- a/serval.h +++ b/serval.h @@ -173,16 +173,16 @@ struct overlay_buffer; struct overlay_frame; struct broadcast; +extern int serverMode; + int server_pid(); const char *_server_pidfile_path(struct __sourceloc); #define server_pidfile_path() (_server_pidfile_path(__WHENCE__)) void server_save_argv(int argc, const char *const *argv); int server(void); -int server_write_pid(); int server_write_proc_state(const char *path, const char *fmt, ...); int server_get_proc_state(const char *path, char *buff, size_t buff_len); void overlay_mdp_clean_socket_files(); -void serverCleanUp(); int overlay_forward_payload(struct overlay_frame *f); int packetOkOverlay(struct overlay_interface *interface,unsigned char *packet, size_t len, diff --git a/server.c b/server.c index 8073fc4d..4bdeb66d 100644 --- a/server.c +++ b/server.c @@ -39,6 +39,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define PIDFILE_NAME "servald.pid" #define STOPFILE_NAME "servald.stop" +int serverMode = 0; keyring_file *keyring=NULL; static char pidfile_path[256]; @@ -94,6 +95,9 @@ int server() IN(); serverMode = 1; + // Warn, not merely Info, if there is no configured log file. + logLevel_NoLogFileConfigured = LOG_LEVEL_WARN; + /* Catch SIGHUP etc so that we can respond to requests to do things, eg, shut down. */ struct sigaction sig; sig.sa_handler = signal_handler;