Skip to content

Commit

Permalink
libdeng2|Log: Include domain in printed log entries
Browse files Browse the repository at this point in the history
Only the first applicable domain is printed. Upper case letters are
for non-dev entries and lower case is for dev entries.

The timestamp in log entries now omits the hour, which is not that
valuable information.
  • Loading branch information
skyjake committed Jan 8, 2014
1 parent cb7ef36 commit df67bca
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
17 changes: 9 additions & 8 deletions doomsday/libdeng2/include/de/c_wrapper.h
Expand Up @@ -85,14 +85,15 @@ typedef enum logentry_level_e {
} logentry_level_t;

typedef enum logentry_audience_e {
DE2_LOG_RES = 0x10000,
DE2_LOG_MAP = 0x20000, ///< Map developer
DE2_LOG_SCR = 0x40000, ///< Script developer
DE2_LOG_GL = 0x80000, ///< GL domain (shaders, etc.)
DE2_LOG_AUDIO = 0x100000, ///< Audio domain
DE2_LOG_INPUT = 0x200000, ///< Input domain
DE2_LOG_NET = 0x400000, ///< Network domain
DE2_LOG_DEV = 0x800000 ///< Native code developer (i.e., the programmer)
DE2_LOG_GENERIC = 0x10000,
DE2_LOG_RES = 0x20000,
DE2_LOG_MAP = 0x40000, ///< Map developer
DE2_LOG_SCR = 0x80000, ///< Script developer
DE2_LOG_GL = 0x100000, ///< GL domain (shaders, etc.)
DE2_LOG_AUDIO = 0x200000, ///< Audio domain
DE2_LOG_INPUT = 0x400000, ///< Input domain
DE2_LOG_NET = 0x800000, ///< Network domain
DE2_LOG_DEV = 0x8000000 ///< Native code developer (i.e., the programmer)
} logentry_audience_t;

#define DE2_LOG_DEBUG (DE2_LOG_DEV | DE2_LOG_VERBOSE)
Expand Down
1 change: 1 addition & 0 deletions doomsday/libdeng2/include/de/data/time.h
Expand Up @@ -125,6 +125,7 @@ class DENG2_PUBLIC Time : public ISerializable
enum Format {
ISOFormat,
BuildNumberAndTime,
BuildNumberAndTimeWithoutHour,
FriendlyFormat,
ISODateOnly,
CompilerDateTime // Oct 7 2013 03:18:36 (__DATE__ __TIME__)
Expand Down
16 changes: 12 additions & 4 deletions doomsday/libdeng2/src/core/log.cpp
Expand Up @@ -254,7 +254,7 @@ String LogEntry::asText(Flags const &formattingFlags, int shortenSection) const
// Begin with the timestamp.
if(flags.testFlag(Styled)) output << TEXT_STYLE_LOG_TIME;

output << _when.asText(Date::BuildNumberAndTime) << " ";
output << _when.asText(Date::BuildNumberAndTimeWithoutHour) << " ";

if(!flags.testFlag(OmitLevel))
{
Expand All @@ -270,8 +270,16 @@ String LogEntry::asText(Flags const &formattingFlags, int shortenSection) const
"(ERR)",
"(!!!)"
};
output << qSetPadChar(' ') << qSetFieldWidth(5) << levelNames[level()] <<
qSetFieldWidth(0) << " ";
QChar dc = (_metadata & Resource? 'R' :
_metadata & Map? 'M' :
_metadata & Script? 'S' :
_metadata & GL? 'G' :
_metadata & Audio? 'A' :
_metadata & Input? 'I' :
_metadata & Network? 'N' : ' ');
if(_metadata & Dev) dc = dc.toLower();
output << dc << qSetPadChar(' ') << qSetFieldWidth(5)
<< levelNames[level()] << qSetFieldWidth(0) << " ";
}
else
{
Expand All @@ -280,7 +288,7 @@ String LogEntry::asText(Flags const &formattingFlags, int shortenSection) const
"XVerbose",
"Verbose",
"",
"Note",
"Note!",
"Warning",
"ERROR",
"FATAL!"
Expand Down
4 changes: 4 additions & 0 deletions doomsday/libdeng2/src/data/time.cpp
Expand Up @@ -306,6 +306,10 @@ String Time::asText(Format format) const
{
return d->dateTime.toString(Qt::TextDate);
}
else if(format == BuildNumberAndTimeWithoutHour)
{
return QString("#%1 ").arg(asBuildNumber(), -4) + d->dateTime.toString("mm:ss.zzz");
}
else
{
return QString("#%1 ").arg(asBuildNumber(), -4) + d->dateTime.toString("hh:mm:ss.zzz");
Expand Down

0 comments on commit df67bca

Please sign in to comment.