Skip to content

Commit

Permalink
Refactor|Log: Added bits for target audience, more LOG_* macros
Browse files Browse the repository at this point in the history
It is now possible to mark log entries for specific user groups
and/or domains. While the DEV group is intended for pure programmer
stuff (like pointer values etc.), the other groups are for domain
specific information (things like map elements, input events, or
OpenGL details).

The DEBUG and TRACE levels were removed and replaced with
DEV|VERBOSE and DEV|XVERBOSE, respectively.

Todo: Take the new macros into use in the libs and engine subsystems.
Todo: Filter history / alert selectively based on the new bits.
  • Loading branch information
skyjake committed Jan 4, 2014
1 parent 7ffc297 commit 7e0a6c3
Show file tree
Hide file tree
Showing 32 changed files with 363 additions and 219 deletions.
2 changes: 1 addition & 1 deletion doomsday/client/include/clientapp.h
Expand Up @@ -59,7 +59,7 @@ class ClientApp : public de::GuiApp
* @param msg Message to show. May contain style escapes.
* @param level Importance of the message.
*/
static void alert(de::String const &msg, de::LogEntry::Level level = de::LogEntry::MESSAGE);
static void alert(de::String const &msg, de::LogEntry::Level level = de::LogEntry::Message);

public:
static ClientApp &app();
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/include/filesys/fileid.h
Expand Up @@ -78,7 +78,7 @@ class FileId : public LogEntry::Arg::Base
String asText() const;

// Implements LogEntry::Arg::Base.
LogEntry::Arg::Type logEntryArgType() const { return LogEntry::Arg::STRING; }
LogEntry::Arg::Type logEntryArgType() const { return LogEntry::Arg::StringArgument; }

/// @return Md5hash for this FileId.
Md5Hash const& md5() const { return md5_; }
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/include/uri.hh
Expand Up @@ -318,7 +318,7 @@ public:
String asText() const;

// Implements LogEntry::Arg::Base.
LogEntry::Arg::Type logEntryArgType() const { return LogEntry::Arg::STRING; }
LogEntry::Arg::Type logEntryArgType() const { return LogEntry::Arg::StringArgument; }

// Implements ISerializable.
void operator >> (Writer &to) const;
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/clientapp.cpp
Expand Up @@ -409,8 +409,8 @@ void ClientApp::alert(String const &msg, LogEntry::Level level)
if(ClientWindow::mainExists())
{
ClientWindow::main().alerts()
.newAlert(msg, level >= LogEntry::ERROR? AlertDialog::Major :
level == LogEntry::WARNING? AlertDialog::Normal :
.newAlert(msg, level >= LogEntry::Error? AlertDialog::Major :
level == LogEntry::Warning? AlertDialog::Normal :
AlertDialog::Minor);
}
/**
Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/dd_help.cpp
Expand Up @@ -65,7 +65,7 @@ static void readStrings(File const &file)
String id = line.mid(1, end > 0? end - 1 : -1).trimmed().toLower();
node = &helps.insert(id, StringsByType()).value();

LOG_DEV_TRACE("Help node '%s'", id);
LOG_DEV_TRACE_DEBUGONLY("Help node '%s'", id);
}
else if(node && line.contains('=')) // It must be a key?
{
Expand Down Expand Up @@ -125,7 +125,7 @@ static void readStrings(File const &file)

node->insert(type, text);

LOG_DEV_TRACE("Help string (type %i): \"%s\"", type << text);
LOG_DEV_TRACE_DEBUGONLY("Help string (type %i): \"%s\"", type << text);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/filesys/filehandle.cpp
Expand Up @@ -136,7 +136,7 @@ FileHandle* FileHandleBuilder::fromLump(File1& lump, bool dontBuffer)
hndl->d->pos = hndl->d->data = (uint8_t*) M_Malloc(hndl->d->size);
if(!hndl->d->data) Con_Error("FileHandleBuilder::fromFileLump: Failed on allocation of %lu bytes for data buffer.", (unsigned long) hndl->d->size);

LOG_DEV_TRACE("[%p] Buffering \"%s:%s\"...",
LOG_DEV_TRACE_DEBUGONLY("[%p] Buffering \"%s:%s\"...",
dintptr(hndl) << NativePath(lump.container().composePath()).pretty() << NativePath(lump.composePath()).pretty());

lump.read((uint8_t*)hndl->d->data, 0, lump.size());
Expand Down
23 changes: 18 additions & 5 deletions doomsday/libdeng2/include/de/c_wrapper.h
Expand Up @@ -74,22 +74,35 @@ DENG2_PUBLIC int CommandLine_IsMatchingAlias(char const *original, char const *o
* LogBuffer
*/
// Log levels (see de::Log for description).
typedef enum legacycore_loglevel_e {
DE2_LOG_TRACE,
DE2_LOG_DEBUG,
typedef enum logentry_level_e {
DE2_LOG_XVERBOSE = 1,
DE2_LOG_VERBOSE,
DE2_LOG_MESSAGE,
DE2_LOG_INFO,
DE2_LOG_WARNING,
DE2_LOG_ERROR,
DE2_LOG_CRITICAL
} legacycore_loglevel_t;
} 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)
} logentry_audience_t;

#define DE2_LOG_DEBUG (DE2_LOG_DEV | DE2_LOG_VERBOSE)
#define DE2_LOG_TRACE (DE2_LOG_DEV | DE2_LOG_XVERBOSE)

DENG2_PUBLIC void LogBuffer_EnableStandardOutput(int enable);
DENG2_PUBLIC void LogBuffer_Flush(void);
DENG2_PUBLIC void LogBuffer_Clear(void);
DENG2_PUBLIC void LogBuffer_Msg(char const *text);
DENG2_PUBLIC void LogBuffer_Printf(legacycore_loglevel_t level, char const *format, ...);
DENG2_PUBLIC void LogBuffer_Printf(int levelAndAudience, char const *format, ...);

/*
* Info
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libdeng2/include/de/core/id.h
Expand Up @@ -90,7 +90,7 @@ class DENG2_PUBLIC Id : public ISerializable, public LogEntry::Arg::Base
void operator << (Reader &from);

// Implements LogEntry::Arg::Base.
LogEntry::Arg::Type logEntryArgType() const { return LogEntry::Arg::STRING; }
LogEntry::Arg::Type logEntryArgType() const { return LogEntry::Arg::StringArgument; }

private:
Type _id;
Expand Down

0 comments on commit 7e0a6c3

Please sign in to comment.