Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion common/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,22 @@ void Logger::write(Priority prio, const char *fmt, ...)
// + add thread id using std::thread::id this_id = std::this_thread::get_id();
// + add timestmap with millisecond resolution

va_list ap;
char buffer[256];
va_list ap, aq;
va_start(ap, fmt);
va_copy(aq, ap);

vsprintf(buffer, fmt, aq);
va_end(aq);

std::string cache(buffer);
if (cache == m_cache)
{
va_end(ap);
return;
}

m_cache = cache;
vsyslog(prio, fmt, ap);
va_end(ap);
}
Expand Down
1 change: 1 addition & 0 deletions common/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class Logger
Logger &operator=(const Logger&);

std::string m_self;
std::string m_cache;

static Priority m_minPrio;
};
Expand Down