diff options
Diffstat (limited to 'usbmuxd/log.c')
| -rw-r--r-- | usbmuxd/log.c | 21 |
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 | ||
| 35 | int log_level = LL_FATAL; | 35 | int log_level = LL_WARNING; |
| 36 | 36 | ||
| 37 | int log_syslog = 0; | 37 | int 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 | } |
