QMessage.hh
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 void Init(MsgLevel plevel, MsgLevel llevel, const std::string& logfile);
00035
00036 static inline void Warn(const std::string& sender,const std::string& msg) { QMessageHandler::Get()->Send(WarnMsg,sender,msg); }
00037 static inline void Info(const std::string& sender,const std::string& msg) { QMessageHandler::Get()->Send(InfoMsg,sender,msg); }
00038 static inline void Debug(const std::string& sender,const std::string& msg) { QMessageHandler::Get()->Send(DebugMsg,sender,msg); }
00039 static inline void Error(const std::string& sender,const std::string& msg) { QMessageHandler::Get()->Send(ErrorMsg,sender,msg); }
00040 static inline void Panic(const std::string& sender,const std::string& msg) { QMessageHandler::Get()->Send(PanicMsg,sender,msg); }
00041
00042 std::ostream& GetLogFile() {return logfile;}
00043
00044 virtual ~QMessageHandler() {}
00045
00046 void Send(MsgLevel l, const std::string& sender, const std::string& msg );
00047
00048 private:
00049 QMessageHandler();
00050 static QMessageHandler *me;
00051 std::ofstream logfile;
00052
00053
00054 MsgLevel print_level;
00055 MsgLevel log_level;
00056
00057 void SetColor(MsgLevel);
00058
00059
00060
00061 };
00062
00063 #endif