00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
#include <stdio.h>
00023 #define STL_USING_MAP
00024 #define STL_USING_STRING
00025 #define STL_USING_VECTOR
00026 #define STL_USING_LIST
00027
#include "stlhelper.h"
00028
#ifdef _WIN32
00029
#pragma warning(disable:4786)
00030
#endif
00031
00032
#include <string>
00033
#include <map>
00034
#ifdef WIN32
00035
#include <config-win.h>
00036
#include <mysql.h>
00037
#include <time.h>
00038
#else
00039
#include <mysql/mysql.h>
00040
#endif
00041
00042
#include "MyErrlog.h"
00043
00044
00045 #define D2(x) { \
00046
FILE *fil = fopen("c:\\deb.log","at"); \
00047
x; \
00048
fclose(fil); \
00049
}
00050
00051
00052 void MyErrlog::error(Database& ,
const std::string& str)
00053 {
00054 time_t t = time(NULL);
00055
struct tm *tp = localtime(&t);
00056
char errstr[1000];
00057 sprintf(errstr,
"%d-%02d-%02d %02d:%02d:%02d :: Database: %s\n",
00058 tp -> tm_year + 1900,tp -> tm_mon + 1,tp -> tm_mday,
00059 tp -> tm_hour,tp -> tm_min, tp -> tm_sec,
00060 str.c_str());
00061
#ifdef _DEBUG
00062
::MessageBox(NULL, errstr,
"MySQL", MB_OK);
00063
#endif
00064
D2(fprintf(fil,
"%s",errstr);)
00065 }
00066
00067
00068 void MyErrlog::error(Database& ,Query& q,
const std::string& str)
00069 {
00070 time_t t = time(NULL);
00071
struct tm *tp = localtime(&t);
00072
char errstr[1000];
00073 sprintf(errstr,
"%d-%02d-%02d %02d:%02d:%02d :: Query: %s: %s(%d)\n",
00074 tp -> tm_year + 1900,tp -> tm_mon + 1,tp -> tm_mday,
00075 tp -> tm_hour,tp -> tm_min, tp -> tm_sec,
00076 str.c_str(),q.GetError().c_str(),q.GetErrno());
00077 sprintf(errstr + strlen(errstr),
" (QUERY: \"%s\")\n",q.GetLastQuery().c_str());
00078
#ifdef _DEBUG
00079
::MessageBox(NULL, errstr,
"MySQL", MB_OK);
00080
#endif
00081
D2(fprintf(fil,
"%s",errstr);)
00082 }
00083
00084