Page principale | Liste des namespaces | Hiérarchie des classes | Liste par ordre alphabétique | Liste des composants | Liste des fichiers | Membres des namespaces | Composants | Déclarations

ExCTrace.h

Aller à la documentation de ce fichier.
00001 /************************************************************************/
00002 /* Ex Nihlo Engine by Hermanns Christophe                                                               */
00003 /************************************************************************/
00004 /* This program is free software; you can redistribute it and/or                */
00005 /* modify it under the terms of the GNU General Public License                  */
00006 /* as published by the Free Software Foundation; either version 2               */
00007 /* of the License, or (at your option) any later version.                               */
00008 /*                                                                                                                                              */
00009 /* This program is distributed in the hope that it will be useful,              */
00010 /* but WITHOUT ANY WARRANTY; without even the implied warranty of               */
00011 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                                 */
00012 /*                                                                                                                                              */
00013 /* See the GNU General Public License for more details.                                 */
00014 /*                                                                                                                                              */
00015 /* You should have received a copy of the GNU General Public License    */
00016 /* along with this program; if not, write to the Free Software                  */
00017 /* Foundation, Inc., 59 Temple Place - Suite 330,                                               */
00018 /* Boston, MA  02111-1307, USA.                                                                                 */
00019 /*                                                                                                                                              */
00020 /* If you use a important part of this code please send me a mail               */
00021 /* I just want to see where my code go thks :)                                                  */
00022 /************************************************************************/
00023 
00024 /************************************************************************/
00025 /* Contact                                                              */  
00026 /************************************************************************/
00027 /* ExNihilo Website :www.ploksoftware.org                               */
00028 /*                                                                      */
00029 /* Hermanns Christophe ExNihilo creator and main programmer             */
00030 /*                                                                      */
00031 /* Mail             : Data@ploksoftware.org                                                             */
00032 /* ICQ              : 8030901                                                                                   */
00033 /* MSN Messenger    : Data_7@hotmail.com                                                                */
00034 /*                                                                      */
00035 /*                                                                      */
00036 /************************************************************************/
00037 
00038 /************************************************************************/
00039 /* File Description                                                                                             */
00040 /************************************************************************/
00041 /* File Name   :ExCTrace.h                                                                                              */
00042 /*                                                                                                                                              */
00043 /* Start Date   :03/15/2002                                                                                             */
00044 /*                                                                                                                                              */
00045 /* Last Update :06/20/2003                                              */
00046 /*                                                                                                                                              */
00047 /* File Description :                                                                                                   */
00048 /*                                                                      */
00049 /* For update of this file check : www.ploksoftware.org                 */
00050 /************************************************************************/
00051 
00052 #ifndef EXCTRACE_H__
00053 #define EXCTRACE_H__
00054 
00055 #include <stdio.h>
00056 #include <stdlib.h>
00057 #include <iostream>
00058 #include <fstream>
00059 #ifndef GCC_295
00060         #include <ostream>
00061 #endif
00062 #include <string.h>
00063 #include <time.h>
00064 #include <sys/timeb.h>
00065 #include <sys/types.h>
00066 
00067 #include <iostream>
00068 #include <strstream>
00069 #ifdef UNIX_SRC
00070         #include <typeinfo>
00071 #else
00072         #include <typeinfo.h>
00073 #endif
00074 /*
00075         Traceable call stack
00076         Before compiling make your choice betwene
00077         1) NORMAL
00078         2) TRACE
00079         3) DEBUG
00080         4) LOG
00081         
00082         NORMAL :
00083                 Guard and UnGard are defined as nothing use only when you 
00084                 have finish your programe
00085         TRACE :
00086                 Each function call will be show on consol and each 
00087                 function out to
00088         DEBUG :
00089                 If any exception occure you will show on consol the 
00090                 call stack and where the programme bug ...
00091         LOG     :
00092                 Same as Debug but all is redirect to log.txt
00093         TRACETIME:
00094                 Show tge time each function take
00095 */
00096 
00097 #ifndef UNIX_SRC
00098         // under WIN32 change here
00099         // UNIX users use the configure script
00100         #define DEBUG
00101 #endif
00102 
00103 #define EXC throw 1;
00104  
00105 //#ifndef UNIX_SRC
00106         #ifdef NORMAL
00107                 #define Guard(function) 
00108                 #define UnGuard
00109                 #define Trace
00110                 #define Error
00111         #else 
00112         #ifdef LOG
00113         static std::ofstream logfile("callstack.log",std::ios::app);\
00114                 #define Guard(function) static char * __FUNCTION_NAME__ = #function;\
00115                                                                                 try {
00116                 #define UnGuard } catch (...) {\
00117                                                                                 time_t tt;struct tm *ttb;tt = time(NULL);ttb = localtime(&tt);\
00118                                                                                 logfile<<"*********************CALL STACK*********************"<<std::endl;\
00119                                                                                 logfile<<"* Date   : "<<asctime(ttb);\
00120                                                                                 logfile<<"* Module : "<<__FUNCTION_NAME__<<std::endl;\
00121                                                                                 logfile<<"* Line   : "<<__LINE__<<std::endl;\
00122                                                                                 logfile<<"* File   : "<<__FILE__<<std::endl;\
00123                                                                                 logfile<<"* Make date : "<<__DATE__<<" "<<__TIME__<<std::endl;\
00124                                                                                 logfile<<"***************************************************"<<std::endl;\
00125                                                                                 throw; }
00126         #elif defined DEBUG
00127                 #define Guard(function) static char * __FUNCTION_NAME__ = #function;\
00128                                                                                 try {
00129                 #define UnGuard } catch (...) {\
00130                                                                                 time_t tt;struct tm *ttb;tt = time(NULL);ttb = localtime(&tt);\
00131                                                                                 std::cout<<"*********************CALL STACK*********************"<<std::endl;\
00132                                                                                 std::cout<<"* Date   : "<<asctime(ttb);\
00133                                                                                 std::cout<<"* Module : "<<__FUNCTION_NAME__<<std::endl;\
00134                                                                                 std::cout<<"* Line   : "<<__LINE__<<std::endl;\
00135                                                                                 std::cout<<"* File   : "<<__FILE__<<std::endl;\
00136                                                                                 std::cout<<"* Make date : "<<__DATE__<<" "<<__TIME__<<std::endl;\
00137                                                                                 std::cout<<"***************************************************"<<std::endl;\
00138                                                                                 throw; }
00139         #elif defined TRACE
00140                         #define Guard(function) static char * __FUNCTION_NAME__ = #function;\
00141                                                                                 std::cout<<">>>> Module : "<<__FUNCTION_NAME__<<std::endl;
00142                         #define UnGuard                         std::cout<<"<<<< Module : "<<__FUNCTION_NAME__<<std::endl;
00143 
00144         
00145         #elif defined TRACETIME
00146                 static std::ofstream logfile("TraceTime.log",std::ios::out);
00147                 #define Guard(function) static char * __FUNCTION_NAME__ = #function;\
00148                                                                                 __timeb64 ltime,ltime2;\
00149                                                                                 logfile<<"Enter function : "<<__FUNCTION_NAME__<<std::endl;\
00150                                                                                 _ftime64(&ltime );
00151                 #define UnGuard                                 _ftime64(&ltime2 );\
00152                                                                                 logfile<<"Time in func   : "<<ltime2.millitm-ltime.millitm <<std::endl;\
00153                                                                                 logfile<<"Leave function : "<<__FUNCTION_NAME__<<std::endl;
00154 
00155         #endif //TRACETIME
00156 
00157 
00158         #define Trace(why) static char * __WHY__ = #why;\
00159                                                                                 time_t tt;struct tm *ttb;tt = time(NULL);ttb = localtime(&tt);\
00160                                                                                 std::cout<<"***********************TRACE***********************"<<std::endl;\
00161                                                                                 std::cout<<"* Date      : "<<asctime(ttb);\
00162                                                                                 std::cout<<"* Module    : "<<__FUNCTION_NAME__<<std::endl;\
00163                                                                                 std::cout<<"* Line      : "<<__LINE__<<std::endl;\
00164                                                                                 std::cout<<"* File      : "<<__FILE__<<std::endl;\
00165                                                                                 std::cout<<"* Make date : "<<__DATE__<<" "<<__TIME__<<std::endl;\
00166                                                                                 std::cout<<"* Cause     : "<<__WHY__<<std::endl;\
00167                                                                                 std::cout<<"* Error     : "<<errno<<std::endl;\
00168                                                                                 std::cout<<"***************************************************"<<std::endl;
00169         
00170         #endif // !NORMAL
00171 //#endif
00172                                                         
00173 #endif // EXCTRACE_H__

Généré le Tue Oct 28 12:43:33 2003 pour ExNihilo par doxygen 1.3.4