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         
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                 // counters for errors and warnings
00053                 int warnings;
00054                 int errors;
00055 
00056                 // default levels for print and log
00057                 MsgLevel print_level;
00058                 MsgLevel log_level;
00059 
00060                 void SetColor(MsgLevel);
00061         
00062                 
00063 
00064 };
00065 
00066 #endif

Generated on Fri Mar 6 13:40:39 2009 for CUORE Software by  doxygen 1.5.1