QMsgLogger Class Reference

List of all members.


Detailed Description

Author:
sergio.didomizio@ge.infn.it

Public Member Functions

virtual ~QMsgLogger ()
 destructor
bool HasError () const
void ResetError ()
const QErrorGetError () const
bool RegisterProcess (const std::string &process, const std::string &host, pid_t pid)
 register process to message logger
bool ReleaseProcess (const std::string &process)
 unregister previously registered process
bool UpdateStatus (const std::string &process, QDaqCommonDefs::ProcessStatus_t status)
 update process status informations
void WriteLog (MsgLevel severity, const std::string &sender, const std::string &message)
 write message supplied by external processes
void Write (const std::string &message, MsgLevel severity)
 write message not supplied by external processes)
std::list< std::string > GetRegisteredProcesses () const
 get a vector containing names of registered processes
bool GetProcessInfo (const std::string &process, pid_t *pid, QDaqCommonDefs::ProcessStatus_t *status, std::string *host)
 get informations regarding a particular process
unsigned long GetLastLogId () const
 get id associated to most recent log
unsigned long GetFirstValidLogId () const
 get id associated to oldest retained log
unsigned long GetTimeLogId (const time_t &msgTime) const
 get id of first message that occurred after specified time
bool GetFormattedLogMessage (const unsigned long &id, std::string &message)
 get formatted log message associated to given id
bool GetLogMessage (const unsigned long &id, QLogInfo &logInfo)
 get unformatted log message associated to given id

Static Public Member Functions

static QMsgLoggerGetInstance ()
 singleton

Private Member Functions

 QMsgLogger ()
 private constructor
void AddLogEntry (MsgLevel severity, const std::string &sender, const std::string &message, const time_t &msgTime)
const std::string & GetTime () const
 get current date and time formatted as a string
const std::string & FormatForLog (MsgLevel severity) const
 translate a 'severity' string into a format suitable for log file

Private Attributes

std::map< std::string,
QProcessInfo_t * > 
fProcesses
 map of registered processes and corresponding informations
std::map< unsigned long, QLogInfofMessages
unsigned long fFirstValidMsgId
unsigned long fMessageCtr
const unsigned int kMaxMsgSize
const unsigned int kMsgDelBunchSize
std::ofstream fOs
QError fError

Classes

struct  QProcessInfo_t

Member Function Documentation

bool QMsgLogger::RegisterProcess ( const std::string &  process,
const std::string &  host,
pid_t  pid 
)

register process to message logger

Parameters:
process process name
host process host
pid process pid
Returns:
true on success, false if another process with the same name is already registered

References fProcesses, QDaqCommonDefs::QUnknown_s, QError::Set(), and Write().

bool QMsgLogger::ReleaseProcess ( const std::string &  process  ) 

unregister previously registered process

Parameters:
process process name
Returns:
true on success, false if there are no registered processes with this name

References fProcesses, QError::Set(), and Write().

bool QMsgLogger::UpdateStatus ( const std::string &  process,
QDaqCommonDefs::ProcessStatus_t  status 
)

update process status informations

Parameters:
process process name
status new process status
Returns:
true on success, false if there are no registered processes with this name

References fProcesses, QDaqCommonDefs::ProcessStatusEnumToString(), QError::Set(), and Write().

void QMsgLogger::WriteLog ( MsgLevel  severity,
const std::string &  sender,
const std::string &  message 
)

write message supplied by external processes

Parameters:
severity message severity
sender sender process
message text message
Message is written to log file even if sender is not registered

References FormatForLog(), fProcesses, and GetTime().

void QMsgLogger::Write ( const std::string &  message,
MsgLevel  severity 
)

write message not supplied by external processes)

Parameters:
message text message
severity message severity

References FormatForLog(), and GetTime().

Referenced by RegisterProcess(), ReleaseProcess(), and UpdateStatus().

std::list< std::string > QMsgLogger::GetRegisteredProcesses (  )  const

get a vector containing names of registered processes

Returns:
vector of process names

References fProcesses.

bool QMsgLogger::GetProcessInfo ( const std::string &  process,
pid_t *  pid,
QDaqCommonDefs::ProcessStatus_t status,
std::string *  host 
)

get informations regarding a particular process

Memory pointed by pid and status are filled with the corresponding informations. Pass NULL pointer to the quantities you are not interested in.

Parameters:
process the name of the wanted process
pid pointer to a variable that will be filled with Process Id
status pointer to a variable that will be filled with process status
status pointer to a variable that will be filled with the hostname of the requested process
Returns:
true on success, false if process is not registered

References fProcesses, and QError::Set().

bool QMsgLogger::GetFormattedLogMessage ( const unsigned long &  id,
std::string &  message 
)

get formatted log message associated to given id

Parameters:
id message id
message string filled with requested message
Returns:
true, unless requested id is invalid

References GetLogMessage(), QLogInfo::GetMessage(), QLogInfo::GetSender(), and QLogInfo::GetTimeString().

bool QMsgLogger::GetLogMessage ( const unsigned long &  id,
QLogInfo logInfo 
)

get unformatted log message associated to given id

Parameters:
id message id
logInfo QLogInfo object filled with requested log id
Returns:
true, unless requested id is invalid

Referenced by GetFormattedLogMessage().

const std::string & QMsgLogger::GetTime (  )  const [private]

get current date and time formatted as a string

Returns:
string containing current date and time

Referenced by Write(), and WriteLog().

const std::string & QMsgLogger::FormatForLog ( MsgLevel  severity  )  const [private]

translate a 'severity' string into a format suitable for log file

Parameters:
severity string to be formatted
Returns:
formatted string

Referenced by Write(), and WriteLog().


The documentation for this class was generated from the following files:

Generated on Tue Nov 16 10:50:07 2010 for CUORE Software by  doxygen 1.5.6