00001
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00031 #define LOG4SENDPP_NEED_EXPORTS
00032 #include <log4sendpp/log4sendpp.h>
00033
00034 #include <iostream>
00035
00036
00037 LOG4SENDPP_NS_START
00038
00039
00040 LOG4SENDPP_API_IMPL(void)
00041 getVersion (int &major, int &minor, int &patch,
00042 bool &debug, LOG4SENDPP_STD_NS::string &info)
00043 {
00044 LOG4SENDPP_STD_NS::string s = LOG4SENDPP_VERSION;
00045 LOG4SENDPP_STD_NS::string num;
00046 info = "";
00047
00048 LOG4SENDPP_STD_NS::size_t pos = s.find('.');
00049 bool good = true;
00050 if (pos != LOG4SENDPP_STD_NS::string::npos)
00051 {
00052 num = s.substr(0, pos);
00053 if (num.length() == 0)
00054 good = false;
00055 #ifdef _MSC_VER_60_70
00056 major = atoi(num.c_str());
00057 #else
00058 major = LOG4SENDPP_STD_NS::atoi(num.c_str());
00059 #endif
00060 s.erase(0, pos+1);
00061 pos = s.find('.');
00062
00063 if (pos != LOG4SENDPP_STD_NS::string::npos)
00064 {
00065 num = s.substr(0, pos);
00066 if (num.length() == 0)
00067 good = false;
00068 #ifdef _MSC_VER_60_70
00069 minor = atoi(num.c_str());
00070 #else
00071 minor = LOG4SENDPP_STD_NS::atoi(num.c_str());
00072 #endif
00073 s.erase(0, pos+1);
00074
00075 if (s.length() == 0)
00076 good = false;
00077 #ifdef _MSC_VER_60_70
00078 patch = atoi(s.c_str());
00079 #else
00080 patch = LOG4SENDPP_STD_NS::atoi(s.c_str());
00081 #endif
00082 }
00083 else
00084 good = false;
00085 }
00086 else
00087 good = false;
00088
00089 if (!good)
00090 {
00091 major = -1;
00092 minor = -1;
00093 patch = -1;
00094 info = "";
00095 }
00096
00097 #ifdef DEBUG
00098 debug = true;
00099 #else
00100 debug = false;
00101 #endif
00102 }
00103
00104
00108 void defaultFailureHandler(unsigned srcline,
00109 const LOG4SENDPP_STD_NS::string &srcfile,
00110 const LOG4SENDPP_STD_NS::string &message)
00111 {
00112 LOG4SENDPP_STD_NS::cout << "A failure has happened in " << srcfile << ", " << srcline << ":\n"
00113 << message << LOG4SENDPP_STD_NS::endl;
00114
00115 }
00116
00117
00121 static FailureHandler handlerptr = defaultFailureHandler;
00122
00123
00124 LOG4SENDPP_API_IMPL(void)
00125 handleFailure(unsigned srcline,
00126 const LOG4SENDPP_STD_NS::string &srcfile,
00127 const LOG4SENDPP_STD_NS::string &message)
00128 {
00129 (*handlerptr)(srcline, srcfile, message);
00130 }
00131
00132
00133 LOG4SENDPP_API_IMPL(FailureHandler) setFailureHandler(FailureHandler handler)
00134 {
00135 FailureHandler temp = handlerptr;
00136 handlerptr = handler;
00137 return temp;
00138 }
00139
00140
00141 LOG4SENDPP_NS_END
00142
00143
00144
00145