00001 #ifndef LOGGER_H
00002 #define LOGGER_H
00003
00004 #include "string"
00005 #include "fstream"
00006 #include "globals.h"
00007
00008 extern int ind;
00009
00010 extern Globals global_vars;
00011
00012 #define DMP_DEBUG_INFO 0
00013
00014 inline void TOF(const char * msg)
00015 {
00016 #if(DMP_DEBUG_INFO)
00017 std::string fname = global_vars.xmp_file_name + ".debug.log";
00018 std::ofstream of;
00019 of.open( fname.c_str(), std::ios_base::out | std::ios_base::app);
00020 of << msg << "\n";
00021 of.close();
00022 #endif
00023 }
00024
00025 inline void DMP(const char * msg)
00026 {
00027 global_vars.dmp << msg;
00028 }
00029
00030 inline void ERR_OUT(const char * msg)
00031 {
00032 const char * fname = global_vars.err_file_name.c_str();
00033 std::ofstream of;
00034 of.open( fname, std::ios_base::out | std::ios_base::app);
00035 of << msg << "\n";
00036 of.close();
00037 }
00038
00039 inline void TO(const char * msg)
00040 {
00041 global_vars.err << MSG_INFO << msg << "\n";
00042 #if(0)
00043 if ( global_vars.silent_mode)
00044 ERR_OUT( msg);
00045 else
00046 AfxMessageBox(msg);
00047 TOF(msg);
00048 #endif
00049 }
00050
00051 inline void DMP(const std::string& msg) { DMP( msg.c_str() ); }
00052
00053 inline void TO( const CString& msg) { TO( (LPCTSTR) msg); }
00054 inline void TO( const std::string& msg) { TO( msg.c_str()); }
00055
00056 inline void TOF( const CString& msg) { TOF( (LPCTSTR) msg); }
00057 inline void TOF( const std::string& msg) { TOF( msg.c_str() ); }
00058
00059 inline void ERR_OUT( const CString& msg) { ERR_OUT( (LPCTSTR) msg); }
00060 inline void ERR_OUT( const std::string& msg) { ERR_OUT( msg.c_str() ); }
00061
00062 inline std::string indStr()
00063 {
00064 return std::string( ind, '\t');
00065 }
00066
00067 #endif // LOGGER_H