summaryrefslogtreecommitdiffstats
path: root/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'log.c')
-rw-r--r--log.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/log.c b/log.c
new file mode 100644
index 0000000..d7f57df
--- /dev/null
+++ b/log.c
@@ -0,0 +1,50 @@
1/*
2 usbmuxd - iPhone/iPod Touch USB multiplex server daemon
3
4Copyright (C) 2009 Hector Martin "marcan" <hector@marcansoft.com>
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 2 or version 3.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19*/
20
21#ifdef HAVE_CONFIG_H
22#include <config.h>
23#endif
24
25#include <stdio.h>
26#include <stdlib.h>
27#include <string.h>
28#include <stdarg.h>
29
30#include "log.h"
31
32int log_level = LOG_SPEW;
33
34void usbmuxd_log(enum loglevel level, const char *fmt, ...)
35{
36 va_list ap;
37 char *fs;
38
39 if(level < log_level)
40 return;
41
42 fs = malloc(10 + strlen(fmt));
43 sprintf(fs, "[%d] %s\n", level, fmt);
44
45 va_start(ap, fmt);
46 vfprintf(stderr, fs, ap);
47 va_end(ap);
48
49 free(fs);
50} \ No newline at end of file