1#include "ThrottledConsumer.h"
3#include "../HashSequence.h"
4#include "../Platform/Timer.h"
5#include "../Platform/Timer.h"
36 msg.
line = lineNumber;
40 messagesMutex.unlock();
49 int64_t now = Cogs::Timer::currentTimeMilliseconds();
52 time_t seconds = now / 1000;
53 char milliseconds[64];
55 strftime(buffer,
sizeof(buffer),
"%H:%M:%S", localtime(&seconds));
56 snprintf(milliseconds,
sizeof(milliseconds),
":%03d",
static_cast<int>(now % 1000));
57 strcat(buffer, milliseconds);
59 LockGuard lock(messagesMutex);
61 for (
auto i = messages.begin(), e = messages.end(); i != e; ) {
69 if (message.
count > 1) {
71 prefix += std::to_string(message.
count);
75 outputMessage(prefix, message);
81 i = messages.erase(i);
void flush(bool flushAll=true)
Flushes some or all messages currently queued and awaiting a suitable time to be output.
virtual void consumeMessage(const char *source, Category category, uint32_t errorNumber, const char *message, const char *filename, int lineNumber) override
Consumes a message being sent through the logging system.
static void setEnabled(bool enable)
Enables or disables throttling of messages.
Category
Logging categories used to filter log messages.
constexpr size_t hashSequence(const T &t, const U &u)
Hash the last two items in a sequence of objects.
int line
Line number this message is from.
int count
Number of times this message has been received since it was last output.
std::string message
Message to be output.
int64_t outputTime
Time at which this message can be next output.
const char * file
Name of file that generated this message.
std::string source
Source of this message.
Category category
Category to which this message belongs.