Debug.cpp
From Giona
(Difference between revisions)
Line 3: | Line 3: | ||
/**************************************************************************** | /**************************************************************************** | ||
*This class implements the debugging tool. | *This class implements the debugging tool. | ||
+ | * -------------------------------------------------------------------------- | ||
*Author: Rosario Marino | *Author: Rosario Marino | ||
***************************************************************************/ | ***************************************************************************/ | ||
Line 17: | Line 18: | ||
debug_on=true; | debug_on=true; | ||
} | } | ||
+ | |||
+ | /* | ||
+ | * Sets the debug error mode ON | ||
+ | */ | ||
+ | void Debug::setDebugErrorOn() | ||
+ | { | ||
+ | std::cout << "DEBUG ERROR MODE IS ON" <<std::endl; | ||
+ | debug_error_on=true; | ||
+ | } | ||
+ | |||
/* | /* | ||
Line 25: | Line 36: | ||
debug_on=false; | debug_on=false; | ||
} | } | ||
+ | |||
+ | /* | ||
+ | * Sets the debug error mode OFF | ||
+ | */ | ||
+ | void Debug::setDebugErrorOff() | ||
+ | { | ||
+ | debug_error_on=false; | ||
+ | } | ||
+ | |||
/* | /* | ||
Line 37: | Line 57: | ||
} | } | ||
+ | |||
+ | /* | ||
+ | * Debug error message on console | ||
+ | */ | ||
+ | void Debug::debugError(STRING function, STRING error, STRING msg) | ||
+ | { | ||
+ | if(debug_error_on) | ||
+ | { | ||
+ | std::cout << "ERROR: " << time(0) << " -> in function " << function << std::endl; | ||
+ | std::cout << "Error signaled: " << error << std::endl; | ||
+ | std::cout << "- : " << msg << std::endl; | ||
+ | } | ||
+ | } | ||
</pre> | </pre> |
Current revision as of 17:35, 17 December 2007
/**************************************************************************** *This class implements the debugging tool. * -------------------------------------------------------------------------- *Author: Rosario Marino ***************************************************************************/ #include "Debug.h" /* * Sets the debug mode ON */ void Debug::setDebugOn() { std::cout << "DEBUG MODE IS ON" <<std::endl; debug_on=true; } /* * Sets the debug error mode ON */ void Debug::setDebugErrorOn() { std::cout << "DEBUG ERROR MODE IS ON" <<std::endl; debug_error_on=true; } /* * Sets the debug mode OFF */ void Debug::setDebugOff() { debug_on=false; } /* * Sets the debug error mode OFF */ void Debug::setDebugErrorOff() { debug_error_on=false; } /* * Debug message on console */ void Debug::debug(STRING txt) { if(debug_on) { std::cout << "dbg: " << time(0) << " -> " << txt << std::endl; } } /* * Debug error message on console */ void Debug::debugError(STRING function, STRING error, STRING msg) { if(debug_error_on) { std::cout << "ERROR: " << time(0) << " -> in function " << function << std::endl; std::cout << "Error signaled: " << error << std::endl; std::cout << "- : " << msg << std::endl; } }