Flowgrind
Advanced TCP traffic generator
debug.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright (C) 2013 Alexander Zimmermann <alexander.zimmermann@netapp.com>
8  * Copyright (C) 2010-2013 Christian Samsel <christian.samsel@rwth-aachen.de>
9  * Copyright (C) 2009 Tim Kosse <tim.kosse@gmx.de>
10  * Copyright (C) 2007-2008 Daniel Schaffrath <daniel.schaffrath@mac.com>
11  *
12  * This file is part of Flowgrind.
13  *
14  * Flowgrind is free software: you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation, either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * Flowgrind is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with Flowgrind. If not, see <http://www.gnu.org/licenses/>.
26  *
27  */
28 
29 #ifndef _DEBUG_H_
30 #define _DEBUG_H_
31 
32 #ifdef HAVE_CONFIG_H
33 #include "config.h"
34 #endif /* HAVE_CONFIG_H */
35 
36 #ifdef DEBUG
37 
38 #include <limits.h>
39 #include <pthread.h>
40 
49 #define DEBUG_MSG(LVL, MSG, ...) do { \
50  char *timestamp = NULL; \
51  debug_timestamp(&timestamp); \
52  if (debug_level >= LVL) \
53  fprintf(stderr, "%s %s:%d [%d/%d] " MSG "\n", \
54  timestamp, __FUNCTION__, __LINE__, getpid(), \
55  (unsigned)pthread_self()%USHRT_MAX, ##__VA_ARGS__); \
56  free(timestamp); \
57 } while (0)
58 
60 unsigned debug_level;
61 
63 void decrease_debuglevel(void);
64 
66 void increase_debuglevel(void);
67 
78 int debug_timestamp(char **resultp);
79 
80 #else /* DEBUG */
81 
82 #define DEBUG_MSG(LVL, MSG, ...) do {} while(0)
83 
84 #endif /* DEBUG */
85 
86 #endif /* _DEBUG_H_ */
increase_debuglevel
void increase_debuglevel(void)
Decrease debug level.
Definition: debug.c:50
debug_timestamp
int debug_timestamp(char **resultp)
Helper function for DEBUG_MSG macro.
Definition: debug.c:56
decrease_debuglevel
void decrease_debuglevel(void)
Decrease debug level.
Definition: debug.c:44
config.h
debug_level
unsigned debug_level
Global debug level for flowgrind controller and daemon.
Definition: debug.h:60