diff --git a/src/log.c b/src/log.c index 86db07ae..df64a7b3 100644 --- a/src/log.c +++ b/src/log.c @@ -20,6 +20,7 @@ * */ +#include #include #include #include @@ -161,6 +162,21 @@ log_msg(log_level_t level, const char * const area, const char * const msg) } } +log_level_t +log_level_from_string(char *log_level) +{ + assert(log_level != NULL); + if (strcmp(log_level, "DEBUG") == 0) { + return PROF_LEVEL_DEBUG; + } else if (strcmp(log_level, "INFO") == 0) { + return PROF_LEVEL_INFO; + } else if (strcmp(log_level, "WARN") == 0) { + return PROF_LEVEL_WARN; + } else { + return PROF_LEVEL_ERROR; + } +} + static void _rotate_log_file(void) { diff --git a/src/log.h b/src/log.h index 146f55a4..82d2774d 100644 --- a/src/log.h +++ b/src/log.h @@ -45,6 +45,7 @@ void log_warning(const char * const msg, ...); void log_error(const char * const msg, ...); void log_msg(log_level_t level, const char * const area, const char * const msg); +log_level_t log_level_from_string(char *log_level); void chat_log_init(void); void chat_log_chat(const gchar * const login, gchar *other, diff --git a/src/profanity.c b/src/profanity.c index 0dddac14..83a955a6 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -44,7 +44,6 @@ #include "ui/ui.h" #include "xmpp/xmpp.h" -static log_level_t _get_log_level(char *log_level); static gboolean _process_input(char *inp); static void _handle_idle_time(void); static void _init(const int disable_tls, char *log_level); @@ -395,20 +394,6 @@ prof_handle_activity(void) } } -static log_level_t -_get_log_level(char *log_level) -{ - if (strcmp(log_level, "DEBUG") == 0) { - return PROF_LEVEL_DEBUG; - } else if (strcmp(log_level, "INFO") == 0) { - return PROF_LEVEL_INFO; - } else if (strcmp(log_level, "WARN") == 0) { - return PROF_LEVEL_WARN; - } else { - return PROF_LEVEL_ERROR; - } -} - /* * Take a line of input and process it, return TRUE if profanity is to * continue, FALSE otherwise @@ -507,7 +492,7 @@ _init(const int disable_tls, char *log_level) // ignore SIGPIPE signal(SIGPIPE, SIG_IGN); _create_directories(); - log_level_t prof_log_level = _get_log_level(log_level); + log_level_t prof_log_level = log_level_from_string(log_level); log_init(prof_log_level); if (strcmp(PACKAGE_STATUS, "development") == 0) { log_info("Starting Profanity (%sdev)...", PACKAGE_VERSION);