Skip to content

Commit

Permalink
libshell|libdeng2: Flag remote log entries as such
Browse files Browse the repository at this point in the history
Added a log entry flag indicating log entries that have been received
over the network from a remote source.
  • Loading branch information
skyjake committed Feb 5, 2013
1 parent 5276041 commit 49ed6a3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
12 changes: 9 additions & 3 deletions doomsday/libdeng2/include/de/core/log.h
Expand Up @@ -302,7 +302,11 @@ class DENG2_PUBLIC LogEntry : public Lockable, public ISerializable

/// Parts of the section can be abbreviated because they are clear
/// from the context (e.g., previous line).
AbbreviateSection = 0x10
AbbreviateSection = 0x10,

/// Entry is not from a local source. Could be used to mark entries
/// originating from a remote LogBuffer (over the network).
Remote = 0x20
};
Q_DECLARE_FLAGS(Flags, Flag)

Expand All @@ -323,10 +327,12 @@ class DENG2_PUBLIC LogEntry : public Lockable, public ISerializable
* Copy constructor.
* @param other Log entry.
*/
LogEntry(LogEntry const &other);
LogEntry(LogEntry const &other, Flags extraFlags = 0);

~LogEntry();

Flags flags() const;

/// Returns the timestamp of the entry.
Time when() const { return _when; }

Expand All @@ -349,7 +355,7 @@ class DENG2_PUBLIC LogEntry : public Lockable, public ISerializable
*
* @return Composed textual representation of the entry.
*/
String asText(Flags const &flags = 0, int shortenSection = 0) const;
String asText(Flags const &flags = 0, int shortenSection = 0) const;

// Implements ISerializable.
void operator >> (Writer &to) const;
Expand Down
13 changes: 9 additions & 4 deletions doomsday/libdeng2/src/core/log.cpp
Expand Up @@ -199,13 +199,13 @@ LogEntry::LogEntry(Level level, String const &section, int sectionDepth, String
}
}

LogEntry::LogEntry(LogEntry const &other)
LogEntry::LogEntry(LogEntry const &other, Flags extraFlags)
: _when(other._when),
_level(other._level),
_section(other._section),
_sectionDepth(other._sectionDepth),
_format(other._format),
_defaultFlags(other._defaultFlags),
_defaultFlags(other._defaultFlags | extraFlags),
_disabled(other._disabled)
{
DENG2_FOR_EACH_CONST(Args, i, other._args)
Expand All @@ -222,7 +222,12 @@ LogEntry::~LogEntry()
for(Args::iterator i = _args.begin(); i != _args.end(); ++i)
{
delete *i;
}
}
}

LogEntry::Flags LogEntry::flags() const
{
return _defaultFlags;
}

String LogEntry::asText(Flags const &formattingFlags, int shortenSection) const
Expand Down Expand Up @@ -255,7 +260,7 @@ String LogEntry::asText(Flags const &formattingFlags, int shortenSection) const
"(deb)",
"(vrb)",
"",
"(inf)",
"(i)",
"(WRN)",
"(ERR)",
"(!!!)"
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libshell/src/protocol.cpp
Expand Up @@ -60,7 +60,7 @@ void LogEntryPacket::execute() const
LogBuffer &buf = LogBuffer::appBuffer();
foreach(LogEntry *e, _entries)
{
buf.add(new LogEntry(*e));
buf.add(new LogEntry(*e, LogEntry::Remote));
}
}

Expand Down

0 comments on commit 49ed6a3

Please sign in to comment.