00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _Q_MESSAGE_H_
00011 #define _Q_MESSAGE_H_
00012
00013 #include <fstream>
00014 #include <stdarg.h>
00015 #include "QCuore.hh"
00016 #include "QMessageDefs.hh"
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 class QMessageHandler {
00031
00032 public:
00033 static QMessageHandler *Get();
00034
00035 static inline void Warn(const std::string& sender,const std::string& msg) { QMessageHandler::Get()->Send(WarnMsg,sender,msg); }
00036 static inline void Info(const std::string& sender,const std::string& msg) { QMessageHandler::Get()->Send(InfoMsg,sender,msg); }
00037 static inline void Debug(const std::string& sender,const std::string& msg) { QMessageHandler::Get()->Send(DebugMsg,sender,msg); }
00038 static inline void Error(const std::string& sender,const std::string& msg) { QMessageHandler::Get()->Send(ErrorMsg,sender,msg); }
00039 static inline void Panic(const std::string& sender,const std::string& msg) { QMessageHandler::Get()->Send(PanicMsg,sender,msg); }
00040
00041 std::ostream& GetLogFile() {return logfile;}
00042
00043 virtual ~QMessageHandler() {}
00044
00045 void Send(MsgLevel l, const std::string& sender, const std::string& msg );
00046
00047 private:
00048 QMessageHandler();
00049 static QMessageHandler *me;
00050 std::ofstream logfile;
00051
00052
00053 int warnings;
00054 int errors;
00055
00056
00057 MsgLevel print_level;
00058 MsgLevel log_level;
00059
00060 void SetColor(MsgLevel);
00061
00062
00063
00064 };
00065
00066 #endif