Support tagged messages.
This changes the design of the LogBackend class and its subclasses, now the main virtual method is addTaggedMessage(). The former virtual method addMessage() is now a regular non-virtual method forwarding to addTaggedMessage(). You can configure message limiting based on tags by passing a MessageLimiter to the configureMessageLimiter() method, which will then be used by the includeMessage() method. That method now takes an additional tag argument. The most user-visible part of this is that there are new overloads of the static methods OpmLog::warning(), OpmLog::error() etc, that take message tags. To tie things together the OpmLog and Logger classes have also gotten new addTaggedMessage() methods, but they should mostly be used through the convenience methods such as OpmLog::warning().
This commit is contained in:
@@ -41,14 +41,14 @@ TimerLog::TimerLog(std::ostream& os) : StreamLog( os , StopTimer | StartTimer )
|
||||
|
||||
|
||||
|
||||
void TimerLog::addMessage(int64_t messageType , const std::string& msg ) {
|
||||
void TimerLog::addTaggedMessage(int64_t messageType, const std::string& messageTag, const std::string& msg ) {
|
||||
if (messageType == StopTimer) {
|
||||
clock_t stop = clock();
|
||||
double secondsElapsed = 1.0 * (m_start - stop) / CLOCKS_PER_SEC ;
|
||||
|
||||
m_work.str("");
|
||||
m_work << std::fixed << msg << ": " << secondsElapsed << " seconds ";
|
||||
StreamLog::addMessage( messageType , m_work.str());
|
||||
StreamLog::addTaggedMessage( messageType, messageTag, m_work.str());
|
||||
} else {
|
||||
if (messageType == StartTimer)
|
||||
m_start = clock();
|
||||
|
||||
Reference in New Issue
Block a user