Public Member Functions | |
virtual | ~QMsgLogger () |
destructor | |
bool | HasError () const |
void | ResetError () |
const QError & | GetError () 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 QMsgLogger & | GetInstance () |
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, QLogInfo > | fMessages |
unsigned long | fFirstValidMsgId |
unsigned long | fMessageCtr |
const unsigned int | kMaxMsgSize |
const unsigned int | kMsgDelBunchSize |
std::ofstream | fOs |
QError | fError |
Classes | |
struct | QProcessInfo_t |
bool QMsgLogger::RegisterProcess | ( | const std::string & | process, | |
const std::string & | host, | |||
pid_t | pid | |||
) |
register process to message logger
process | process name | |
host | process host | |
pid | process pid |
References fProcesses, QDaqCommonDefs::QUnknown_s, QError::Set(), and Write().
bool QMsgLogger::ReleaseProcess | ( | const std::string & | process | ) |
unregister previously registered process
process | process name |
References fProcesses, QError::Set(), and Write().
bool QMsgLogger::UpdateStatus | ( | const std::string & | process, | |
QDaqCommonDefs::ProcessStatus_t | status | |||
) |
update process status informations
process | process name | |
status | new process status |
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
severity | message severity | |
sender | sender process | |
message | text message |
References FormatForLog(), fProcesses, and GetTime().
void QMsgLogger::Write | ( | const std::string & | message, | |
MsgLevel | severity | |||
) |
write message not supplied by external processes)
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
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.
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 |
References fProcesses, and QError::Set().
bool QMsgLogger::GetFormattedLogMessage | ( | const unsigned long & | id, | |
std::string & | message | |||
) |
get formatted log message associated to given id
id | message id | |
message | string filled with requested message |
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
id | message id | |
logInfo | QLogInfo object filled with requested log id |
Referenced by GetFormattedLogMessage().
const std::string & QMsgLogger::GetTime | ( | ) | const [private] |
get current date and time formatted as a string
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
severity | string to be formatted |
Referenced by Write(), and WriteLog().