00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "LOW_exception.h"
00020 #include "LOW_helper_msglog.h"
00021
00022
00023
00024
00025
00026
00027
00028 bool LOW_exception::logOnCreation = false;
00029
00030
00031
00032
00033
00034
00035
00036 LOW_exception::LOW_exception() :
00037 errNum( 0),
00038 message( "")
00039 {
00040 }
00041
00042 LOW_exception::LOW_exception( const std::string inMsg, const std::string inFile, const int inLine) :
00043 errNum( 0),
00044 message( inMsg),
00045 file( inFile),
00046 line( inLine)
00047 {
00048 if ( logOnCreation )
00049 logException( "[auto-logged on creation] ");
00050 }
00051
00052 LOW_exception::LOW_exception( const int inErrNum, const std::string inMsg, const std::string inFile, const int inLine) :
00053 errNum( inErrNum),
00054 message( inMsg),
00055 file( inFile),
00056 line( inLine)
00057 {
00058 if ( logOnCreation )
00059 logException( "[auto-logged on creation] ");
00060 }
00061
00062 LOW_exception::~LOW_exception()
00063 {
00064 }
00065
00066
00067
00068
00069
00070
00071
00072 void LOW_exception::setLogOnCreation( const bool inLogOnCreation)
00073 {
00074 logOnCreation = inLogOnCreation;
00075 }
00076
00077
00078 bool LOW_exception::getLogOnCreation()
00079 {
00080 return logOnCreation;
00081 }
00082
00083
00084
00085
00086
00087
00088
00089 void LOW_exception::logException( const std::string inPrefix)
00090 {
00091 if ( errNum == 0 )
00092 LOW_helper_msglog::printError( "%s%s {file: %s, line: %d}", inPrefix.c_str(), message.c_str(), file.c_str(), line);
00093 else
00094 LOW_helper_msglog::printPerror( errNum, "%s%s {file: %s, line: %d}", inPrefix.c_str(), message.c_str(), file.c_str(), line);
00095 }