1
/*
2
 * Copyright (C) 2009-2010 Felipe Contreras
3
 * Copyright (C) 2009-2010 Nokia Corporation
4
 *
5
 * Author: Felipe Contreras <felipe.contreras@gmail.com>
6
 *
7
 * This file may be used under the terms of the GNU Lesser General Public
8
 * License version 2.1, a copy of which is found in LICENSE included in the
9
 * packaging of this file.
10
 */
11
12
#ifndef LOG_H
13
#define LOG_H
14
15
#ifdef DEBUG
16
extern unsigned debug_level;
17
#endif
18
19
void pr_helper(unsigned int level,
20
		const char *file,
21
		const char *function,
22
		unsigned int line,
23
		const char *fmt,
24
		...) __attribute__((format(printf, 5, 6)));
25
26
#define pr_base(level, ...) pr_helper(level, __FILE__, __func__, __LINE__, __VA_ARGS__)
27
28
#define pr_err(...) pr_base(0, __VA_ARGS__)
29
#define pr_warning(...) pr_base(1, __VA_ARGS__)
30
#define pr_test(...) pr_base(2, __VA_ARGS__)
31
32
#ifdef DEBUG
33
#define pr_info(...) pr_base(3, __VA_ARGS__)
34
#define pr_debug(...) pr_base(4, __VA_ARGS__)
35
#else
36
#define pr_info(...) ({ if (0) pr_base(3, __VA_ARGS__); })
37
#define pr_debug(...) ({ if (0) pr_base(4, __VA_ARGS__); })
38
#endif
39
40
#endif /* LOG_H */