/users/wolffm/guskov/Source/Logging.hh

Go to the documentation of this file.
00001 #ifndef DEF_LOG_ACTIVE_123
00002 #define DEF_LOG_ACTIVE_123
00003 
00004 #include <iostream>
00005 #include <fstream>
00006 #include <stack>
00007 #include <time.h>
00008 
00010 
00011 #ifdef LOG_ACTIVE
00012 
00014 #define TO_STR(x) #x
00015 #define LOG_STR(x) << TO_STR([) <<__LINE__ << TO_STR(:) << __FILE__ << TO_STR(] :) << x << std::endl; 
00016 
00018 #define LOG(x) if(Logging::default_level <= LOG_OUTPUT_LEVEL) Logging::log() LOG_STR(x);
00020 #define LOG_AT(lvl, x) if(lvl <= LOG_OUTPUT_LEVEL) Logging::log() LOG_STR(x);
00022 #define TRACE(x) Logging::log() << TO_STR(x) << std::endl; x;
00024 #define EXP(x) Logging::log() << TO_STR(x) << " = " << x << std::endl;
00025 
00028 #define SET_LEVEL(x) Logging::default_level = x;
00030 #define OPEN_LOG(x) Logging::set_log_stream(x, false);
00032 #define OPEN_LOG_APPEND(x) Logging::set_log_stream(x, true);
00034 #define SET_LOG_STDERR Logging::set_log_stream("");
00036 #define CLOSE_LOG Logging::close_log_stream();
00037 
00038 
00039 
00040 #else 
00042 
00043 #define LOG_STR(x) 
00044 #define LOG(x) 
00045 #define LOG_AT(lvl, x) 
00046 #define SET_LEVEL(x) 
00047 #define SET_LOG(x) 
00048 #define SET_LOG_APPEND(x) 
00049 #define SET_LOG_STDERR 
00050 #define TRACE(x)
00051 #define EXP(x) 
00052 #define CLOSE_LOG
00053 #define OPEN_LOG(x)
00054 #define OPEN_LOG_APPEND(x)
00055 
00056 #endif
00057 
00058 #define CLOCKS_PER_MS  (CLOCKS_PER_SEC * 1000)
00059 
00063 class Logging {
00064 public:
00068   static unsigned int default_level; 
00069     
00075   static void set_log_stream(const std::string& str, bool append = false);
00076     
00081   static void close_log_stream();
00082     
00087   static std::ostream& log();
00088 
00090   static std::stack<std::ostream*> streams;
00091 
00092 
00093 };
00094 
00095 
00098 class TimeLogging : Logging {
00099 
00100 private:
00102   clock_t startup;
00104   clock_t last_event;
00105 
00106 public:
00107 
00108   TimeLogging();
00109 
00117   void log_event(const std::string& s_event);
00118 
00119   
00120 
00121 };
00122 
00123 
00124 
00125 
00126 
00127 
00128 
00129 
00130 #endif

Generated on Fri Jun 15 17:24:59 2007 for GuskovRemeshing by  doxygen 1.5.2