Skip to content

Commit

Permalink
UI|Client: Configurable styled log sink formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jan 2, 2014
1 parent b6875e4 commit f65fe72
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 6 additions & 0 deletions doomsday/client/include/ui/styledlogsinkformatter.h
Expand Up @@ -28,7 +28,13 @@
class StyledLogSinkFormatter : public de::LogSink::IFormatter
{
public:
StyledLogSinkFormatter();
StyledLogSinkFormatter(de::LogEntry::Flags const &formatFlags);

Lines logEntryToTextLines(de::LogEntry const &entry);

private:
de::LogEntry::Flags _format;
};

#endif // DENG_CLIENT_STYLEDLOGSINKFORMATTER_H
15 changes: 11 additions & 4 deletions doomsday/client/src/ui/styledlogsinkformatter.cpp
Expand Up @@ -20,16 +20,23 @@

using namespace de;

LogSink::IFormatter::Lines StyledLogSinkFormatter::logEntryToTextLines(LogEntry const &entry)
StyledLogSinkFormatter::StyledLogSinkFormatter()
{
LogEntry::Flags flags = LogEntry::Styled | LogEntry::OmitLevel;
_format = LogEntry::Styled | LogEntry::OmitLevel;

#ifndef _DEBUG
// No metadata in release builds.
flags |= LogEntry::Simple;
_format |= LogEntry::Simple;
#endif
}

StyledLogSinkFormatter::StyledLogSinkFormatter(LogEntry::Flags const &formatFlags)
: _format(formatFlags)
{}

LogSink::IFormatter::Lines StyledLogSinkFormatter::logEntryToTextLines(LogEntry const &entry)
{
// This will form a single long line. The line wrapper will
// then determine how to wrap it onto the available width.
return Lines() << entry.asText(flags);
return Lines() << entry.asText(_format);
}

0 comments on commit f65fe72

Please sign in to comment.