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
#include "log.h"
-int log_level = LL_FATAL;
+int log_level = LL_WARNING;
int log_syslog = 0;
@@ -66,17 +66,22 @@ void usbmuxd_log(enum loglevel level, const char *fmt, ...)
char *fs;
struct timeval ts;
struct tm *tp;
-
+
gettimeofday(&ts, NULL);
tp = localtime(&ts.tv_sec);
-
+
if(level > log_level)
return;
-
+
fs = malloc(20 + strlen(fmt));
- strftime(fs, 10, "[%H:%M:%S", tp);
- sprintf(fs+9, ".%03d][%d] %s\n", (int)(ts.tv_usec / 1000), level, fmt);
-
+
+ if(log_syslog) {
+ sprintf(fs, "[%d] %s\n", level, fmt);
+ } else {
+ strftime(fs, 10, "[%H:%M:%S", tp);
+ sprintf(fs+9, ".%03d][%d] %s\n", (int)(ts.tv_usec / 1000), level, fmt);
+ }
+
va_start(ap, fmt);
if (log_syslog) {
vsyslog(level_to_syslog_level(level), fs, ap);
@@ -84,6 +89,6 @@ void usbmuxd_log(enum loglevel level, const char *fmt, ...)
vfprintf(stderr, fs, ap);
}
va_end(ap);
-
+
free(fs);
}