#include <TraceFct.h>
Public Member Functions | |
TraceFct (string name, bool print_it, int num_fct_to_print) | |
Class initializer. | |
~TraceFct () | |
TraceFct (const char *name) | |
Function entry constructor. | |
TraceFct (string &name) | |
Function entry constructor. | |
Static Public Member Functions | |
static void | dump_stack (void) |
Print the current function stack. | |
Exit | |
These functions print an error message to stderr as well as the tracefct output stream (if different from stderr ) and then exits the program with the supplied error code. The error message is passed in the same fashion as the arguments to vprintf or sprintf . The message may contain multiple output lines (i.e., multiple newline characters). If a trailing newline character is not specified, it will be appended. | |
static void | exit (int exit_code, const char *format,...) |
Exit a program, dumping the function stack. | |
static void | exit (int exit_code, Exception &ex) |
Exit a program, dumping the function stack. | |
static void | exit (int exit_code, const string &msg) |
Exit a program, dumping the function stack. | |
static void | die (const char *format,...) |
Exit a program with error EXIT_FAILURE, dumping the function stack. | |
static void | die (Exception &ex) |
Exit a program with error EXIT_FAILURE, dumping the function stack. | |
static void | die (const string &msg) |
Exit a program with error EXIT_FAILURE, dumping the function stack. | |
Messages | |
The message functions print a user supplied message to the TraceFct output stream, prefixed by the standard TraceFct style prefix string. Unlike TraceFct::exit(), a newline character is not appended to the message.
The | |
static void | message (const char *format,...) |
Print a formatted message to the tracefct output stream. | |
static void | message (Exception &ex) |
Print a message to the tracefct output stream. | |
static void | message (const string &msg) |
Print a message to the tracefct output stream. | |
static void | vmessage (const char *format, va_list args) |
Print a formatted message to the tracefct output stream using a stdargs argument list. | |
static void | println (Exception &ex) |
Print a message to the tracefct output stream. | |
static void | println (const string &msg) |
Print a message to the tracefct output stream. | |
static void | println (const char *msg) |
Print a message to the tracefct output stream. | |
Output Stream manipulation | |
static void | open (const string &filename) |
redirect the tracefct output stream | |
static void | close (void) |
reset the tracefct output stream to stderr . |
Definition at line 155 of file TraceFct.h.
TraceFct::TraceFct | ( | const char * | name | ) |
Function entry constructor.
name | the name of the function |
Definition at line 122 of file TraceFct.cc.
References message().
TraceFct::TraceFct | ( | string & | name | ) |
Function entry constructor.
name | the name of the function |
Definition at line 106 of file TraceFct.cc.
References message().
TraceFct::TraceFct | ( | string | prog_name, | |
bool | print_it, | |||
int | num_fct_to_print | |||
) |
Class initializer.
This initializer should be used to initialize the class, and should be called once in the program, before any subsequent calls to the per-function initializers
name | the name of the program, preferrably argv[0]. path information (if present) is not stripped. | |
print_it | if true, a message will be output upon entry and exit of a function | |
num_fct_to_print | if positive, only the requested number of function names will be printed. if non-positive, all of the function names will be printed. |
Definition at line 80 of file TraceFct.cc.
TraceFct::~TraceFct | ( | ) |
void TraceFct::exit | ( | int | exit_code, | |
const char * | format, | |||
... | ||||
) | [static] |
Exit a program, dumping the function stack.
exit_code | the exit code to be returned to the system | |
format | a printf style format string | |
... | additional arguments |
Definition at line 361 of file TraceFct.cc.
void TraceFct::exit | ( | int | exit_code, | |
Exception & | ex | |||
) | [static] |
Exit a program, dumping the function stack.
exit_code | the exit code to be returned to the system | |
ex | The Exception Stack to print |
Exception
stack.
Definition at line 398 of file TraceFct.cc.
References dump_stack().
static void TraceFct::exit | ( | int | exit_code, | |
const string & | msg | |||
) | [inline, static] |
Exit a program, dumping the function stack.
exit_code | the exit code to be returned to the system | |
msg | a message to print |
Definition at line 166 of file TraceFct.h.
References exit().
void TraceFct::die | ( | const char * | format, | |
... | ||||
) | [static] |
Exit a program with error EXIT_FAILURE, dumping the function stack.
format | a printf style format string | |
... | additional arguments |
Definition at line 446 of file TraceFct.cc.
void TraceFct::die | ( | Exception & | ex | ) | [inline, static] |
Exit a program with error EXIT_FAILURE, dumping the function stack.
ex | The Exception Stack to print |
Exception
stack.
Definition at line 172 of file TraceFct.h.
References exit().
void TraceFct::die | ( | const string & | msg | ) | [inline, static] |
Exit a program with error EXIT_FAILURE, dumping the function stack.
msg | a message to print |
Definition at line 175 of file TraceFct.h.
References exit().
void TraceFct::message | ( | const char * | format, | |
... | ||||
) | [static] |
Print a formatted message to the tracefct
output stream.
format | a printf style format string | |
... | additional arguments |
printf
, allowing formatted output. Definition at line 515 of file TraceFct.cc.
Referenced by dump_stack(), message(), TraceFct(), and ~TraceFct().
static void TraceFct::message | ( | Exception & | ex | ) | [inline, static] |
Print a message to the tracefct
output stream.
ex | The exception to print |
Definition at line 179 of file TraceFct.h.
static void TraceFct::message | ( | const string & | msg | ) | [inline, static] |
Print a message to the tracefct
output stream.
msg | a message to print |
Definition at line 181 of file TraceFct.h.
References message().
void TraceFct::vmessage | ( | const char * | format, | |
va_list | args | |||
) | [static] |
Print a formatted message to the tracefct
output stream using a stdargs
argument list.
format | a printf style string | |
args | q The error message is passed in the same fashion as the arguments to vprintf . Note that vmessage expects a va_list to be passed, rather than a variable argument list. |
Definition at line 543 of file TraceFct.cc.
static void TraceFct::println | ( | Exception & | ex | ) | [inline, static] |
Print a message to the tracefct
output stream.
ex | the exception to print |
Definition at line 186 of file TraceFct.h.
static void TraceFct::println | ( | const string & | msg | ) | [inline, static] |
Print a message to the tracefct
output stream.
msg | a message to print |
Definition at line 188 of file TraceFct.h.
static void TraceFct::println | ( | const char * | msg | ) | [inline, static] |
Print a message to the tracefct
output stream.
msg | a message to print |
Definition at line 190 of file TraceFct.h.
void TraceFct::dump_stack | ( | void | ) | [static] |
void TraceFct::open | ( | const string & | file | ) | [static] |
redirect the tracefct
output stream
file | the file to which messages are to be written |
stderr
. TraceFct::exit() always writes to stderr
. To reset the output stream, see TraceFct::close(). If the current output stream is not stderr
, it is automatically closed.
If the passed filename is the string stderr
, open() will use stderr
.
Upon error, it writes and exit to stderr
and exits.
Definition at line 598 of file TraceFct.cc.
void TraceFct::close | ( | void | ) | [static] |
reset the tracefct
output stream to stderr
.
close() resets the output stream to stderr
, closing the file previously opened by TraceFct::open().
Definition at line 646 of file TraceFct.cc.