cctools
debug.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2003-2004 Douglas Thain and the University of Wisconsin
3 Copyright (C) 2005- The University of Notre Dame
4 This software is distributed under the GNU General Public License.
5 See the file COPYING for details.
6 */
7 
8 #ifndef DEBUG_H
9 #define DEBUG_H
10 
35 #include "int_sizes.h"
36 
37 #include <unistd.h>
38 
39 #include <sys/types.h>
40 
41 #include <stdarg.h>
42 #include <stdio.h>
43 
44 /* priority */
45 #define D_INFO (0LL)
46 #define D_FATAL (1LL<<0)
47 #define D_ERROR (1LL<<1)
48 #define D_NOTICE (1LL<<2)
49 #define D_DEBUG (1LL<<3)
51 /* subsystem */
52 #define D_SYSCALL (1LL<<4)
53 #define D_CHANNEL (1LL<<5)
54 #define D_PROCESS (1LL<<6)
55 #define D_RESOLVE (1LL<<7)
56 #define D_LIBCALL (1LL<<8)
57 #define D_LOCAL (1LL<<9)
58 #define D_DNS (1LL<<10)
59 #define D_TCP (1LL<<11)
60 #define D_AUTH (1LL<<12)
61 #define D_IRODS (1LL<<13)
62 #define D_CVMFS (1LL<<14)
63 #define D_HTTP (1LL<<15)
64 #define D_FTP (1LL<<16)
65 #define D_NEST (1LL<<17)
66 #define D_GROW (1LL<<18)
67 #define D_CHIRP (1LL<<19)
68 #define D_DCAP (1LL<<20)
69 #define D_RFIO (1LL<<21)
70 #define D_GLITE (1LL<<22)
71 #define D_MULTI (1LL<<23)
72 #define D_PSTREE (1LL<<24)
73 #define D_ALLOC (1LL<<25)
74 #define D_LFC (1LL<<26)
75 #define D_GFAL (1LL<<27)
76 #define D_SUMMARY (1LL<<28)
77 #define D_LOGIN (1LL<<29)
78 #define D_CACHE (1LL<<30)
79 #define D_POLL (1LL<<31)
80 #define D_HDFS (1LL<<32)
81 #define D_WQ (1LL<<33)
82 #define D_BXGRID (1LL<<34)
83 #define D_USER (1LL<<35)
84 #define D_XROOTD (1LL<<36)
85 #define D_MPI (1LL<<37)
86 #define D_BATCH (1LL<<38)
87 #define D_RMON (1LL<<39)
88 #define D_MAKEFLOW_RUN (1LL<<40)
89 #define D_MAKEFLOW_LEXER (1LL<<41)
90 #define D_MAKEFLOW_PARSER (1LL<<42)
91 #define D_MAKEFLOW_ALLOC (1LL<<43)
92 #define D_CONFUGA (1LL<<44)
93 #define D_JX (1LL<<45)
94 #define D_MAKEFLOW_HOOK (1LL<<46)
97 #define D_REMOTE (D_HTTP|D_FTP|D_NEST|D_CHIRP|D_DCAP|D_RFIO|D_LFC|D_GFAL|D_MULTI|D_GROW|D_IRODS|D_HDFS|D_BXGRID|D_XROOTD|D_CVMFS)
98 
100 #define D_MAKEFLOW (D_MAKEFLOW_RUN|D_MAKEFLOW_LEXER|D_MAKEFLOW_PARSER)
101 
103 #define D_ALL (~(0LL))
104 
105 /*
106 It turns out that many libraries and tools make use of symbols like "debug" and
107 "fatal". This causes strange failures when we link against such codes. Rather
108 than change all of our code, we simply insert these defines to transparently
109 modify the linker namespace we are using.
110 */
111 
112 #define debug cctools_debug
113 #define fatal cctools_fatal
114 #define notice cctools_notice
115 #define warn cctools_warn
116 #define debug_config cctools_debug_config
117 #define debug_config_file cctools_debug_config_file
118 #define debug_config_file_size cctools_debug_config_file_size
119 #define debug_config_fatal cctools_debug_config_fatal
120 #define debug_config_getpid cctools_debug_config_getpid
121 #define debug_flags_set cctools_debug_flags_set
122 #define debug_flags_print cctools_debug_flags_print
123 #define debug_flags_clear cctools_debug_flags_clear
124 #define debug_flags_restore cctools_debug_flags_restore
125 #define debug_set_flag_name cctools_debug_set_flag_name
126 #define debug_rename cctools_debug_rename
127 
134 void debug(INT64_T flags, const char *fmt, ...)
135 #ifndef SWIG
136 __attribute__ (( format(printf,2,3) ))
137 #endif
138 ;
139 
147 void vdebug(INT64_T flags, const char *fmt, va_list args);
148 
155 void warn(INT64_T flags, const char *fmt, ...);
156 
162 void fatal(const char *fmt, ...);
163 
164 
170 void notice(INT64_T flags, const char *fmt, ...);
171 
177 void debug_config(const char *name);
178 
185 void debug_config_file(const char *file);
186 
187 int debug_config_file_e(const char *file);
188 
196 void debug_config_file_size(off_t size);
197 
198 void debug_config_fatal(void (*callback) (void));
199 
200 void debug_config_getpid (pid_t (*getpidf)(void));
201 
210 int debug_flags_set(const char *flagname);
211 
218 void debug_flags_print(FILE * stream);
219 
225 INT64_T debug_flags_clear(void);
226 
233 void debug_set_flag_name(INT64_T flag, const char *name);
234 
238 void debug_flags_restore(INT64_T flags);
239 
243 void debug_rename(const char *suffix);
244 
247 void debug_reopen(void);
248 
249 /* LDEBUG likes debug, but also print the code location.
250  * NOTE: the caller of this macro must supply at least one argument after the format string.
251  */
252 #define LDEBUG(fmt, ...) debug(D_DEBUG, "%s:%s:%d[%s]: " fmt, __func__, __FILE__, __LINE__, CCTOOLS_SOURCE, __VA_ARGS__)
253 
254 #endif
void debug_flags_print(FILE *stream)
Display the available debug flags.
void notice(INT64_T flags, const char *fmt,...)
Emit a notice message.
void debug_rename(const char *suffix)
Rename debug file with given suffix.
void debug_flags_restore(INT64_T flags)
Restore debug flags.
void fatal(const char *fmt,...)
Emit a fatal debugging message and terminate with SIGTERM.
void void vdebug(INT64_T flags, const char *fmt, va_list args)
Emit a debugging message.
int debug_flags_set(const char *flagname)
Set debugging flags to enable output.
void warn(INT64_T flags, const char *fmt,...)
Emit a warning message.
void debug_config_file_size(off_t size)
Set the maximum debug file size.
void debug_config_file(const char *file)
Direct debug output to a file.
void debug(INT64_T flags, const char *fmt,...) __attribute__((format(printf
Emit a debugging message.
void debug_config(const char *name)
Initialize the debugging system.
void debug_set_flag_name(INT64_T flag, const char *name)
Set name of flag combination Sets the string value associated with flag.
INT64_T debug_flags_clear(void)
Clear all debugging flags.
void debug_reopen(void)
Reopen the debug stream.