1 #ifndef TraceFct_h_INCLUDED 2 #define TraceFct_h_INCLUDED 29 #include <Exception/Exception.h> 42 # define _tf_assert(level,ex) \ 46 TraceFct::exit( level, "Assertion failed: file\"%s\", line %d\n%s\n", \ 47 __FILE__, __LINE__, #ex); \ 61 # define TF_ASSERT_LEVEL 71 # define tf_assert(ex) _tf_assert(990,ex) 73 #ifdef TF_ASSERT_LEVEL 74 # if TF_ASSERT_LEVEL > 0 82 # define tf_assert1(ex) _tf_assert(991,ex) 83 # if TF_ASSERT_LEVEL > 1 91 # define tf_assert2(ex) _tf_assert(992,ex) 92 # if TF_ASSERT_LEVEL > 2 100 # define tf_assert3(ex) _tf_assert(993,ex) 101 # if TF_ASSERT_LEVEL > 3 109 # define tf_assert4(ex) _tf_assert(994,ex) 110 # if TF_ASSERT_LEVEL > 4 119 # define tf_assert5(ex) _tf_assert(995,ex) 128 # define tf_assert1(ex) 132 # define tf_assert2(ex) 136 # define tf_assert3(ex) 140 # define tf_assert4(ex) 144 # define tf_assert5(ex) 157 TraceFct(
string name,
bool print_it,
int num_fct_to_print );
160 static void exit (
int exit_code,
const char *format, ...);
161 static void exit (
int exit_code, Exception& ex );
163 static void exit (
int exit_code,
const string& msg)
164 {
exit( exit_code, msg.c_str() ); };
167 static void die (
const char *format, ...);
169 static void die ( Exception& ex )
170 {
exit( EXIT_FAILURE, ex ); }
172 static void die (
const string& msg)
173 {
exit( EXIT_FAILURE, msg ); };
175 static void message (
const char *format, ...);
177 { print(
false, ex ); }
178 static void message (
const string& msg)
181 static void vmessage (
const char *format, va_list args);
184 { print(
true, ex ); }
185 static void println (
const string& msg)
186 { print(
true, msg.c_str() ); }
188 { print(
true, msg ); }
191 static void open(
const string& filename );
192 static void close(
void);
195 static bool print_upon_enter_and_exit;
196 static int stack_level_to_print;
197 static string prefix;
201 static char outbuf[8192];
202 static string progname;
203 static ostream* ostr;
204 static list<string> function_stack;
206 static char* init_prefix(
void );
208 static void vexit_print(
const char* format, va_list args );
209 static void vprint(
bool print_nl,
const char *format, va_list args);
210 static void print(
bool print_nl,
const char *format, ... );
211 static void print(
bool print_nl, Exception& ex );
static void die(const char *format,...)
Exit a program with error EXIT_FAILURE, dumping the function stack.
Definition: TraceFct.cc:452
static void message(Exception &ex)
Print a message to the tracefct output stream.
Definition: TraceFct.h:176
Definition: TraceFct.h:152
static void message(const char *format,...)
Print a formatted message to the tracefct output stream.
Definition: TraceFct.cc:521
TraceFct(const char *name)
Function entry constructor.
Definition: TraceFct.cc:119
static void die(Exception &ex)
Exit a program with error EXIT_FAILURE, dumping the function stack.
Definition: TraceFct.h:169
~TraceFct()
Definition: TraceFct.cc:135
static void dump_stack(void)
Print the current function stack.
Definition: TraceFct.cc:278
static void open(const string &filename)
redirect the tracefct output stream
Definition: TraceFct.cc:604
static void exit(int exit_code, const char *format,...)
Exit a program, dumping the function stack.
Definition: TraceFct.cc:367
static void println(const char *msg)
Print a message to the tracefct output stream.
Definition: TraceFct.h:187
static void vmessage(const char *format, va_list args)
Print a formatted message to the tracefct output stream using a stdargs argument list.
Definition: TraceFct.cc:549
static void println(Exception &ex)
Print a message to the tracefct output stream.
Definition: TraceFct.h:183
static void close(void)
reset the tracefct output stream to stderr.
Definition: TraceFct.cc:652