Logo
~Database~
~ C++ ~
~Contact~

StderrLog.cpp

Go to the documentation of this file.
00001 /*
00002  **     StderrLog.cpp
00003  **
00004  **     Published / author: 2004-08-18 / grymse@alhem.net
00005  **/
00006 /*
00007 Copyright (C) 2004 Anders Hedstrom
00008 
00009 This program is free software; you can redistribute it and/or
00010 modify it under the terms of the GNU General Public License
00011 as published by the Free Software Foundation; either version 2
00012 of the License, or (at your option) any later version.
00013 
00014 This program is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00017 GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with this program; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00022 */
00023 #include <stdio.h>
00024 #ifdef _WIN32
00025 #pragma warning(disable:4786)
00026 #endif
00027 
00028 #include <afxdb.h>
00029 #include <sql.h>
00030 
00031 #include "IError.h"
00032 #include "StderrLog.h"
00033 #include "Query.h"
00034 
00035 
00036 #ifdef ODBCW_NAMESPACE
00037 namespace ODBCW_NAMESPACE {
00038 #endif
00039 
00040 
00041 void StderrLog::error(Database& db,const std::string& str)
00042 {
00043         time_t t = time(NULL);
00044         struct tm *tp = localtime(&t);
00045         fprintf(stderr,"%d-%02d-%02d %02d:%02d:%02d :: Database: %s\n",
00046                 tp -> tm_year + 1900,tp -> tm_mon + 1,tp -> tm_mday,
00047                 tp -> tm_hour,tp -> tm_min, tp -> tm_sec,
00048                 str.c_str());
00049 }
00050 
00051 
00052 void StderrLog::error(Database& db,Query& q,const std::string& str)
00053 {
00054         time_t t = time(NULL);
00055         struct tm *tp = localtime(&t);
00056         fprintf(stderr,"%d-%02d-%02d %02d:%02d:%02d :: Query: %s: %s(%d)\n",
00057                 tp -> tm_year + 1900,tp -> tm_mon + 1,tp -> tm_mday,
00058                 tp -> tm_hour,tp -> tm_min, tp -> tm_sec,
00059                 str.c_str(),q.GetError().c_str(),q.GetErrno());
00060         fprintf(stderr," (QUERY: \"%s\")\n",q.GetLastQuery().c_str());
00061 }
00062 
00063 
00064 #ifdef ODBCW_NAMESPACE
00065 } // namespace ODBCW_NAMESPACE {
00066 #endif
Page, code, and content Copyright (C) 2006 by Anders Hedström