about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-02-03 00:27:43 +0000
committerJames Booth <boothj5@gmail.com>2013-02-03 00:27:43 +0000
commitc90c83f7e1e2a3dc9aa28baa959bc45cf4fe6362 (patch)
treea8a7d54aacb0b49e9d3c5d5e07a9e29fb19200f9 /src
parent7d6ce4da0271babfce08d19899563b1065feedef (diff)
downloadprofani-tty-c90c83f7e1e2a3dc9aa28baa959bc45cf4fe6362.tar.gz
Removed log function to log.c
Diffstat (limited to 'src')
-rw-r--r--src/log.c16
-rw-r--r--src/log.h1
-rw-r--r--src/profanity.c17
3 files changed, 18 insertions, 16 deletions
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 <assert.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -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);