Add logging macros.
[tairon.git] / src / core / log.h
blob769bcc29a28cfb4333c5bf76b4a163fea9216046
1 /***************************************************************************
2 * *
3 * Copyright (C) 2006 David Brodsky *
4 * *
5 * This library is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU Library General Public *
7 * License as published by the Free Software Foundation and appearing *
8 * in the file LICENSE.LGPL included in the packaging of this file. *
9 * *
10 * This library 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 GNU *
13 * Library General Public License for more details. *
14 * *
15 ***************************************************************************/
17 #ifndef _tairon_core_log_h
18 #define _tairon_core_log_h
20 #include <cstdio>
22 #ifndef LOGLEVEL
23 #define LOGLEVEL 0
24 #endif
26 #if LOGLEVEL >= 0
27 #define ERROR(x) printf("Error (" __FILE__ ":%d) %s\n", __LINE__, x)
28 #else
29 #define ERROR(x) {}
30 #endif
32 #if LOGLEVEL >= 1
33 #define WARNING(x) printf("Warning (" __FILE__ ":%d) %s\n", __LINE__, x)
34 #else
35 #define WARNING(x) {}
36 #endif
38 #if LOGLEVEL >= 2
39 #define INFO(x) printf("Info (" __FILE__ ":%d) %s\n", __LINE__, x)
40 #else
41 #define INFO(x) {}
42 #endif
44 #if LOGLEVEL >= 3
45 #define DEBUG(x) printf("Debug (" __FILE__ ":%d) %s\n", __LINE__, x)
46 #else
47 #define DEBUG(x) {}
48 #endif
50 #endif
52 // vim: ai sw=4 ts=4 noet fdm=marker