blob: a814224c8712b42598c7a4251ca9406f8ee86cc3 [file] [log] [blame]
Holger Freyther32636e82008-12-27 11:07:15 +00001/* Debugging/Logging support code */
2/* (C) 2008 by Harald Welte <laforge@gnumonks.org>
3 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 */
20
21#include <stdarg.h>
22#include <stdio.h>
23#include <string.h>
24#include <time.h>
25
26#include <openbsc/debug.h>
27
28static unsigned int debug_mask = 0xffffffff & ~DMI;
29
30void debugp(unsigned int subsys, char *file, int line, const char *format, ...)
31{
32 char *timestr;
33 va_list ap;
34 time_t tm;
35 FILE *outfd = stderr;
36
37 if (!(debug_mask & subsys))
38 return;
39
40 va_start(ap, format);
41
42 tm = time(NULL);
43 timestr = ctime(&tm);
44 timestr[strlen(timestr)-1] = '\0';
45 fprintf(outfd, "%s <%4.4x> %s:%d ", timestr, subsys, file, line);
46 vfprintf(outfd, format, ap);
47
48 va_end(ap);
49
50 fflush(outfd);
51}
52