Skip to content

Commit

Permalink
libdeng2|MemoryLogSink: Configurable minimum log entry level
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed May 23, 2013
1 parent 48c8c63 commit 19e608e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion doomsday/libdeng2/include/de/core/memorylogsink.h
Expand Up @@ -32,7 +32,7 @@ namespace de {
class MemoryLogSink : public LogSink, public Lockable
{
public:
MemoryLogSink();
MemoryLogSink(LogEntry::Level minimumLevel = LogEntry::DEBUG);
~MemoryLogSink();

LogSink &operator << (LogEntry const &entry);
Expand All @@ -50,6 +50,7 @@ class MemoryLogSink : public LogSink, public Lockable

private:
QList<LogEntry *> _entries;
LogEntry::Level _minLevel;
};

} // namespace de
Expand Down
12 changes: 7 additions & 5 deletions doomsday/libdeng2/src/core/memorylogsink.cpp
Expand Up @@ -20,7 +20,7 @@

namespace de {

MemoryLogSink::MemoryLogSink()
MemoryLogSink::MemoryLogSink(LogEntry::Level minimumLevel) : _minLevel(minimumLevel)
{}

MemoryLogSink::~MemoryLogSink()
Expand All @@ -40,10 +40,12 @@ void MemoryLogSink::clear()

LogSink &MemoryLogSink::operator << (LogEntry const &entry)
{
DENG2_GUARD(this);

_entries.append(new LogEntry(entry));
addedNewEntry(*_entries.back());
if(entry.level() >= _minLevel)
{
DENG2_GUARD(this);
_entries.append(new LogEntry(entry));
addedNewEntry(*_entries.back());
}
return *this;
}

Expand Down

0 comments on commit 19e608e

Please sign in to comment.