diff --git a/doomsday/client/include/clientapp.h b/doomsday/client/include/clientapp.h index 3b8c8fbe0a..b8947b1a8a 100644 --- a/doomsday/client/include/clientapp.h +++ b/doomsday/client/include/clientapp.h @@ -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(); diff --git a/doomsday/client/include/filesys/fileid.h b/doomsday/client/include/filesys/fileid.h index f0336ac222..34f592979a 100644 --- a/doomsday/client/include/filesys/fileid.h +++ b/doomsday/client/include/filesys/fileid.h @@ -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_; } diff --git a/doomsday/client/include/uri.hh b/doomsday/client/include/uri.hh index 1a35d68f42..bcb323d0bb 100644 --- a/doomsday/client/include/uri.hh +++ b/doomsday/client/include/uri.hh @@ -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; diff --git a/doomsday/client/src/clientapp.cpp b/doomsday/client/src/clientapp.cpp index 3a14b0117e..f5bdbfe845 100644 --- a/doomsday/client/src/clientapp.cpp +++ b/doomsday/client/src/clientapp.cpp @@ -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); } /** diff --git a/doomsday/client/src/dd_help.cpp b/doomsday/client/src/dd_help.cpp index 50cb2e391f..b46cc615e8 100644 --- a/doomsday/client/src/dd_help.cpp +++ b/doomsday/client/src/dd_help.cpp @@ -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? { @@ -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); } } } diff --git a/doomsday/client/src/filesys/filehandle.cpp b/doomsday/client/src/filesys/filehandle.cpp index c7b549129e..e89b3214ca 100644 --- a/doomsday/client/src/filesys/filehandle.cpp +++ b/doomsday/client/src/filesys/filehandle.cpp @@ -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()); diff --git a/doomsday/libdeng2/include/de/c_wrapper.h b/doomsday/libdeng2/include/de/c_wrapper.h index aadcb218e8..921b698d9b 100644 --- a/doomsday/libdeng2/include/de/c_wrapper.h +++ b/doomsday/libdeng2/include/de/c_wrapper.h @@ -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 diff --git a/doomsday/libdeng2/include/de/core/id.h b/doomsday/libdeng2/include/de/core/id.h index 9f18f652b7..d19aedc9b2 100644 --- a/doomsday/libdeng2/include/de/core/id.h +++ b/doomsday/libdeng2/include/de/core/id.h @@ -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; diff --git a/doomsday/libdeng2/include/de/core/log.h b/doomsday/libdeng2/include/de/core/log.h index e53c39a5cb..9d2505bc4d 100644 --- a/doomsday/libdeng2/include/de/core/log.h +++ b/doomsday/libdeng2/include/de/core/log.h @@ -54,26 +54,115 @@ de::Block __logSectionUtf8 = __logSectionName.toUtf8(); \ LOG_AS(__logSectionUtf8.constData()); -#define LOG_AT_LEVEL(level, str) de::LogEntryStager(level, str) -#define LOG_TRACE(str) LOG_AT_LEVEL(de::LogEntry::TRACE, str) -#define LOG_DEBUG(str) LOG_AT_LEVEL(de::LogEntry::DEBUG, str) -#define LOG_VERBOSE(str) LOG_AT_LEVEL(de::LogEntry::VERBOSE, str) -#define LOG_MSG(str) LOG_AT_LEVEL(de::LogEntry::MESSAGE, str) -#define LOG_INFO(str) LOG_AT_LEVEL(de::LogEntry::INFO, str) -#define LOG_WARNING(str) LOG_AT_LEVEL(de::LogEntry::WARNING, str) -#define LOG_ERROR(str) LOG_AT_LEVEL(de::LogEntry::ERROR, str) -#define LOG_CRITICAL(str) LOG_AT_LEVEL(de::LogEntry::CRITICAL, str) +// End-user/game audience: +#define LOG_AT_LEVEL(level, str) de::LogEntryStager(level, str) +#define LOG_XVERBOSE(str) LOG_AT_LEVEL(de::LogEntry::XVerbose, str) +#define LOG_VERBOSE(str) LOG_AT_LEVEL(de::LogEntry::Verbose, str) +#define LOG_MSG(str) LOG_AT_LEVEL(de::LogEntry::Message, str) +#define LOG_INFO(str) LOG_AT_LEVEL(de::LogEntry::Important, str) +#define LOG_WARNING(str) LOG_AT_LEVEL(de::LogEntry::Warning, str) +#define LOG_ERROR(str) LOG_AT_LEVEL(de::LogEntry::Error, str) +#define LOG_CRITICAL(str) LOG_AT_LEVEL(de::LogEntry::Critical, str) + +// Custom combination of audiences: +#define LOG_XVERBOSE_TO(audflags, str) LOG_AT_LEVEL(audflags | de::LogEntry::XVerbose, str) +#define LOG_VERBOSE_TO(audflags, str) LOG_AT_LEVEL(audflags | de::LogEntry::Verbose, str) +#define LOG_MSG_TO(audflags, str) LOG_AT_LEVEL(audflags | de::LogEntry::Message, str) +#define LOG_INFO_TO(audflags, str) LOG_AT_LEVEL(audflags | de::LogEntry::Important, str) +#define LOG_WARNING_TO(audflags, str) LOG_AT_LEVEL(audflags | de::LogEntry::Warning, str) +#define LOG_ERROR_TO(audflags, str) LOG_AT_LEVEL(audflags | de::LogEntry::Error, str) +#define LOG_CRITICAL_TO(audflags, str) LOG_AT_LEVEL(audflags | de::LogEntry::Critical, str) + +// Resource developer audience: +#define LOG_RES_AT_LEVEL(level, str) LOG_AT_LEVEL(de::LogEntry::Resource | level, str) +#define LOG_RES_XVERBOSE(str) LOG_RES_AT_LEVEL(de::LogEntry::XVerbose, str) +#define LOG_RES_VERBOSE(str) LOG_RES_AT_LEVEL(de::LogEntry::Verbose, str) +#define LOG_RES_MSG(str) LOG_RES_AT_LEVEL(de::LogEntry::Message, str) +#define LOG_RES_INFO(str) LOG_RES_AT_LEVEL(de::LogEntry::Info, str) +#define LOG_RES_WARNING(str) LOG_RES_AT_LEVEL(de::LogEntry::Warning, str) +#define LOG_RES_ERROR(str) LOG_RES_AT_LEVEL(de::LogEntry::Error, str) +#define LOG_RES_CRITICAL(str) LOG_RES_AT_LEVEL(de::LogEntry::Critical, str) + +// Map developer audience: +#define LOG_MAP_AT_LEVEL(level, str) LOG_AT_LEVEL(de::LogEntry::Map | level, str) +#define LOG_MAP_XVERBOSE(str) LOG_MAP_AT_LEVEL(de::LogEntry::XVerbose, str) +#define LOG_MAP_VERBOSE(str) LOG_MAP_AT_LEVEL(de::LogEntry::Verbose, str) +#define LOG_MAP_MSG(str) LOG_MAP_AT_LEVEL(de::LogEntry::Message, str) +#define LOG_MAP_INFO(str) LOG_MAP_AT_LEVEL(de::LogEntry::Info, str) +#define LOG_MAP_WARNING(str) LOG_MAP_AT_LEVEL(de::LogEntry::Warning, str) +#define LOG_MAP_ERROR(str) LOG_MAP_AT_LEVEL(de::LogEntry::Error, str) +#define LOG_MAP_CRITICAL(str) LOG_MAP_AT_LEVEL(de::LogEntry::Critical, str) + +// Script developer audience: +#define LOG_SCR_AT_LEVEL(level, str) LOG_AT_LEVEL(de::LogEntry::Script | level, str) +#define LOG_SCR_XVERBOSE(str) LOG_SCR_AT_LEVEL(de::LogEntry::XVerbose, str) +#define LOG_SCR_VERBOSE(str) LOG_SCR_AT_LEVEL(de::LogEntry::Verbose, str) +#define LOG_SCR_MSG(str) LOG_SCR_AT_LEVEL(de::LogEntry::Message, str) +#define LOG_SCR_INFO(str) LOG_SCR_AT_LEVEL(de::LogEntry::Info, str) +#define LOG_SCR_WARNING(str) LOG_SCR_AT_LEVEL(de::LogEntry::Warning, str) +#define LOG_SCR_ERROR(str) LOG_SCR_AT_LEVEL(de::LogEntry::Error, str) +#define LOG_SCR_CRITICAL(str) LOG_SCR_AT_LEVEL(de::LogEntry::Critical, str) + +// Audio audience: +#define LOG_AUDIO_AT_LEVEL(level, str) LOG_AT_LEVEL(de::LogEntry::Audio | level, str) +#define LOG_AUDIO_XVERBOSE(str) LOG_AUDIO_AT_LEVEL(de::LogEntry::XVerbose, str) +#define LOG_AUDIO_VERBOSE(str) LOG_AUDIO_AT_LEVEL(de::LogEntry::Verbose, str) +#define LOG_AUDIO_MSG(str) LOG_AUDIO_AT_LEVEL(de::LogEntry::Message, str) +#define LOG_AUDIO_INFO(str) LOG_AUDIO_AT_LEVEL(de::LogEntry::Info, str) +#define LOG_AUDIO_WARNING(str) LOG_AUDIO_AT_LEVEL(de::LogEntry::Warning, str) +#define LOG_AUDIO_ERROR(str) LOG_AUDIO_AT_LEVEL(de::LogEntry::Error, str) +#define LOG_AUDIO_CRITICAL(str) LOG_AUDIO_AT_LEVEL(de::LogEntry::Critical, str) + +// Graphics audience: +#define LOG_GL_AT_LEVEL(level, str) LOG_AT_LEVEL(de::LogEntry::GL | level, str) +#define LOG_GL_XVERBOSE(str) LOG_GL_AT_LEVEL(de::LogEntry::XVerbose, str) +#define LOG_GL_VERBOSE(str) LOG_GL_AT_LEVEL(de::LogEntry::Verbose, str) +#define LOG_GL_MSG(str) LOG_GL_AT_LEVEL(de::LogEntry::Message, str) +#define LOG_GL_INFO(str) LOG_GL_AT_LEVEL(de::LogEntry::Info, str) +#define LOG_GL_WARNING(str) LOG_GL_AT_LEVEL(de::LogEntry::Warning, str) +#define LOG_GL_ERROR(str) LOG_GL_AT_LEVEL(de::LogEntry::Error, str) +#define LOG_GL_CRITICAL(str) LOG_GL_AT_LEVEL(de::LogEntry::Critical, str) + +// Input audience: +#define LOG_INPUT_AT_LEVEL(level, str) LOG_AT_LEVEL(de::LogEntry::Input | level, str) +#define LOG_INPUT_XVERBOSE(str) LOG_INPUT_AT_LEVEL(de::LogEntry::XVerbose, str) +#define LOG_INPUT_VERBOSE(str) LOG_INPUT_AT_LEVEL(de::LogEntry::Verbose, str) +#define LOG_INPUT_MSG(str) LOG_INPUT_AT_LEVEL(de::LogEntry::Message, str) +#define LOG_INPUT_INFO(str) LOG_INPUT_AT_LEVEL(de::LogEntry::Info, str) +#define LOG_INPUT_WARNING(str) LOG_INPUT_AT_LEVEL(de::LogEntry::Warning, str) +#define LOG_INPUT_ERROR(str) LOG_INPUT_AT_LEVEL(de::LogEntry::Error, str) +#define LOG_INPUT_CRITICAL(str) LOG_INPUT_AT_LEVEL(de::LogEntry::Critical, str) + +// Network audience: +#define LOG_NET_AT_LEVEL(level, str) LOG_AT_LEVEL(de::LogEntry::Network | level, str) +#define LOG_NET_XVERBOSE(str) LOG_NET_AT_LEVEL(de::LogEntry::XVerbose, str) +#define LOG_NET_VERBOSE(str) LOG_NET_AT_LEVEL(de::LogEntry::Verbose, str) +#define LOG_NET_MSG(str) LOG_NET_AT_LEVEL(de::LogEntry::Message, str) +#define LOG_NET_INFO(str) LOG_NET_AT_LEVEL(de::LogEntry::Info, str) +#define LOG_NET_WARNING(str) LOG_NET_AT_LEVEL(de::LogEntry::Warning, str) +#define LOG_NET_ERROR(str) LOG_NET_AT_LEVEL(de::LogEntry::Error, str) +#define LOG_NET_CRITICAL(str) LOG_NET_AT_LEVEL(de::LogEntry::Critical, str) + +// Native code developer audience: +#define LOG_DEV_AT_LEVEL(level, str) LOG_AT_LEVEL(de::LogEntry::Dev | level, str) +#define LOG_DEV_XVERBOSE(str) LOG_DEV_AT_LEVEL(de::LogEntry::XVerbose, str) +#define LOG_TRACE(str) LOG_DEV_XVERBOSE(str) // backwards comp +#define LOG_DEV_VERBOSE(str) LOG_DEV_AT_LEVEL(de::LogEntry::Verbose, str) +#define LOG_DEBUG(str) LOG_DEV_VERBOSE(str) // backwards comp +#define LOG_DEV_MSG(str) LOG_DEV_AT_LEVEL(de::LogEntry::Message, str) +#define LOG_DEV_INFO(str) LOG_DEV_AT_LEVEL(de::LogEntry::Info, str) +#define LOG_DEV_WARNING(str) LOG_DEV_AT_LEVEL(de::LogEntry::Warning, str) +#define LOG_DEV_ERROR(str) LOG_DEV_AT_LEVEL(de::LogEntry::Error, str) #ifdef DENG2_DEBUG /** - * Makes a developer-only TRACE level log entry. Only enabled in debug builds; - * use this for internal messages that are only useful to / understood by - * developers when debugging. (Note that parameters differ compared to the - * normal LOG_* macros.) + * Makes a developer-only extra verbose level log entry. Only enabled in debug builds; use this + * for internal messages that might have a significant processing overhead. (Note that parameters + * differ compared to the normal LOG_* macros.) */ -# define LOG_DEV_TRACE(form, args) LOG_TRACE(form) << args +# define LOG_DEV_TRACE_DEBUGONLY(form, args) LOG_TRACE(form) << args #else -# define LOG_DEV_TRACE(form, args) +# define LOG_DEV_TRACE_DEBUGONLY(form, args) #endif #ifdef WIN32 @@ -99,94 +188,120 @@ class LogBuffer; class DENG2_PUBLIC LogEntry : public Lockable, public ISerializable { public: - /// Level of the log entry. - enum Level + /// Target audience of the entry (bits). If not given, the entry is intended for the + /// end-user/player. + enum Audience { - /** - * Trace messages are intended for low-level debugging. They should be used - * to log which methods are entered and exited, and mark certain points within - * methods. Intended only for developers and debug builds. - */ - TRACE = 0, + Resource = 0x10000, ///< Resource or resource pack developer (files, etc.) + Map = 0x20000, ///< Map developer + Script = 0x40000, ///< Script developer + GL = 0x80000, ///< GL developer (shaders, etc.) + Audio = 0x100000, ///< Audio developer + Input = 0x200000, ///< Input events, devices, etc. + Network = 0x400000, ///< Network connections, packets, etc. + Dev = 0x800000, ///< Native code developer (i.e., the programmer) + + AudienceMask = 0xff0000 + }; - /** - * Debug messages are intended for normal debugging. They should be enabled - * only in debug builds. An example of a debug message might be a printout of - * a ZIP archive's file count and size once an archive has been successfully - * opened. Intended only for developers and debug builds. - */ - DEBUG = 1, + static String audienceToText(Audience audience) + { + switch(audience) + { + case Resource: return "Resource"; + case Map: return "Map"; + case Script: return "Script"; + case GL: return "GL"; + case Audio: return "Audio"; + case Input: return "Input"; + case Network: return "Network"; + case Dev: return "Dev"; + default: return ""; + } + } + static Audience textToAudience(String text) + { + for(int i = 16; i < 32; ++i) + { + if(!audienceToText(Audience(1 << i)).compareWithoutCase(text)) + return Audience(1 << i); + } + throw de::Error("Log::textToAudience", "'" + text + "' is not a valid log audience"); + } + + /// Importance level of the log entry. + enum Level + { /** - * Verbose messages should be used to log technical information that is only - * of interest to advanced users. An example of a verbose message could be - * the summary of all the defined object types during the launch of a game. - * Verbose messages should not be used for anything that produces a large - * number of log entries, such as an entry about reading the contents of a - * file within a ZIP archive (which would be suitable for the DEBUG level). + * Verbose messages should be used for logging additional/supplementary information. All + * verbose messages can be safely ignored. */ - VERBOSE = 2, + XVerbose = 1, + Verbose = 2, /** - * Normal log entries are intended for regular users. An example: message about - * which map is being loaded. + * The base level: normal log entries. */ - MESSAGE = 3, + Message = 3, /** - * Info messages are intended for situations that are particularly noteworthy. - * An info message should be used for instance when a script has been stopped - * because of an uncaught exception occurred during its execution. + * Important messages are intended for situations that are particularly noteworthy. They + * will not cause an alert to be raised, but the information is deemed particularly + * valuable. */ - INFO = 4, + Important = 4, /** - * Warning messages are reserved for recoverable error situations. A warning - * might be logged for example when the expected resource could not be found, - * and a fallback resource was used instead. + * Warning messages are reserved for error situations that were automatically recovered + * from. A warning might be logged for example when the expected resource could not be + * found, and a fallback resource was used instead. Warnings will cause an alert to be + * raised so that the target audience is aware of the problem. */ - WARNING = 5, + Warning = 5, /** - * Error messages are intended for nonrecoverable errors. The error is grave - * enough to cause the shutting down of the current game, but the engine can - * still remain running. + * Error messages are intended for errors that could not be (fully) recovered from. The + * error is grave enough to possibly cause the shutting down of the current game, however + * the engine can still remain running. Will cause an alert to be raised so that the + * target audience is aware of the problem. */ - ERROR = 6, + Error = 6, /** - * Critical messages are intended for fatal errors that cause the engine to be - * shut down. + * Critical messages are intended for fatal errors that cause the engine to be shut down. */ - CRITICAL = 7, + Critical = 7, - MAX_LOG_LEVELS - }; + MAX_LOG_LEVELS, + LOWEST_LOG_LEVEL = XVerbose, + + LevelMask = 0x7 + }; static String levelToText(Level level) { switch(level) { - case TRACE: return "TRACE"; - case DEBUG: return "DEBUG"; - case VERBOSE: return "VERBOSE"; - case MESSAGE: return "MESSAGE"; - case INFO: return "INFO"; - case WARNING: return "WARNING"; - case ERROR: return "ERROR"; - case CRITICAL: return "CRITICAL"; + case XVerbose: return "XVerbose"; + case Verbose: return "Verbose"; + case Message: return "Message"; + case Important: return "Important"; + case Warning: return "Warning"; + case Error: return "Error"; + case Critical: return "Critical"; default: return ""; } } static Level textToLevel(String text) { - for(int i = TRACE; i < MAX_LOG_LEVELS; ++i) + for(int i = XVerbose; i < MAX_LOG_LEVELS; ++i) { if(!levelToText(Level(i)).compareWithoutCase(text)) return Level(i); } - throw Error("Log::textToLevel", "'" + text + "' is not a valid log level"); + throw de::Error("Log::textToLevel", "'" + text + "' is not a valid log level"); } /** @@ -202,9 +317,9 @@ class DENG2_PUBLIC LogEntry : public Lockable, public ISerializable DENG2_ERROR(TypeError); enum Type { - INTEGER, - FLOATING_POINT, - STRING + IntegerArgument, + FloatingPointArgument, + StringArgument }; /** @@ -234,17 +349,17 @@ class DENG2_PUBLIC LogEntry : public Lockable, public ISerializable }; public: - Arg() : _type(INTEGER) { _data.intValue = 0; } - Arg(dint i) : _type(INTEGER) { _data.intValue = i; } - Arg(duint i) : _type(INTEGER) { _data.intValue = i; } - Arg(long int i) : _type(INTEGER) { _data.intValue = i; } - Arg(long unsigned int i) : _type(INTEGER) { _data.intValue = i; } - Arg(duint64 i) : _type(INTEGER) { _data.intValue = dint64(i); } - Arg(dint64 i) : _type(INTEGER) { _data.intValue = i; } - Arg(ddouble d) : _type(FLOATING_POINT) { _data.floatValue = d; } - Arg(void const *p) : _type(INTEGER) { _data.intValue = dint64(p); } - Arg(char const *s) : _type(STRING) { _data.stringValue = new String(s); } - Arg(String const &s) : _type(STRING) { _data.stringValue = new String(s.data(), s.size()); } + Arg() : _type(IntegerArgument) { _data.intValue = 0; } + Arg(dint i) : _type(IntegerArgument) { _data.intValue = i; } + Arg(duint i) : _type(IntegerArgument) { _data.intValue = i; } + Arg(long int i) : _type(IntegerArgument) { _data.intValue = i; } + Arg(long unsigned int i) : _type(IntegerArgument) { _data.intValue = i; } + Arg(duint64 i) : _type(IntegerArgument) { _data.intValue = dint64(i); } + Arg(dint64 i) : _type(IntegerArgument) { _data.intValue = i; } + Arg(ddouble d) : _type(FloatingPointArgument) { _data.floatValue = d; } + Arg(void const *p) : _type(IntegerArgument) { _data.intValue = dint64(p); } + Arg(char const *s) : _type(StringArgument) { _data.stringValue = new String(s); } + Arg(String const &s) : _type(StringArgument) { _data.stringValue = new String(s.data(), s.size()); } Arg(Base const &arg); Arg(Arg const &other); @@ -253,15 +368,15 @@ class DENG2_PUBLIC LogEntry : public Lockable, public ISerializable inline Type type() const { return _type; } inline dint64 intValue() const { - DENG2_ASSERT(_type == INTEGER); + DENG2_ASSERT(_type == IntegerArgument); return _data.intValue; } inline ddouble floatValue() const { - DENG2_ASSERT(_type == FLOATING_POINT); + DENG2_ASSERT(_type == FloatingPointArgument); return _data.floatValue; } inline QString stringValue() const { - DENG2_ASSERT(_type == STRING); + DENG2_ASSERT(_type == StringArgument); return *_data.stringValue; } @@ -320,7 +435,7 @@ class DENG2_PUBLIC LogEntry : public Lockable, public ISerializable */ LogEntry(); - LogEntry(Level level, String const §ion, int sectionDepth, String const &format, Args args); + LogEntry(duint32 levelAndAudience, String const §ion, int sectionDepth, String const &format, Args args); /** * Copy constructor. @@ -337,7 +452,9 @@ class DENG2_PUBLIC LogEntry : public Lockable, public ISerializable /// Returns the timestamp of the entry. Time when() const { return _when; } - Level level() const { return _level; } + inline duint32 audience() const { return _levelAudience & AudienceMask; } + + inline Level level() const { return Level(_levelAudience & LevelMask); } /// Returns a reference to the entry's section part. Reference is valid /// for the lifetime of the entry. @@ -367,7 +484,7 @@ class DENG2_PUBLIC LogEntry : public Lockable, public ISerializable private: Time _when; - Level _level; + duint32 _levelAudience; String _section; int _sectionDepth; String _format; @@ -431,7 +548,7 @@ class DENG2_PUBLIC Log void endSection(char const *name); /** - * Creates a new log entry with the default (MESSAGE) level. + * Creates a new log entry with the default (Message) level, targeted to the end-user. * * @param format Format template of the entry. * @param arguments List of arguments. The entry is given ownership of @@ -442,12 +559,12 @@ class DENG2_PUBLIC Log /** * Creates a new log entry with the specified log entry level. * - * @param level Level of the entry. - * @param format Format template of the entry. - * @param arguments List of arguments. The entry is given ownership of - * each Arg instance. + * @param levelAndAudience Level of the entry and target audience bits. + * @param format Format template of the entry. + * @param arguments List of arguments. The entry is given ownership of + * each Arg instance. */ - LogEntry &enter(LogEntry::Level level, String const &format, LogEntry::Args arguments = LogEntry::Args()); + LogEntry &enter(duint32 levelAndAudience, String const &format, LogEntry::Args arguments = LogEntry::Args()); public: /** @@ -477,7 +594,7 @@ class DENG2_PUBLIC Log class DENG2_PUBLIC LogEntryStager { public: - LogEntryStager(LogEntry::Level level, String const &format); + LogEntryStager(duint32 levelAndAudience, String const &format); /// Appends a new argument to the entry. template @@ -498,7 +615,7 @@ class DENG2_PUBLIC LogEntryStager private: bool _disabled; - LogEntry::Level _level; + duint32 _level; String _format; LogEntry::Args _args; }; diff --git a/doomsday/libdeng2/include/de/core/logbuffer.h b/doomsday/libdeng2/include/de/core/logbuffer.h index 405a543199..7fd2ae462e 100644 --- a/doomsday/libdeng2/include/de/core/logbuffer.h +++ b/doomsday/libdeng2/include/de/core/logbuffer.h @@ -99,7 +99,7 @@ class DENG2_PUBLIC LogBuffer : public QObject, public Lockable, DENG2_OBSERVES(F * Enables log entries at or over a level. When a level is disabled, the * entries will not be added to the log entry buffer. */ - void enable(LogEntry::Level overLevel = LogEntry::MESSAGE); + void enable(LogEntry::Level overLevel = LogEntry::Message); /** * Disables the log. @@ -107,7 +107,7 @@ class DENG2_PUBLIC LogBuffer : public QObject, public Lockable, DENG2_OBSERVES(F */ void disable() { enable(LogEntry::MAX_LOG_LEVELS); } - bool isEnabled(LogEntry::Level overLevel = LogEntry::MESSAGE) const; + bool isEnabled(LogEntry::Level overLevel = LogEntry::Message) const; /** * Enables or disables standard output of log messages. When enabled, @@ -168,7 +168,7 @@ class DENG2_PUBLIC LogBuffer : public QObject, public Lockable, DENG2_OBSERVES(F static LogBuffer &appBuffer(); - static bool isAppBufferAvailable(); + static bool appBufferExists(); public slots: /** diff --git a/doomsday/libdeng2/include/de/core/memorylogsink.h b/doomsday/libdeng2/include/de/core/memorylogsink.h index f4e1a1ba52..488945b04d 100644 --- a/doomsday/libdeng2/include/de/core/memorylogsink.h +++ b/doomsday/libdeng2/include/de/core/memorylogsink.h @@ -32,7 +32,7 @@ namespace de { class DENG2_PUBLIC MemoryLogSink : public LogSink, public Lockable { public: - MemoryLogSink(LogEntry::Level minimumLevel = LogEntry::DEBUG); + MemoryLogSink(LogEntry::Level minimumLevel = LogEntry::XVerbose); ~MemoryLogSink(); LogSink &operator << (LogEntry const &entry); diff --git a/doomsday/libdeng2/include/de/data/date.h b/doomsday/libdeng2/include/de/data/date.h index a0c030ecc4..383e2e1de0 100644 --- a/doomsday/libdeng2/include/de/data/date.h +++ b/doomsday/libdeng2/include/de/data/date.h @@ -64,7 +64,7 @@ class DENG2_PUBLIC Date : public Time, public LogEntry::Arg::Base // Implements LogEntry::Arg::Base. LogEntry::Arg::Type logEntryArgType() const { - return LogEntry::Arg::STRING; + return LogEntry::Arg::StringArgument; } }; diff --git a/doomsday/libdeng2/include/de/data/path.h b/doomsday/libdeng2/include/de/data/path.h index 95397d955e..6779db7bb8 100644 --- a/doomsday/libdeng2/include/de/data/path.h +++ b/doomsday/libdeng2/include/de/data/path.h @@ -406,7 +406,7 @@ class DENG2_PUBLIC Path : public ISerializable, public LogEntry::Arg::Base } // Implements LogEntry::Arg::Base. - LogEntry::Arg::Type logEntryArgType() const { return LogEntry::Arg::STRING; } + LogEntry::Arg::Type logEntryArgType() const { return LogEntry::Arg::StringArgument; } String asText() const { return toString(); } diff --git a/doomsday/libdeng2/include/de/data/record.h b/doomsday/libdeng2/include/de/data/record.h index 64945aded7..9bb2bf3214 100644 --- a/doomsday/libdeng2/include/de/data/record.h +++ b/doomsday/libdeng2/include/de/data/record.h @@ -342,7 +342,7 @@ class DENG2_PUBLIC Record : 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; } String asText() const { return asText("", 0); } // Observes Variable deletion. diff --git a/doomsday/libdeng2/include/de/libdeng2.h b/doomsday/libdeng2/include/de/libdeng2.h index 91919a0216..0dd5135824 100644 --- a/doomsday/libdeng2/include/de/libdeng2.h +++ b/doomsday/libdeng2/include/de/libdeng2.h @@ -449,7 +449,9 @@ enum ProtocolVersion { DENG2_PROTOCOL_1_10_0 = 0, DENG2_PROTOCOL_1_11_0_BUILD_926 = 1, // Time serilization changed DENG2_PROTOCOL_1_11_0 = 1, - DENG2_PROTOCOL_LATEST = DENG2_PROTOCOL_1_11_0 + DENG2_PROTOCOL_1_14_0_BUILD_1099 = 2, // LogEntry serialization changed + DENG2_PROTOCOL_1_14_0 = 2, + DENG2_PROTOCOL_LATEST = DENG2_PROTOCOL_1_14_0 }; //@{ diff --git a/doomsday/libdeng2/include/de/net/address.h b/doomsday/libdeng2/include/de/net/address.h index 8749174b2c..2af5271018 100644 --- a/doomsday/libdeng2/include/de/net/address.h +++ b/doomsday/libdeng2/include/de/net/address.h @@ -106,7 +106,7 @@ class DENG2_PUBLIC Address : public LogEntry::Arg::Base static bool isHostLocal(QHostAddress const &host); // Implements LogEntry::Arg::Base. - LogEntry::Arg::Type logEntryArgType() const { return LogEntry::Arg::STRING; } + LogEntry::Arg::Type logEntryArgType() const { return LogEntry::Arg::StringArgument; } private: DENG2_PRIVATE(d) diff --git a/doomsday/libdeng2/src/c_wrapper.cpp b/doomsday/libdeng2/src/c_wrapper.cpp index 46b33ce8bc..a31c9d9c42 100644 --- a/doomsday/libdeng2/src/c_wrapper.cpp +++ b/doomsday/libdeng2/src/c_wrapper.cpp @@ -129,7 +129,7 @@ void LogBuffer_EnableStandardOutput(int enable) de::LogBuffer::appBuffer().enableStandardOutput(enable != 0); } -static void logFragmentPrinter(de::LogEntry::Level level, char const *fragment) +static void logFragmentPrinter(duint32 levelAndAudience, char const *fragment) { static std::string currentLogLine; @@ -138,23 +138,23 @@ static void logFragmentPrinter(de::LogEntry::Level level, char const *fragment) std::string::size_type pos; while((pos = currentLogLine.find('\n')) != std::string::npos) { - LOG().enter(level, currentLogLine.substr(0, pos).c_str()); + LOG().enter(levelAndAudience, currentLogLine.substr(0, pos).c_str()); currentLogLine.erase(0, pos + 1); } } void LogBuffer_Msg(char const *text) { - logFragmentPrinter(de::LogEntry::MESSAGE, text); + logFragmentPrinter(de::LogEntry::Message, text); } -void LogBuffer_Printf(legacycore_loglevel_t level, char const *format, ...) +void LogBuffer_Printf(int levelAndAudience, char const *format, ...) { // Validate the level. - de::LogEntry::Level logLevel = de::LogEntry::Level(level); - if(level < DE2_LOG_TRACE || level > DE2_LOG_CRITICAL) + de::LogEntry::Level logLevel = de::LogEntry::Level(levelAndAudience & de::LogEntry::LevelMask); + if(logLevel < de::LogEntry::XVerbose || logLevel > de::LogEntry::Critical) { - logLevel = de::LogEntry::MESSAGE; + logLevel = de::LogEntry::Message; } // If this level is not enabled, just ignore. @@ -166,7 +166,7 @@ void LogBuffer_Printf(legacycore_loglevel_t level, char const *format, ...) vsprintf(buffer, format, args); /// @todo unsafe va_end(args); - logFragmentPrinter(logLevel, buffer); + logFragmentPrinter(logLevel | (levelAndAudience & de::LogEntry::AudienceMask), buffer); } Info *Info_NewFromString(char const *utf8text) diff --git a/doomsday/libdeng2/src/core/app.cpp b/doomsday/libdeng2/src/core/app.cpp index dbd05eefa7..317f1ae4bd 100644 --- a/doomsday/libdeng2/src/core/app.cpp +++ b/doomsday/libdeng2/src/core/app.cpp @@ -180,11 +180,7 @@ App::App(NativePath const &appFilePath, QStringList args) d->logBuffer.enableFlushing(false); // Set the log message level. -#ifdef DENG2_DEBUG - LogEntry::Level level = LogEntry::DEBUG; -#else - LogEntry::Level level = LogEntry::MESSAGE; -#endif + LogEntry::Level level = LogEntry::Message; try { int pos; @@ -198,7 +194,7 @@ App::App(NativePath const &appFilePath, QStringList args) qWarning("%s", er.asText().toLatin1().constData()); } // Aliases have not been defined at this point. - level = de::max(LogEntry::TRACE, + level = de::max(LogEntry::XVerbose, LogEntry::Level(level - d->cmdLine.has("-verbose") - d->cmdLine.has("-v"))); diff --git a/doomsday/libdeng2/src/core/log.cpp b/doomsday/libdeng2/src/core/log.cpp index 02a87590d5..61cf0040ce 100644 --- a/doomsday/libdeng2/src/core/log.cpp +++ b/doomsday/libdeng2/src/core/log.cpp @@ -68,15 +68,15 @@ LogEntry::Arg::Arg(const LogEntry::Arg::Base &arg) : _type(arg.logEntryArgType() { switch(_type) { - case INTEGER: + case IntegerArgument: _data.intValue = arg.asInt64(); break; - case FLOATING_POINT: + case FloatingPointArgument: _data.floatValue = arg.asDouble(); break; - case STRING: { + case StringArgument: { String s = arg.asText(); _data.stringValue = new String(s.data(), s.size()); break; } @@ -88,15 +88,15 @@ LogEntry::Arg::Arg(Arg const &other) { switch(other._type) { - case INTEGER: + case IntegerArgument: _data.intValue = other._data.intValue; break; - case FLOATING_POINT: + case FloatingPointArgument: _data.floatValue = other._data.floatValue; break; - case STRING: + case StringArgument: _data.stringValue = new String(*other._data.stringValue); break; } @@ -104,7 +104,7 @@ LogEntry::Arg::Arg(Arg const &other) LogEntry::Arg::~Arg() { - if(_type == STRING) + if(_type == StringArgument) { delete _data.stringValue; } @@ -112,11 +112,11 @@ LogEntry::Arg::~Arg() ddouble LogEntry::Arg::asNumber() const { - if(_type == INTEGER) + if(_type == IntegerArgument) { return ddouble(_data.intValue); } - else if(_type == FLOATING_POINT) + else if(_type == FloatingPointArgument) { return _data.floatValue; } @@ -125,15 +125,15 @@ ddouble LogEntry::Arg::asNumber() const String LogEntry::Arg::asText() const { - if(_type == STRING) + if(_type == StringArgument) { return *_data.stringValue; } - else if(_type == INTEGER) + else if(_type == IntegerArgument) { return String::number(_data.intValue); } - else if(_type == FLOATING_POINT) + else if(_type == FloatingPointArgument) { return String::number(_data.floatValue); } @@ -146,15 +146,15 @@ void LogEntry::Arg::operator >> (Writer &to) const switch(_type) { - case INTEGER: + case IntegerArgument: to << _data.intValue; break; - case FLOATING_POINT: + case FloatingPointArgument: to << _data.floatValue; break; - case STRING: + case StringArgument: to << *_data.stringValue; break; } @@ -162,53 +162,54 @@ void LogEntry::Arg::operator >> (Writer &to) const void LogEntry::Arg::operator << (Reader &from) { - if(_type == STRING) delete _data.stringValue; + if(_type == StringArgument) delete _data.stringValue; from.readAs(_type); switch(_type) { - case INTEGER: + case IntegerArgument: from >> _data.intValue; break; - case FLOATING_POINT: + case FloatingPointArgument: from >> _data.floatValue; break; - case STRING: + case StringArgument: _data.stringValue = new String; from >> *_data.stringValue; break; } } -LogEntry::LogEntry() : _level(TRACE), _sectionDepth(0), _disabled(true) +LogEntry::LogEntry() : _levelAudience(0), _sectionDepth(0), _disabled(true) {} -LogEntry::LogEntry(Level level, String const §ion, int sectionDepth, String const &format, Args args) - : _level(level), - _section(section), - _sectionDepth(sectionDepth), - _format(format), - _disabled(false), - _args(args) +LogEntry::LogEntry(duint32 levelAndAudience, String const §ion, int sectionDepth, String const &format, Args args) + : _levelAudience(levelAndAudience) + , _section(section) + , _sectionDepth(sectionDepth) + , _format(format) + , _disabled(false) + , _args(args) { - if(!LogBuffer::appBuffer().isEnabled(level)) + if(!LogBuffer::appBuffer().isEnabled(level())) { _disabled = true; } } LogEntry::LogEntry(LogEntry const &other, Flags extraFlags) - : Lockable(), ISerializable(), - _when(other._when), - _level(other._level), - _section(other._section), - _sectionDepth(other._sectionDepth), - _format(other._format), - _defaultFlags(other._defaultFlags | extraFlags), - _disabled(other._disabled) + : Lockable() + , ISerializable() + , _when(other._when) + , _levelAudience(other._levelAudience) + , _section(other._section) + , _sectionDepth(other._sectionDepth) + , _format(other._format) + , _defaultFlags(other._defaultFlags | extraFlags) + , _disabled(other._disabled) { DENG2_FOR_EACH_CONST(Args, i, other._args) { @@ -260,8 +261,8 @@ String LogEntry::asText(Flags const &formattingFlags, int shortenSection) const if(!flags.testFlag(Styled)) { char const *levelNames[LogEntry::MAX_LOG_LEVELS] = { - "(...)", - "(deb)", + "", // not used + "(vv)", "(v)", "", "(i)", @@ -269,26 +270,26 @@ String LogEntry::asText(Flags const &formattingFlags, int shortenSection) const "(ERR)", "(!!!)" }; - output << qSetPadChar(' ') << qSetFieldWidth(5) << levelNames[_level] << + output << qSetPadChar(' ') << qSetFieldWidth(5) << levelNames[level()] << qSetFieldWidth(0) << " "; } else { char const *levelNames[LogEntry::MAX_LOG_LEVELS] = { - "Trace", - "Debug", + "", // not used + "XVerbose", "Verbose", "", - "Info", + "Important", "Warning", "ERROR", "FATAL!" }; output << "\t" - << (_level >= LogEntry::WARNING? TEXT_STYLE_BAD_SECTION : - _level <= LogEntry::DEBUG? TEXT_STYLE_DEBUG_SECTION : - TEXT_STYLE_SECTION) - << levelNames[_level] << "\t"; + << (level() >= LogEntry::Warning? TEXT_STYLE_MAJOR_SECTION : + level() <= LogEntry::XVerbose? TEXT_STYLE_MINOR_SECTION : + TEXT_STYLE_SECTION) + << levelNames[level()] << "\t"; } } } @@ -299,9 +300,9 @@ String LogEntry::asText(Flags const &formattingFlags, int shortenSection) const if(flags.testFlag(Styled)) { output << TEXT_MARK_INDENT - << (_level >= LogEntry::WARNING? TEXT_STYLE_BAD_SECTION : - _level <= LogEntry::DEBUG? TEXT_STYLE_DEBUG_SECTION : - TEXT_STYLE_SECTION); + << (level() >= LogEntry::Warning? TEXT_STYLE_MAJOR_SECTION : + level() <= LogEntry::XVerbose? TEXT_STYLE_MINOR_SECTION : + TEXT_STYLE_SECTION); } // Process the section: shortening and possible abbreviation. @@ -371,9 +372,9 @@ String LogEntry::asText(Flags const &formattingFlags, int shortenSection) const if(flags.testFlag(Styled)) { output << TEXT_MARK_INDENT - << (_level >= LogEntry::WARNING? TEXT_STYLE_BAD_MESSAGE : - _level <= LogEntry::DEBUG? TEXT_STYLE_DEBUG_MESSAGE : - TEXT_STYLE_MESSAGE); + << (level() >= LogEntry::Warning? TEXT_STYLE_MAJOR_MESSAGE : + level() <= LogEntry::XVerbose? TEXT_STYLE_MINOR_MESSAGE : + TEXT_STYLE_MESSAGE); } // Message text with the arguments formatted. @@ -396,7 +397,7 @@ void LogEntry::operator >> (Writer &to) const to << _when << _section << _format - << dbyte(_level) + << duint32(_levelAudience) << dbyte(_sectionDepth) << duint32(_defaultFlags); @@ -411,8 +412,20 @@ void LogEntry::operator << (Reader &from) from >> _when >> _section >> _format; - from.readAs(_level) - .readAs(_sectionDepth) + + if(from.version() >= DENG2_PROTOCOL_1_14_0_BUILD_1099) + { + // This version adds audience information to the entry. + from.readAs(_levelAudience); + } + else + { + dbyte oldLevel; + from >> oldLevel; + _levelAudience = oldLevel; // lacks audience information + } + + from.readAs(_sectionDepth) .readAs(_defaultFlags) .readObjects(_args); } @@ -421,15 +434,15 @@ QTextStream &operator << (QTextStream &stream, LogEntry::Arg const &arg) { switch(arg.type()) { - case LogEntry::Arg::INTEGER: + case LogEntry::Arg::IntegerArgument: stream << arg.intValue(); break; - case LogEntry::Arg::FLOATING_POINT: + case LogEntry::Arg::FloatingPointArgument: stream << arg.floatValue(); break; - case LogEntry::Arg::STRING: + case LogEntry::Arg::StringArgument: stream << arg.stringValue(); break; } @@ -470,12 +483,12 @@ void Log::endSection(char const *DENG2_DEBUG_ONLY(name)) LogEntry &Log::enter(String const &format, LogEntry::Args arguments) { - return enter(LogEntry::MESSAGE, format, arguments); + return enter(LogEntry::Message, format, arguments); } -LogEntry &Log::enter(LogEntry::Level level, String const &format, LogEntry::Args arguments) +LogEntry &Log::enter(duint32 levelAndAudience, String const &format, LogEntry::Args arguments) { - if(!LogBuffer::appBuffer().isEnabled(level)) + if(!LogBuffer::appBuffer().isEnabled(LogEntry::Level(levelAndAudience & LogEntry::LevelMask))) { DENG2_ASSERT(arguments.isEmpty()); @@ -504,7 +517,7 @@ LogEntry &Log::enter(LogEntry::Level level, String const &format, LogEntry::Args } // Make a new entry. - LogEntry *entry = new LogEntry(level, context, depth, format, arguments); + LogEntry *entry = new LogEntry(levelAndAudience, context, depth, format, arguments); // Add it to the application's buffer. The buffer gets ownership. LogBuffer::appBuffer().add(entry); @@ -555,10 +568,12 @@ void Log::disposeThreadLog() } } -LogEntryStager::LogEntryStager(LogEntry::Level level, String const &format) : _level(level) +LogEntryStager::LogEntryStager(duint32 levelAndAudience, String const &format) + : _level(levelAndAudience) { - _disabled = !LogBuffer::isAppBufferAvailable() || - !LogBuffer::appBuffer().isEnabled(level); + _disabled = !LogBuffer::appBufferExists() || + !LogBuffer::appBuffer().isEnabled(LogEntry::Level(levelAndAudience & + LogEntry::LevelMask)); if(!_disabled) { _format = format; diff --git a/doomsday/libdeng2/src/core/logbuffer.cpp b/doomsday/libdeng2/src/core/logbuffer.cpp index 359e088f4e..e5f4d090a4 100644 --- a/doomsday/libdeng2/src/core/logbuffer.cpp +++ b/doomsday/libdeng2/src/core/logbuffer.cpp @@ -64,7 +64,7 @@ DENG2_PIMPL_NOREF(LogBuffer) Sinks sinks; Instance(duint maxEntryCount) - : enabledOverLevel(LogEntry::MESSAGE), + : enabledOverLevel(LogEntry::Message), maxEntryCount(maxEntryCount), useStandardOutput(true), flushingEnabled(true), @@ -323,7 +323,7 @@ LogBuffer &LogBuffer::appBuffer() return *_appBuffer; } -bool LogBuffer::isAppBufferAvailable() +bool LogBuffer::appBufferExists() { return _appBuffer != 0; } diff --git a/doomsday/libdeng2/src/core/logsink.cpp b/doomsday/libdeng2/src/core/logsink.cpp index b4db47ab39..8d1a0b58c2 100644 --- a/doomsday/libdeng2/src/core/logsink.cpp +++ b/doomsday/libdeng2/src/core/logsink.cpp @@ -55,10 +55,10 @@ bool LogSink::willAccept(LogEntry const &entry) const return false; case OnlyNormalEntries: - return entry.level() < LogEntry::WARNING; + return entry.level() < LogEntry::Warning; case OnlyWarningEntries: - return entry.level() >= LogEntry::WARNING; + return entry.level() >= LogEntry::Warning; } return false; } diff --git a/doomsday/libdeng2/src/core/logtextstyle.h b/doomsday/libdeng2/src/core/logtextstyle.h index cd420cdae8..f5ed4d8965 100644 --- a/doomsday/libdeng2/src/core/logtextstyle.h +++ b/doomsday/libdeng2/src/core/logtextstyle.h @@ -31,11 +31,11 @@ namespace de { char const *TEXT_STYLE_NORMAL = DENG2_ESC("0"); // normal char const *TEXT_STYLE_MESSAGE = DENG2_ESC("0"); // normal -char const *TEXT_STYLE_BAD_MESSAGE = DENG2_ESC("1"); // major -char const *TEXT_STYLE_DEBUG_MESSAGE = DENG2_ESC("2"); // minor +char const *TEXT_STYLE_MAJOR_MESSAGE = DENG2_ESC("1"); // major +char const *TEXT_STYLE_MINOR_MESSAGE = DENG2_ESC("2"); // minor char const *TEXT_STYLE_SECTION = DENG2_ESC("3"); // meta -char const *TEXT_STYLE_BAD_SECTION = DENG2_ESC("4"); // major meta -char const *TEXT_STYLE_DEBUG_SECTION = DENG2_ESC("5"); // minor meta +char const *TEXT_STYLE_MAJOR_SECTION = DENG2_ESC("4"); // major meta +char const *TEXT_STYLE_MINOR_SECTION = DENG2_ESC("5"); // minor meta char const *TEXT_STYLE_LOG_TIME = DENG2_ESC("6"); // aux meta char const *TEXT_MARK_INDENT = DENG2_ESC(">"); diff --git a/doomsday/libdeng2/src/data/record.cpp b/doomsday/libdeng2/src/data/record.cpp index 528016ab0e..c87d6fedba 100644 --- a/doomsday/libdeng2/src/data/record.cpp +++ b/doomsday/libdeng2/src/data/record.cpp @@ -161,7 +161,7 @@ DENG2_PIMPL(Record) duint32 oldTargetId = value->record()->d->oldUniqueId; if(refMap.contains(oldTargetId)) { - LOG_DEV_TRACE("RecordValue %p restored to reference record %i (%p)", + LOG_DEV_TRACE_DEBUGONLY("RecordValue %p restored to reference record %i (%p)", value << oldTargetId << refMap[oldTargetId]); // Relink the value to its target. @@ -527,7 +527,7 @@ void Record::variableBeingDeleted(Variable &variable) { DENG2_ASSERT(d->findMemberByPath(variable.name()) != 0); - LOG_DEV_TRACE("Variable %p deleted, removing from Record %p", &variable << this); + LOG_DEV_TRACE_DEBUGONLY("Variable %p deleted, removing from Record %p", &variable << this); // Remove from our index. d->members.remove(variable.name()); diff --git a/doomsday/libdeng2/src/filesys/filesystem.cpp b/doomsday/libdeng2/src/filesys/filesystem.cpp index 5d87be6b31..8538383714 100644 --- a/doomsday/libdeng2/src/filesys/filesystem.cpp +++ b/doomsday/libdeng2/src/filesys/filesystem.cpp @@ -88,7 +88,7 @@ Folder &FileSystem::makeFolder(String const &path, FolderCreationBehaviors behav Feed *feed = (*i)->newSubFeed(subFolder->name()); if(!feed) continue; // Check next one instead. - LOG_DEV_TRACE("Creating subfeed \"%s\" from %s", + LOG_DEV_TRACE_DEBUGONLY("Creating subfeed \"%s\" from %s", subFolder->name() << (*i)->description()); subFolder->attach(feed); diff --git a/doomsday/libdeng2/src/scriptsys/operatorexpression.cpp b/doomsday/libdeng2/src/scriptsys/operatorexpression.cpp index 704dd822bc..c20a93adb1 100644 --- a/doomsday/libdeng2/src/scriptsys/operatorexpression.cpp +++ b/doomsday/libdeng2/src/scriptsys/operatorexpression.cpp @@ -217,7 +217,7 @@ Value *OperatorExpression::evaluate(Evaluator &evaluator) const case INDEX: { /* - LOG_DEV_TRACE("INDEX: types %s [ %s ] byref:%b", + LOG_DEV_TRACE_DEBUGONLY("INDEX: types %s [ %s ] byref:%b", DENG2_TYPE_NAME(*leftValue) << DENG2_TYPE_NAME(*rightValue) << flags().testFlag(ByReference)); */ diff --git a/doomsday/libdeng2/src/scriptsys/parser.cpp b/doomsday/libdeng2/src/scriptsys/parser.cpp index 14e1d0e5c9..966fdf9efa 100644 --- a/doomsday/libdeng2/src/scriptsys/parser.cpp +++ b/doomsday/libdeng2/src/scriptsys/parser.cpp @@ -557,7 +557,7 @@ Expression *Parser::parseConditionalCompound(Compound &compound, CompoundFlags c if(flags.testFlag(HasCondition)) { LOG_AS("parseConditionalCompound"); - LOG_DEV_TRACE("colon at %i", colon); + LOG_DEV_TRACE_DEBUGONLY("colon at %i", colon); TokenRange conditionRange = range.between(1, colon); if(conditionRange.empty()) @@ -619,7 +619,7 @@ Expression *Parser::parseExpression(TokenRange const &fullRange, Expression::Fla TokenRange range = fullRange; LOG_AS("parseExpression"); - LOG_DEV_TRACE("", range.asText()); + LOG_DEV_TRACE_DEBUGONLY("", range.asText()); if(!range.size()) { diff --git a/doomsday/libdeng2/src/scriptsys/printstatement.cpp b/doomsday/libdeng2/src/scriptsys/printstatement.cpp index 90181c01d1..6f08d6a255 100644 --- a/doomsday/libdeng2/src/scriptsys/printstatement.cpp +++ b/doomsday/libdeng2/src/scriptsys/printstatement.cpp @@ -63,7 +63,7 @@ void PrintStatement::execute(Context &context) const os << (*i)->asText(); } - LOG_MSG(_E(m)) << msg; + LOG_SCR_MSG(_E(m)) << msg; context.proceed(); } diff --git a/doomsday/libdeng2/src/scriptsys/scriptedinfo.cpp b/doomsday/libdeng2/src/scriptsys/scriptedinfo.cpp index 7a1ae1763f..f55e785cac 100644 --- a/doomsday/libdeng2/src/scriptsys/scriptedinfo.cpp +++ b/doomsday/libdeng2/src/scriptsys/scriptedinfo.cpp @@ -135,7 +135,7 @@ DENG2_PIMPL(ScriptedInfo) ns.add(varName.concatenateMember("__inherit__")) = new TextValue(targetName); - LOG_DEV_TRACE("setting __inherit__ of %s %s (%p) to %s", + LOG_DEV_TRACE_DEBUGONLY("setting __inherit__ of %s %s (%p) to %s", block.blockType() << varName << &block << targetName); DENG2_ASSERT(!varName.isEmpty()); diff --git a/doomsday/tests/test_log/main.cpp b/doomsday/tests/test_log/main.cpp index 673c10dcbd..070775374f 100644 --- a/doomsday/tests/test_log/main.cpp +++ b/doomsday/tests/test_log/main.cpp @@ -31,16 +31,16 @@ int main(int argc, char **argv) TextApp app(argc, argv); app.initSubsystems(App::DisablePlugins); - for(int i = 0; i < LogEntry::MAX_LOG_LEVELS; ++i) + for(int i = LogEntry::LOWEST_LOG_LEVEL; i < LogEntry::MAX_LOG_LEVELS; ++i) { LogEntry::Level level = LogEntry::Level(i); LogBuffer::appBuffer().enable(level); LOG_AT_LEVEL(level, "Enabled level ") << LogEntry::levelToText(level); - for(int k = 0; k < LogEntry::MAX_LOG_LEVELS; ++k) + for(int k = LogEntry::LOWEST_LOG_LEVEL; k < LogEntry::MAX_LOG_LEVELS; ++k) { LogEntry::Level other = LogEntry::Level(k); - LOG_AT_LEVEL(other, "- (currently enabled %8s) entry at level %8s: visible: %b") + LOG_AT_LEVEL(other, "- (currently enabled %9s) entry at level %9s: visible: %b") << LogEntry::levelToText(level) << LogEntry::levelToText(other) << LogBuffer::appBuffer().isEnabled(other); diff --git a/doomsday/tests/test_log/test_log.pro b/doomsday/tests/test_log/test_log.pro index b9a07cc9a7..c3dd56af58 100644 --- a/doomsday/tests/test_log/test_log.pro +++ b/doomsday/tests/test_log/test_log.pro @@ -6,3 +6,4 @@ TARGET = test_log SOURCES += main.cpp deployTest($$TARGET) + diff --git a/doomsday/tools/shell/shell-gui/src/linkwindow.cpp b/doomsday/tools/shell/shell-gui/src/linkwindow.cpp index 6fb47510c9..f226b9114b 100644 --- a/doomsday/tools/shell/shell-gui/src/linkwindow.cpp +++ b/doomsday/tools/shell/shell-gui/src/linkwindow.cpp @@ -91,7 +91,7 @@ DENG2_PIMPL(LinkWindow) // Configure the log buffer. logBuffer.setMaxEntryCount(50); // buffered here rather than appBuffer #ifdef _DEBUG - logBuffer.enable(LogEntry::DEBUG); + logBuffer.enable(LogEntry::Verbose); #endif } @@ -482,7 +482,7 @@ void LinkWindow::sendCommandToServer(de::String command) if(d->link) { // Echo the command locally. - LogEntry *e = new LogEntry(LogEntry::INFO, "", 0, ">", + LogEntry *e = new LogEntry(LogEntry::Important, "", 0, ">", LogEntry::Args() << new LogEntry::Arg(command)); d->logBuffer.add(e); diff --git a/doomsday/tools/shell/shell-text/src/shellapp.cpp b/doomsday/tools/shell/shell-text/src/shellapp.cpp index e28379ebde..a86894e272 100644 --- a/doomsday/tools/shell/shell-text/src/shellapp.cpp +++ b/doomsday/tools/shell/shell-text/src/shellapp.cpp @@ -144,7 +144,7 @@ ShellApp::ShellApp(int &argc, char **argv) buf.setMaxEntryCount(50); // buffered here rather than appBuffer buf.addSink(d->log->logSink()); #ifdef _DEBUG - buf.enable(LogEntry::DEBUG); + buf.enable(LogEntry::Verbose); #endif QStringList args = arguments();