00001 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 #include <stdio.h>
00033 #ifdef _WIN32
00034 #pragma warning(disable:4786)
00035 #endif
00036 
00037 #include <string>
00038 #include <map>
00039 #ifdef WIN32
00040 #include <config-win.h>
00041 #include <mysql.h>
00042 #include <time.h>
00043 #else
00044 #include <mysql/mysql.h>
00045 #endif
00046 
00047 #include "Database.h"
00048 #include "Query.h"
00049 #include "IError.h"
00050 #include "StderrLog.h"
00051 
00052 
00053 #ifdef MYSQLW_NAMESPACE
00054 namespace MYSQLW_NAMESPACE {
00055 #endif
00056 
00057 
00058 void StderrLog::error(Database& db,const std::string& str)
00059 {
00060         time_t t = time(NULL);
00061         struct tm *tp = localtime(&t);
00062         fprintf(stderr,"%d-%02d-%02d %02d:%02d:%02d :: Database: %s\n",
00063                 tp -> tm_year + 1900,tp -> tm_mon + 1,tp -> tm_mday,
00064                 tp -> tm_hour,tp -> tm_min, tp -> tm_sec,
00065                 str.c_str());
00066 }
00067 
00068 
00069 void StderrLog::error(Database& db,Query& q,const std::string& str)
00070 {
00071         time_t t = time(NULL);
00072         struct tm *tp = localtime(&t);
00073         fprintf(stderr,"%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         fprintf(stderr," (QUERY: \"%s\")\n",q.GetLastQuery().c_str());
00078 }
00079 
00080 
00081 #ifdef MYSQLW_NAMESPACE
00082 } 
00083 #endif
00084