QMessage.hh

00001 /* Cuore Reconstruction program
00002  *
00003  * Author: MP 11/11/05
00004  * $Id: QMessage.hh 76 2006-05-18 15:54:00Z pallas $
00005  *
00006  * Class QMessage
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 enum MsgLevel {
00020         NoMsg = 0,          // no message
00021         DebugMsg = 1,       // debugging messages
00022         InfoMsg = 2,        // information messages
00023         WarnMsg = 3,        // an anomalous condition that could be fixed
00024         ErrorMsg = 4,       // "      "        "        "    "  NOT be fixed
00025         PanicMsg = 5,       // a fatal error that does not allow to continue 
00026         NoFilterMsg = 6     // a message that cannot be filtered on logfile
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                 // default levels for print and log
00054                 MsgLevel print_level;
00055                 MsgLevel log_level;
00056 
00057                 void SetColor(MsgLevel);
00058         
00059                 
00060 
00061 };
00062 
00063 #endif

Generated on Tue Nov 16 10:49:56 2010 for CUORE Software by  doxygen 1.5.6