![]() |
TerraLib 4.1
|
This file contains a set of macros, routines and classes to deal with system checking and logging facility. They should NOT be used by anyone because the support and interfaces can be changed in future. THIS IS FOR INTERNAL USE ONLY. More...
#include <sstream>#include <string>#include <iostream>#include "TeException.h"#include "TeErrorLog.h"Go to the source code of this file.
Namespaces | |
| namespace | TeAgnostic |
This namespace contains a set of routines and classes to deal with system checking and logging facility. | |
Defines | |
| #define | TEAGN_DEBUG_MODE |
| TeAgnostic debug mode selection based on NDEBUG define. | |
| #define | TEAGN_ENABLE_STDOUT_LOG |
| STDOUT logging selection flag. | |
| #define | TEAGN_LOGMSG_STDOUT(message) |
| Logs a message to stdout. | |
| #define | TEAGN_LOGERR_STDOUT(message) |
| Logs a error message to stderr. | |
| #define | TEAGN_LOGWARN_STDOUT(message) |
| Logs a warning message to stdout. | |
| #define | TEAGN_LOGMSG(message) |
| Logs a message. | |
| #define | TEAGN_LOGERR(message) |
| Logs a message. | |
| #define | TEAGN_LOGWARN(message) |
| Logs a warning message. | |
| #define | TEAGN_LOG_AND_THROW(message) |
| Logs a message to stderr and throws. | |
| #define | TEAGN_TRUE_OR_THROW(value, message) |
| Checks if value is true and throws an exception if not. | |
| #define | TEAGN_WATCH(variable) |
| Variable watching. | |
| #define | TEAGN_TRUE_OR_LOG(value, message) |
| Checks if value is true and logs an warning message if not. | |
| #define | TEAGN_TRUE_OR_RETURN(value, message) |
| Checks if value is true. For false values a warning message will be logged and a return of context with false value will be done. | |
| #define | TEAGN_FALSE_OR_RETURN(value, message) |
| Checks if value is false. For true values a warning message will be logged and a return of context with false value will be done. | |
| #define | TEAGN_LOG_AND_RETURN(message) |
| Logs a warning message will and return false. | |
| #define | TEAGN_FALSE_OR_LOG(value, message) |
| Checks if value is false and logs an warning message if not. | |
| #define | TEAGN_CHECK_EQUAL(value1, value2, message) |
| Checks if two values are equal and throws an exception if not. | |
| #define | TEAGN_CHECK_NOTEQUAL(value1, value2, message) |
| Checks if two values are diferent and throws an exception if not. | |
| #define | TEAGN_CHECK_EPS(value1, value2, eps, message) |
| Checks if two values are equal ( within an EPS ) and throws an exception if not. | |
| #define | TEAGN_NOT_IMPLEMENTED TEAGN_LOG_AND_THROW( "Not Implemented." ); |
| Throws an exception for not implemented source. | |
| #define | TEAGN_DEBUG_MODE_CHECK |
| Checks if Debug mode is enabled and throws an exception if not. | |
| #define | TEAGN_DEBUG_CONDITION(value, message) TEAGN_TRUE_OR_THROW( value , message ); |
| Checks if value is true and throws an exception if not. | |
| #define | TEAGN_DEBUG_RETURN(value, message) TEAGN_TRUE_OR_RETURN( value , message ); |
| Checks if value is true. For false values a warning message will be logged and a return of context with false value will be done. | |
Functions | |
| template<class T > | |
| std::string | TeAgnostic::to_string (const T &data) |
| Data conversion to string. | |
| bool | TeAgnostic::debugModeCheck () |
| Checks if the code was compiled with debug mode. | |
This file contains a set of macros, routines and classes to deal with system checking and logging facility. They should NOT be used by anyone because the support and interfaces can be changed in future. THIS IS FOR INTERNAL USE ONLY.
| TEAGN_DEBUG_MODE | If defined, debug code macros will be compiled and used or if not defined the compiler debug flag will be used. |
| TEAGN_ENABLE_STDOUT_LOG | If defined, messages also will be logged to STDOUT ( otherwise only TeErrorLog will log messages ) or if not defined the compiler debug flag will be used. |
| #define TEAGN_CHECK_EPS | ( | value1, | |
| value2, | |||
| eps, | |||
| message | |||
| ) |
Checks if two values are equal ( within an EPS ) and throws an exception if not.
| value1 | Value to be checked. |
| value2 | Value to be checked. |
| eps | EPS ( threshold ) |
| message | Message to be logged. |
| #define TEAGN_CHECK_EQUAL | ( | value1, | |
| value2, | |||
| message | |||
| ) |
TEAGN_TRUE_OR_THROW( ( ((double)( value1 ) ) == ((double)( value2 ) ) ), \ std::string( "Values must be equal [" ) + \ TeAgnostic::to_string( value1 ) + "!=" + \ TeAgnostic::to_string( value2 ) + "] - " + \ TeAgnostic::to_string( message ) );
Checks if two values are equal and throws an exception if not.
| value1 | Value to be checked. |
| value2 | Value to be checked. |
| message | Message to be logged. |
| #define TEAGN_CHECK_NOTEQUAL | ( | value1, | |
| value2, | |||
| message | |||
| ) |
TEAGN_TRUE_OR_THROW( ( ((double)( value1 )) != ((double)( value2 )) ), \ std::string( "Values can't be equal [" ) + \ TeAgnostic::to_string( #value1 ) + std::string( "==" ) + \ TeAgnostic::to_string( #value2 ) + std::string( "==" ) + \ TeAgnostic::to_string( value1 ) + std::string( "]" ) );
Checks if two values are diferent and throws an exception if not.
| value1 | Value to be checked. |
| value2 | Value to be checked. |
| message | Message to be logged. |
Checks if value is true and throws an exception if not.
| value | Value to be checked. |
| message | Message to be logged. |
| #define TEAGN_DEBUG_MODE |
TeAgnostic debug mode selection based on NDEBUG define.
Debug mode selection flag.
| #define TEAGN_DEBUG_MODE_CHECK |
TEAGN_TRUE_OR_THROW( TeAgnostic::debugModeCheck() , \ "Code not compiled with debug" );
Checks if Debug mode is enabled and throws an exception if not.
Checks if value is true. For false values a warning message will be logged and a return of context with false value will be done.
| value | Value to be checked. |
| message | Message to be logged. |
| #define TEAGN_ENABLE_STDOUT_LOG |
STDOUT logging selection flag.
| #define TEAGN_FALSE_OR_LOG | ( | value, | |
| message | |||
| ) |
if( ( value ) != 0 ) { \ TEAGN_LOGWARN( TeAgnostic::to_string( message ) + \ " - " + TeAgnostic::to_string( #value ) ); \ };
Checks if value is false and logs an warning message if not.
| value | Value to be checked. |
| message | Message to be logged. |
| #define TEAGN_FALSE_OR_RETURN | ( | value, | |
| message | |||
| ) |
if( ( value ) != 0 ) { \ TEAGN_LOGWARN( TeAgnostic::to_string( message ) + \ " - " + TeAgnostic::to_string( #value ) ); \ return false; \ };
Checks if value is false. For true values a warning message will be logged and a return of context with false value will be done.
| value | Value to be checked. |
| message | Message to be logged. |
| #define TEAGN_LOG_AND_RETURN | ( | message | ) |
{ \
TEAGN_LOGWARN( message ); \
return false; \
};
Logs a warning message will and return false.
| message | Message to be logged. |
| #define TEAGN_LOG_AND_THROW | ( | message | ) |
{ \
TEAGN_LOGERR_STDOUT( message ); \
throw TeException( UNKNOWN_ERROR_TYPE, \
TeAgnostic::to_string( message ), false ); \
};
Logs a message to stderr and throws.
| message | Message to be logged. |
| #define TEAGN_LOGERR | ( | message | ) |
{ \
TeErrorLog::instance().insert( UNKNOWN_ERROR_TYPE, \
TeAgnostic::to_string( message ) ); \
TEAGN_LOGERR_STDOUT( message ); \
};
Logs a message.
| message | Message to be logged. |
| #define TEAGN_LOGERR_STDOUT | ( | message | ) |
std::cerr << std::endl << "Error : " \ << __FILE__ \ << ":" << __LINE__ \ << " - " << TeAgnostic::to_string( message ) \ << std::endl;
Logs a error message to stderr.
| message | Message to be logged. |
| #define TEAGN_LOGMSG | ( | message | ) |
{ \
TeErrorLog::instance().insert( LOG_MESSAGE, \
TeAgnostic::to_string( message ) ); \
TEAGN_LOGMSG_STDOUT( message ); \
};
Logs a message.
| message | Message to be logged. |
| #define TEAGN_LOGMSG_STDOUT | ( | message | ) |
std::cout << std::endl << "Message : " \ << __FILE__ \ << ":" << __LINE__ \ << " - " << TeAgnostic::to_string( message ) \ << std::endl;
Logs a message to stdout.
| message | Message to be logged. |
| #define TEAGN_LOGWARN | ( | message | ) |
{ \
TeErrorLog::instance().insert( LOG_MESSAGE, \
TeAgnostic::to_string( message ) ); \
TEAGN_LOGWARN_STDOUT( message ); \
};
Logs a warning message.
| message | Message to be logged. |
| #define TEAGN_LOGWARN_STDOUT | ( | message | ) |
std::cout << std::endl << "Warning : " \ << __FILE__ \ << ":" << __LINE__ \ << " - " << TeAgnostic::to_string( message ) \ << std::endl;
Logs a warning message to stdout.
| message | Message to be logged. |
| #define TEAGN_NOT_IMPLEMENTED TEAGN_LOG_AND_THROW( "Not Implemented." ); |
Throws an exception for not implemented source.
| #define TEAGN_TRUE_OR_LOG | ( | value, | |
| message | |||
| ) |
if( ( value ) == 0 ) { \ TEAGN_LOGWARN( TeAgnostic::to_string( message ) + \ " - " + TeAgnostic::to_string( #value ) ); \ };
Checks if value is true and logs an warning message if not.
| value | Value to be checked. |
| message | Message to be logged. |
| #define TEAGN_TRUE_OR_RETURN | ( | value, | |
| message | |||
| ) |
if( ( value ) == 0 ) { \ TEAGN_LOGWARN( TeAgnostic::to_string( message ) + \ " - " + TeAgnostic::to_string( #value ) ); \ return false; \ };
Checks if value is true. For false values a warning message will be logged and a return of context with false value will be done.
| value | Value to be checked. |
| message | Message to be logged. |
| #define TEAGN_TRUE_OR_THROW | ( | value, | |
| message | |||
| ) |
if( ( value ) == 0 ) { \ TEAGN_LOGERR_STDOUT( TeAgnostic::to_string( message ) + \ " - " + TeAgnostic::to_string( #value ) ); \ throw TeException( UNKNOWN_ERROR_TYPE, \ TeAgnostic::to_string( message ), false ); \ };
Checks if value is true and throws an exception if not.
| value | Value to be checked. |
| message | Message to be logged. |
| #define TEAGN_WATCH | ( | variable | ) |
{ \
TEAGN_LOGMSG( "WATCH - " + TeAgnostic::to_string( #variable ) + \
"=[" + TeAgnostic::to_string( variable ) +"]" ); \
};
Variable watching.
| variable | Variable to be logged. |