QMsgLogger.hh

Go to the documentation of this file.
00001 
00007 #ifndef _QMSG_LOGGER_HH_
00008 #define _QMSG_LOGGER_HH_
00009 
00010 // QFramework includes
00011 #include "QCuore.hh"
00012 #include "QDaqCommonDefs.hh"
00013 #include "QMessageDefs.hh"
00014 #include "QError.hh"
00015 
00016 // standard C/C++ includes
00017 #include <fstream>
00018 #include <string>
00019 #include <list>
00020 #include <map>
00021 
00022 class QMsgLogger {
00023 public:
00024 
00025    struct QProcessInfo_t 
00026    {
00027       pid_t pid;
00028       ProcessStatus_t status;
00029       std::string hostname;
00030    };
00031 
00033    static QMsgLogger& GetInstance();
00034 
00036    virtual ~QMsgLogger();
00037 
00038    bool HasError() const { return fError != QERR_SUCCESS; }
00039    void ResetError() { fError.Set(QERR_SUCCESS); }
00040    const QError& GetError() const { return fError; }
00041 
00050    bool RegisterProcess(const std::string& process,
00051                         const std::string& host,
00052                         pid_t              pid);
00053 
00060    bool ReleaseProcess(const std::string& process);
00061    
00069    bool UpdateStatus(const std::string& process,
00070                      ProcessStatus_t    status);
00071 
00080    void WriteLog(MsgLevel           severity,
00081                  const std::string& sender,
00082                  const std::string& message);
00083 
00089    void Write(const std::string& message, MsgLevel severity);
00090 
00095    std::list<std::string> GetRegisteredProcesses() const;
00096    
00112    bool GetProcessInfo(const std::string& process,
00113                        pid_t*             pid,
00114                        ProcessStatus_t*   status,
00115                        std::string*       host);
00116 
00117 private:
00119    QMsgLogger();
00120 
00122    std::map<std::string,QProcessInfo_t*> fProcesses;
00123    
00124    std::ofstream fOs;
00125 
00126    QError fError;
00127 
00132    const std::string& GetTime() const;
00133 
00139    const std::string& FormatForLog(MsgLevel severity) const;
00140 
00141 };
00142 
00143 #endif // _QMSG_LOGGER_HH_

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