Logging: check for filter before sending to the queue, to skip all heavy formatting on the other thread.

This commit is contained in:
Emmanuel Gil Peyrot 2015-03-06 19:15:02 +01:00
parent 53ba65db43
commit 0aa44e238d
7 changed files with 21 additions and 9 deletions

View file

@ -11,7 +11,6 @@
#endif
#include "common/logging/backend.h"
#include "common/logging/filter.h"
#include "common/logging/log.h"
#include "common/logging/text_formatter.h"
@ -116,7 +115,7 @@ void PrintColoredMessage(const Entry& entry) {
#endif
}
void TextLoggingLoop(std::shared_ptr<Logger> logger, const Filter* filter) {
void TextLoggingLoop(std::shared_ptr<Logger> logger) {
std::array<Entry, 256> entry_buffer;
while (true) {
@ -126,9 +125,7 @@ void TextLoggingLoop(std::shared_ptr<Logger> logger, const Filter* filter) {
}
for (size_t i = 0; i < num_entries; ++i) {
const Entry& entry = entry_buffer[i];
if (filter->CheckMessage(entry.log_class, entry.log_level)) {
PrintColoredMessage(entry);
}
PrintColoredMessage(entry);
}
}
}