ICAROUS
All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Modules Pages
Static Public Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
larcfm::Debug Class Reference

#include <Debug.h>

Static Public Member Functions

static void setUserDebugFlag (bool b)
 
static void setVerbose (int level)
 
static void pln (const std::string &tag, const std::string &msg)
 
static void pln2 (const std::string &msg, bool verbose)
 
static void pln (const std::string &msg)
 
static void pln (const std::string &tag, const std::string &msg, bool verbose)
 
static void pln (int lvl, const std::string &tag, const std::string &msg)
 
static void pln (int lvl, const std::string &msg)
 
static void warning (const std::string &tag, const std::string &msg)
 
static void warning (const std::string &msg)
 
static void error (const std::string &msg, bool fail_fast)
 
static void error (const std::string &msg)
 
static void printStack ()
 
static void halt ()
 

Static Private Member Functions

static void output (const std::string &tag, const std::string &msg)
 

Static Private Attributes

static const bool FAIL_FAST
 
static int VERBOSE
 

Detailed Description

This class contains a small set of tools to help in debugging. First is a set of tools to instrument the code each type of instrumentation attempts to address a different type of bug. Any messages go to the Standard output channel. messages come out in the format "<code>&lt;tag&gt; message</code>" so they can easily be found. For errors, the tag is pre-populated with "ERROR!", for warnings the tag is user specified. For Status messages, the tag is optional.

Unfortunately, this implementation every Debug method added still costs execution time, regardless if the given verbosity level means no message will be produced. So Debug.pln(lvl, big-complicated-string-operation) means the big string operation will be computed every time, even when the Debug.pln is never triggered.

Each of these debugging messages approximately means

The main instrumentation methods are

Usage scenarios

Future work

Member Function Documentation

◆ error() [1/2]

static void larcfm::Debug::error ( const std::string &  msg)
static

Output the message msg, indicating that an error has occurred. If in fail-fast mode, then the program will exit (perhaps with a stack trace).

Parameters
msgmessage

◆ error() [2/2]

static void larcfm::Debug::error ( const std::string &  msg,
bool  fail_fast 
)
static

Output the message msg, indicating that an error has occurred.

Parameters
msgmessage
fail_fastif true, then halt program. If false, continue.

◆ halt()

static void larcfm::Debug::halt ( )
static

Indicate than something bad has happened and the program to needs to end now. On some platforms, print backtrace. In general, this method should not be used, use error instead.

◆ pln() [1/3]

static void larcfm::Debug::pln ( const std::string &  msg)
static

Print out a status message msg. The output will only come out if 2 is below the Debug verbosity level. Note: There is a (small) performance penalty for every call, even if the VERBOSE level indicates no message will come out.

Parameters
msgthe status message

◆ pln() [2/3]

static void larcfm::Debug::pln ( const std::string &  tag,
const std::string &  msg 
)
static

Print out a status message msg, with each line prepended with tag. The output will only come out if Debug is in "verbose" mode. Note: There is a (small) performance penalty for every call, even if the VERBOSE level indicates no message will come out.

Parameters
tagthe tag to indicate the location of this debug message.
msgthe status message

◆ pln() [3/3]

static void larcfm::Debug::pln ( const std::string &  tag,
const std::string &  msg,
bool  verbose 
)
static

Print out a status message msg, with each line prepended with tag. The output will only if "verbose" is true.

Parameters
tagthe tag to indicate the location of this debug message.
msgthe status message
verboseif true, then display status message

◆ printStack()

static void larcfm::Debug::printStack ( )
static

backtrace will only work under gcc

◆ setVerbose()

static void larcfm::Debug::setVerbose ( int  level)
static

Set the verbosity level for debuggging

  • 0 - Errors only
  • 1 - Errors and Warnings
  • 2 - Errors, Warnings, and Status
  • >2 - All the above, plus user-specified levels
Parameters
levelverbosity level

◆ warning() [1/2]

static void larcfm::Debug::warning ( const std::string &  msg)
static

Output the msg to the console with the prepended WARNING tag. Warnings are always output and never cause a program termination.

Parameters
msgmessage to indicate what has gone wrong.

◆ warning() [2/2]

static void larcfm::Debug::warning ( const std::string &  tag,
const std::string &  msg 
)
static

Output the msg to the console with the prepended tag. Warnings are always output and never cause a program termination.

Parameters
tagthe tag to indicate the location of this debug message.
msgmessage to indicate what has gone wrong.

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