From: Guus Sliepen Date: Mon, 21 Apr 2014 21:35:09 +0000 (+0200) Subject: Remove unused logging functionality. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=3d5dd72aa41f162fd5d4d6dd13f46c0fca5a14a9;p=meshlink Remove unused logging functionality. Just log to stderr for now. In the future we will use the callback provided by the application. --- diff --git a/src/logger.c b/src/logger.c index 54eb3b68..eb630890 100644 --- a/src/logger.c +++ b/src/logger.c @@ -19,56 +19,14 @@ #include "system.h" -#include "conf.h" -#include "meta.h" #include "logger.h" -#include "connection.h" -#include "sptps.h" debug_t debug_level = DEBUG_NOTHING; -static logmode_t logmode = LOGMODE_STDERR; -static pid_t logpid; -#ifdef HAVE_MINGW -static HANDLE loghandle = NULL; -#endif -static const char *logident = NULL; -static void real_logger(int level, int priority, const char *message) { - char timestr[32] = ""; - static bool suppress = false; - - // Bail out early if there is nothing to do. - if(suppress) - return; - - if(level > debug_level || logmode == LOGMODE_NULL) +void logger(int level, int priority, const char *format, ...) { + if(level > debug_level) return; - if(level <= debug_level) { - switch(logmode) { - case LOGMODE_STDERR: - fprintf(stderr, "%s\n", message); - fflush(stderr); - break; - case LOGMODE_SYSLOG: -#ifdef HAVE_MINGW - { - const char *messages[] = {message}; - ReportEvent(loghandle, priority, 0, 0, NULL, 1, 0, messages, NULL); - } -#else -#ifdef HAVE_SYSLOG_H - syslog(priority, "%s", message); -#endif -#endif - break; - case LOGMODE_NULL: - break; - } - } -} - -void logger(int level, int priority, const char *format, ...) { va_list ap; char message[1024] = ""; @@ -79,65 +37,15 @@ void logger(int level, int priority, const char *format, ...) { if(len > 0 && len < sizeof message && message[len - 1] == '\n') message[len - 1] = 0; - real_logger(level, priority, message); + fprintf(stderr, "%s\n", message); } -static void sptps_logger(sptps_t *s, int s_errno, const char *format, va_list ap) { +// TODO: make sure this gets used somewhere +static void sptps_logger(struct sptps *s, int s_errno, const char *format, va_list ap) { char message[1024] = ""; int len = vsnprintf(message, sizeof message, format, ap); if(len > 0 && len < sizeof message && message[len - 1] == '\n') message[len - 1] = 0; - real_logger(DEBUG_ALWAYS, LOG_ERR, message); -} - -void openlogger(const char *ident, logmode_t mode) { - logident = ident; - logmode = mode; - - switch(mode) { - case LOGMODE_STDERR: - logpid = getpid(); - break; - case LOGMODE_SYSLOG: -#ifdef HAVE_MINGW - loghandle = RegisterEventSource(NULL, logident); - if(!loghandle) { - fprintf(stderr, "Could not open log handle!"); - logmode = LOGMODE_NULL; - } - break; -#else -#ifdef HAVE_SYSLOG_H - openlog(logident, LOG_CONS | LOG_PID, LOG_DAEMON); - break; -#endif -#endif - case LOGMODE_NULL: - break; - } - - if(logmode != LOGMODE_NULL) - sptps_log = sptps_logger; - else - sptps_log = sptps_log_quiet; -} - -void closelogger(void) { - switch(logmode) { - case LOGMODE_SYSLOG: -#ifdef HAVE_MINGW - DeregisterEventSource(loghandle); - break; -#else -#ifdef HAVE_SYSLOG_H - closelog(); - break; -#endif -#endif - case LOGMODE_NULL: - case LOGMODE_STDERR: - break; - break; - } + fprintf(stderr, "%s\n", message); } diff --git a/src/logger.h b/src/logger.h index 91440313..89d65616 100644 --- a/src/logger.h +++ b/src/logger.h @@ -64,9 +64,6 @@ enum { #endif extern debug_t debug_level; -extern bool logcontrol; -extern void openlogger(const char *, logmode_t); extern void logger(int, int, const char *, ...) __attribute__ ((__format__(printf, 3, 4))); -extern void closelogger(void); #endif /* __TINC_LOGGER_H__ */