summaryrefslogtreecommitdiffstats
path: root/usbmuxd/log.c
diff options
context:
space:
mode:
authorGravatar Hector Martin2009-08-19 01:24:48 +0200
committerGravatar Hector Martin2009-08-19 01:24:48 +0200
commitd23a2142685b943c4a944ae28d6658c4f562e79e (patch)
tree090d7a62f88151daf02bdf4b076b4908f81e7b1e /usbmuxd/log.c
parentf3cc57a74fa9647565a920ce03889084ca28c6b0 (diff)
downloadusbmuxd-d23a2142685b943c4a944ae28d6658c4f562e79e.tar.gz
usbmuxd-d23a2142685b943c4a944ae28d6658c4f562e79e.tar.bz2
Logging fixes, change default loglevel to LL_WARNING
Diffstat (limited to 'usbmuxd/log.c')
-rw-r--r--usbmuxd/log.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/usbmuxd/log.c b/usbmuxd/log.c
index 4f67e85..2ccb3cc 100644
--- a/usbmuxd/log.c
+++ b/usbmuxd/log.c
@@ -32,7 +32,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 32
33#include "log.h" 33#include "log.h"
34 34
35int log_level = LL_FATAL; 35int log_level = LL_WARNING;
36 36
37int log_syslog = 0; 37int log_syslog = 0;
38 38
@@ -66,17 +66,22 @@ void usbmuxd_log(enum loglevel level, const char *fmt, ...)
66 char *fs; 66 char *fs;
67 struct timeval ts; 67 struct timeval ts;
68 struct tm *tp; 68 struct tm *tp;
69 69
70 gettimeofday(&ts, NULL); 70 gettimeofday(&ts, NULL);
71 tp = localtime(&ts.tv_sec); 71 tp = localtime(&ts.tv_sec);
72 72
73 if(level > log_level) 73 if(level > log_level)
74 return; 74 return;
75 75
76 fs = malloc(20 + strlen(fmt)); 76 fs = malloc(20 + strlen(fmt));
77 strftime(fs, 10, "[%H:%M:%S", tp); 77
78 sprintf(fs+9, ".%03d][%d] %s\n", (int)(ts.tv_usec / 1000), level, fmt); 78 if(log_syslog) {
79 79 sprintf(fs, "[%d] %s\n", level, fmt);
80 } else {
81 strftime(fs, 10, "[%H:%M:%S", tp);
82 sprintf(fs+9, ".%03d][%d] %s\n", (int)(ts.tv_usec / 1000), level, fmt);
83 }
84
80 va_start(ap, fmt); 85 va_start(ap, fmt);
81 if (log_syslog) { 86 if (log_syslog) {
82 vsyslog(level_to_syslog_level(level), fs, ap); 87 vsyslog(level_to_syslog_level(level), fs, ap);
@@ -84,6 +89,6 @@ void usbmuxd_log(enum loglevel level, const char *fmt, ...)
84 vfprintf(stderr, fs, ap); 89 vfprintf(stderr, fs, ap);
85 } 90 }
86 va_end(ap); 91 va_end(ap);
87 92
88 free(fs); 93 free(fs);
89} 94}