Google
Web alhem.net
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

MyErrlog.cpp

Go to the documentation of this file.
00001 00005 /* 00006 Copyright (C) 2004 Anders Hedström (grymse@alhem.net) 00007 00008 This program is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU General Public License 00010 as published by the Free Software Foundation; either version 2 00011 of the License, or (at your option) any later version. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program; if not, write to the Free Software 00020 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 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

Generated on Thu Feb 10 22:42:34 2005 for Distributed URL Classification Tool by doxygen 1.3.7