about summary refs log tree commit diff stats
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
parent7d6ce4da0271babfce08d19899563b1065feedef (diff)
downloadprofani-tty-c90c83f7e1e2a3dc9aa28baa959bc45cf4fe6362.tar.gz
Removed log function to log.c
-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);
a id='n233' href='#n233'>233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463