summaryrefslogtreecommitdiff
path: root/debug.h
blob: 0c5e3a5895329536324f5441784280b7800e0a20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set et sw=2 ts=2: */
/***************************************************************************
 *            debug.h
 *
 *  Thu Nov  1 13:38:47 CET 2012
 *  Copyright 2012 Bent Bisballe Nyeng
 *  deva@aasimon.org
 ****************************************************************************/

/*
 *  This file is part of Debug Module.
 *
 *  Debug Module is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  Debug Module is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Debug Module; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
 */
#ifndef __DEBUG_MODULE_DEBUG_H__
#define __DEBUG_MODULE_DEBUG_H__

#include <stdio.h>

void debug_init(FILE *fp);
void debug_parse(const char *fmt);

enum __debug_class
{
  __class_fixme = 0,
	__class_err = 1,
	__class_warn = 2,
	__class_info = 3,
	__class_debug = 4
};

int __debug(const char *func, const int line, enum __debug_class cl,
            const char *ch, const char *fmt, ...)
  __attribute__((format (printf,5,6)));

#define __DEBUG_PRINT(cl, ch, fmt...)	\
	do { __debug(__func__, __LINE__, cl, ch, fmt); } while(0)
#define __DEBUG(cl, ch, fmt...) \
	__DEBUG_PRINT(__class##cl, #ch, fmt)

#define ERR(ch, fmt...) __DEBUG(_err, ch, fmt)
#define WARN(ch, fmt...) __DEBUG(_warn, ch, fmt)
#define INFO(ch, fmt...) __DEBUG(_info, ch, fmt)
#define DEBUG(ch, fmt...) __DEBUG(_debug, ch, fmt)

#endif/*__DEBUG_MODULE_DEBUG_H__*/