tracefctxx  1.1.8
TraceFct Class Reference

#include <TraceFct.h>

Public Member Functions

 TraceFct (string &name)
 
 TraceFct (string name, bool print_it, int num_fct_to_print)
 
 ~TraceFct ()
 
 TraceFct (const char *name)
 Function entry constructor. More...
 

Static Public Member Functions

static void exit (int exit_code, const string &msg)
 
static void die (const string &msg)
 
static void message (const string &msg)
 
static void println (const string &msg)
 
static void dump_stack (void)
 Print the current function stack. More...
 
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. More...
 
static void exit (int exit_code, Exception &ex)
 Exit a program, dumping the function stack. More...
 
static void die (const char *format,...)
 Exit a program with error EXIT_FAILURE, dumping the function stack. More...
 
static void die (Exception &ex)
 Exit a program with error EXIT_FAILURE, dumping the function stack. More...
 
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 println functions are similar, except that they ensure that a newline character is appended to the message.

static void message (const char *format,...)
 Print a formatted message to the tracefct output stream. More...
 
static void message (Exception &ex)
 Print a message to the tracefct output stream. More...
 
static void vmessage (const char *format, va_list args)
 Print a formatted message to the tracefct output stream using a stdargs argument list. More...
 
static void println (Exception &ex)
 Print a message to the tracefct output stream. More...
 
static void println (const char *msg)
 Print a message to the tracefct output stream. More...
 
Output Stream manipulation
static void open (const string &filename)
 redirect the tracefct output stream More...
 
static void close (void)
 reset the tracefct output stream to stderr. More...
 

Detailed Description

The TraceFct Class

Constructor & Destructor Documentation

◆ TraceFct()

TraceFct::TraceFct ( const char *  name)

Function entry constructor.

Parameters
namethe name of the function

This constructor is used when entering a function which should be registered.

◆ ~TraceFct()

TraceFct::~TraceFct ( )

The destructor.

Member Function Documentation

◆ close()

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().

◆ die() [1/2]

void TraceFct::die ( const char *  format,
  ... 
)
static

Exit a program with error EXIT_FAILURE, dumping the function stack.

Parameters
formata printf style format string
...additional arguments

◆ die() [2/2]

void TraceFct::die ( Exception &  ex)
inlinestatic

Exit a program with error EXIT_FAILURE, dumping the function stack.

Parameters
exThe Exception Stack to print

This version of the exit function will print out the passed Exception stack.

References exit().

◆ dump_stack()

void TraceFct::dump_stack ( void  )
static

Print the current function stack.

Parameters
ostrthe output file stream

This prints the current function stack to the TraceFct output stream

◆ exit() [1/2]

void TraceFct::exit ( int  exit_code,
const char *  format,
  ... 
)
static

Exit a program, dumping the function stack.

Parameters
exit_codethe exit code to be returned to the system
formata printf style format string
...additional arguments

Referenced by die().

◆ exit() [2/2]

void TraceFct::exit ( int  exit_code,
Exception &  ex 
)
static

Exit a program, dumping the function stack.

Parameters
exit_codethe exit code to be returned to the system
exThe Exception Stack to print

This version of the exit function will print out the passed Exception stack.

◆ message() [1/2]

void TraceFct::message ( const char *  format,
  ... 
)
static

Print a formatted message to the tracefct output stream.

Parameters
formata printf style format string
...additional arguments

The message is passed in the same fashion as the arguments to printf, allowing formatted output.

◆ message() [2/2]

static void TraceFct::message ( Exception &  ex)
inlinestatic

Print a message to the tracefct output stream.

Parameters
exThe exception to print

◆ open()

void TraceFct::open ( const string &  filename)
static

redirect the tracefct output stream

Parameters
filethe file to which messages are to be written

\open serves to change the TraceFct output stream to the specified file. Normally TraceFct writes to 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.

◆ println() [1/2]

static void TraceFct::println ( Exception &  ex)
inlinestatic

Print a message to the tracefct output stream.

Parameters
exthe exception to print

◆ println() [2/2]

static void TraceFct::println ( const char *  msg)
inlinestatic

Print a message to the tracefct output stream.

Parameters
msga message to print

◆ vmessage()

void TraceFct::vmessage ( const char *  format,
va_list  args 
)
static

Print a formatted message to the tracefct output stream using a stdargs argument list.

Parameters
formata printf style string
argsThe 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.

The documentation for this class was generated from the following files: