From edc678b984bad8548a0e0d020133bbc760794d16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= Date: Sat, 4 Jan 2014 20:15:11 +0200 Subject: [PATCH] libdeng2: Updated logging with domain-specific LOG macros Also, tweaked the entry levels to be more suitable within the domain. --- doomsday/libdeng2/src/core/app.cpp | 4 ++-- doomsday/libdeng2/src/core/commandline.cpp | 2 +- doomsday/libdeng2/src/core/textapp.cpp | 4 ++-- doomsday/libdeng2/src/data/pathtree.cpp | 6 +++--- doomsday/libdeng2/src/data/pathtreenode.cpp | 2 +- doomsday/libdeng2/src/filesys/archivefeed.cpp | 8 ++++---- doomsday/libdeng2/src/filesys/directoryfeed.cpp | 4 ++-- doomsday/libdeng2/src/filesys/filesystem.cpp | 16 ++++++++-------- doomsday/libdeng2/src/filesys/folder.cpp | 6 +++--- doomsday/libdeng2/src/net/beacon.cpp | 4 ++-- doomsday/libdeng2/src/net/listensocket.cpp | 2 +- doomsday/libdeng2/src/net/socket.cpp | 8 ++++---- doomsday/libdeng2/src/scriptsys/evaluator.cpp | 2 -- doomsday/libdeng2/src/scriptsys/function.cpp | 2 +- doomsday/libdeng2/src/scriptsys/process.cpp | 2 +- doomsday/libdeng2/src/scriptsys/scriptedinfo.cpp | 4 ++-- doomsday/libdeng2/src/scriptsys/scriptsystem.cpp | 3 ++- 17 files changed, 39 insertions(+), 40 deletions(-) diff --git a/doomsday/libdeng2/src/core/app.cpp b/doomsday/libdeng2/src/core/app.cpp index 317f1ae4bd..b578365648 100644 --- a/doomsday/libdeng2/src/core/app.cpp +++ b/doomsday/libdeng2/src/core/app.cpp @@ -202,8 +202,8 @@ App::App(NativePath const &appFilePath, QStringList args) d->appPath = appFilePath; - LOG_INFO("Application path: ") << d->appPath; - LOG_INFO("Enabled log entry level: ") << LogEntry::levelToText(level); + LOG_NOTE("Application path: ") << d->appPath; + LOG_NOTE("Enabled log entry level: ") << LogEntry::levelToText(level); #ifdef MACOSX // When the application is started through Finder, we get a special command diff --git a/doomsday/libdeng2/src/core/commandline.cpp b/doomsday/libdeng2/src/core/commandline.cpp index a32d36e013..81efe74c88 100644 --- a/doomsday/libdeng2/src/core/commandline.cpp +++ b/doomsday/libdeng2/src/core/commandline.cpp @@ -435,7 +435,7 @@ bool CommandLine::execute() const qint64 pid = 0; if(!QProcess::startDetached(at(0), args, d->initialDir.path(), &pid)) { - LOG_WARNING("Failed to start \"%s\"") << at(0); + LOG_ERROR("Failed to start \"%s\"") << at(0); return false; } diff --git a/doomsday/libdeng2/src/core/textapp.cpp b/doomsday/libdeng2/src/core/textapp.cpp index 4d87ec62cc..16adffb941 100644 --- a/doomsday/libdeng2/src/core/textapp.cpp +++ b/doomsday/libdeng2/src/core/textapp.cpp @@ -61,12 +61,12 @@ bool TextApp::notify(QObject *receiver, QEvent *event) int TextApp::execLoop() { - LOG_MSG("Starting TextApp event loop..."); + LOG_DEV_MSG("Starting TextApp event loop..."); d->loop.start(); int code = QCoreApplication::exec(); - LOG_MSG("TextApp event loop exited with code %i") << code; + LOG_DEV_NOTE("TextApp event loop exited with code %i") << code; return code; } diff --git a/doomsday/libdeng2/src/data/pathtree.cpp b/doomsday/libdeng2/src/data/pathtree.cpp index cdba6c926f..2c28129a6b 100644 --- a/doomsday/libdeng2/src/data/pathtree.cpp +++ b/doomsday/libdeng2/src/data/pathtree.cpp @@ -458,7 +458,7 @@ int PathTree::traverse(ComparisonFlags flags, PathTree::Node const *parent, Path #ifdef DENG2_DEBUG void PathTree::debugPrint(QChar separator) const { - LOG_INFO("PathTree [%p]:") << de::dintptr(this); + LOG_DEV_MSG("PathTree [%p]:") << de::dintptr(this); FoundPaths found; if(findAllPaths(found, 0, separator)) { @@ -466,10 +466,10 @@ void PathTree::debugPrint(QChar separator) const DENG2_FOR_EACH_CONST(FoundPaths, i, found) { - LOG_INFO(" %s") << *i; + LOG_DEV_MSG(" %s") << *i; } } - LOG_INFO(" %i unique %s in the tree.") << found.count() << (found.count() == 1? "path" : "paths"); + LOG_DEV_MSG(" %i unique %s in the tree.") << found.count() << (found.count() == 1? "path" : "paths"); } #if 0 diff --git a/doomsday/libdeng2/src/data/pathtreenode.cpp b/doomsday/libdeng2/src/data/pathtreenode.cpp index 370f704458..40a906045f 100644 --- a/doomsday/libdeng2/src/data/pathtreenode.cpp +++ b/doomsday/libdeng2/src/data/pathtreenode.cpp @@ -329,7 +329,7 @@ Path PathTree::Node::path(QChar sep) const #ifdef LIBDENG_STACK_MONITOR LOG_AS("pathConstructor"); - LOG_INFO("Max stack depth: %1 bytes") << maxStackDepth; + LOG_DEV_NOTE("Max stack depth: %1 bytes") << maxStackDepth; #endif return Path(args.composedPath, sep); diff --git a/doomsday/libdeng2/src/filesys/archivefeed.cpp b/doomsday/libdeng2/src/filesys/archivefeed.cpp index 3bf3abf2e8..b9323926e5 100644 --- a/doomsday/libdeng2/src/filesys/archivefeed.cpp +++ b/doomsday/libdeng2/src/filesys/archivefeed.cpp @@ -58,13 +58,13 @@ DENG2_PIMPL(ArchiveFeed) // Open the archive. if(bytes) { - LOG_TRACE("Source %s is a byte array") << f.description(); + LOG_RES_XVERBOSE("Source %s is a byte array") << f.description(); arch = new ZipArchive(*bytes); } else { - LOG_TRACE("Source %s is a stream") << f.description(); + LOG_RES_XVERBOSE("Source %s is a stream") << f.description(); // The file is just a stream, so we can't rely on the file // acting as the physical storage location for Archive. @@ -84,7 +84,7 @@ DENG2_PIMPL(ArchiveFeed) // If modified, the archive is written back to the file. if(arch->modified()) { - LOG_MSG("Updating archive in ") << file.description(); + LOG_RES_MSG("Updating archive in ") << file.description(); // Make sure we have either a compressed or uncompressed version of // each entry in memory before destroying the source file. @@ -95,7 +95,7 @@ DENG2_PIMPL(ArchiveFeed) } else { - LOG_VERBOSE("Not updating archive in %s (not changed)") << file.description(); + LOG_RES_VERBOSE("Not updating archive in %s (not changed)") << file.description(); } delete arch; } diff --git a/doomsday/libdeng2/src/filesys/directoryfeed.cpp b/doomsday/libdeng2/src/filesys/directoryfeed.cpp index 40c40bd832..3bc70d2239 100644 --- a/doomsday/libdeng2/src/filesys/directoryfeed.cpp +++ b/doomsday/libdeng2/src/filesys/directoryfeed.cpp @@ -138,7 +138,7 @@ bool DirectoryFeed::prune(File &file) const if(fileStatus(nativeFile->nativePath()) != nativeFile->status()) { // It's not up to date. - LOG_VERBOSE("%s: status has changed, pruning!") << nativeFile->nativePath(); + LOG_RES_MSG("Pruning \"%s\": status has changed") << nativeFile->nativePath(); return true; } } @@ -159,7 +159,7 @@ bool DirectoryFeed::prune(File &file) const DirectoryFeed *dirFeed = dynamic_cast(subFolder->feeds().front()); if(dirFeed && !exists(dirFeed->_nativePath)) { - LOG_VERBOSE("%s: no longer exists, pruning!") << _nativePath; + LOG_RES_NOTE("Pruning \"%s\": no longer exists") << _nativePath; return true; } } diff --git a/doomsday/libdeng2/src/filesys/filesystem.cpp b/doomsday/libdeng2/src/filesys/filesystem.cpp index 8538383714..2ab1b12c5c 100644 --- a/doomsday/libdeng2/src/filesys/filesystem.cpp +++ b/doomsday/libdeng2/src/filesys/filesystem.cpp @@ -57,7 +57,7 @@ void FileSystem::refresh() Time startedAt; d->root.populate(); - LOG_DEBUG("Completed in %.2f seconds.") << startedAt.since(); + LOG_RES_VERBOSE("Completed in %.2f seconds") << startedAt.since(); printIndex(); } @@ -89,7 +89,7 @@ Folder &FileSystem::makeFolder(String const &path, FolderCreationBehaviors behav if(!feed) continue; // Check next one instead. LOG_DEV_TRACE_DEBUGONLY("Creating subfeed \"%s\" from %s", - subFolder->name() << (*i)->description()); + subFolder->name() << (*i)->description()); subFolder->attach(feed); @@ -119,7 +119,7 @@ File *FileSystem::interpret(File *sourceData) { if(LibraryFile::recognize(*sourceData)) { - LOG_VERBOSE("Interpreted ") << sourceData->description() << " as a shared library"; + LOG_RES_VERBOSE("Interpreted ") << sourceData->description() << " as a shared library"; // It is a shared library intended for Doomsday. return new LibraryFile(sourceData); @@ -128,7 +128,7 @@ File *FileSystem::interpret(File *sourceData) { try { - LOG_VERBOSE("Interpreted %s as a ZIP format archive") << sourceData->description(); + LOG_RES_VERBOSE("Interpreted %s as a ZIP format archive") << sourceData->description(); // It is a ZIP archive: we will represent it as a folder. std::auto_ptr package(new PackageFolder(*sourceData, sourceData->name())); @@ -141,21 +141,21 @@ File *FileSystem::interpret(File *sourceData) { // Even though it was recognized as an archive, the file // contents may still prove to be corrupted. - LOG_WARNING("Archive in %s is invalid") << sourceData->description(); + LOG_RES_WARNING("Archive in %s is invalid") << sourceData->description(); } catch(IByteArray::OffsetError const &) { - LOG_WARNING("Archive in %s is truncated") << sourceData->description(); + LOG_RES_WARNING("Archive in %s is truncated") << sourceData->description(); } catch(IIStream::InputError const &) { - LOG_WARNING("%s cannot be read") << sourceData->description(); + LOG_RES_WARNING("%s cannot be read") << sourceData->description(); } } } catch(Error const &err) { - LOG_ERROR("") << err.asText(); + LOG_RES_ERROR("") << err.asText(); // The error is one we don't know how to handle. We were given // responsibility of the source file, so it has to be deleted. diff --git a/doomsday/libdeng2/src/filesys/folder.cpp b/doomsday/libdeng2/src/filesys/folder.cpp index 0e5cd75440..36cf9d7e41 100644 --- a/doomsday/libdeng2/src/filesys/folder.cpp +++ b/doomsday/libdeng2/src/filesys/folder.cpp @@ -107,7 +107,7 @@ void Folder::populate(PopulationBehavior behavior) // If the file has a designated feed, ask it about pruning. if(file->originFeed() && file->originFeed()->prune(*file)) { - LOG_DEBUG("Pruning \"%s\"") << file->path(); + LOG_RES_XVERBOSE("Pruning \"%s\"") << file->path(); mustPrune = true; } else if(!file->originFeed()) @@ -119,7 +119,7 @@ void Folder::populate(PopulationBehavior behavior) { if((*f)->prune(*file)) { - LOG_DEBUG("Pruning ") << file->path(); + LOG_RES_XVERBOSE("Pruning ") << file->path(); mustPrune = true; break; } @@ -186,7 +186,7 @@ File &Folder::newFile(String const &newPath, FileCreationBehavior behavior) } catch(Feed::RemoveError const &er) { - LOG_WARNING("Failed to replace %s: existing file could not be removed.\n") + LOG_RES_WARNING("Failed to replace %s: existing file could not be removed.\n") << newPath << er.asText(); } } diff --git a/doomsday/libdeng2/src/net/beacon.cpp b/doomsday/libdeng2/src/net/beacon.cpp index 7641d423b3..65cc90a5d3 100644 --- a/doomsday/libdeng2/src/net/beacon.cpp +++ b/doomsday/libdeng2/src/net/beacon.cpp @@ -171,7 +171,7 @@ void Beacon::readIncoming() d->socket->readDatagram(reinterpret_cast(block.data()), block.size(), &from, &port); - LOG_TRACE("Received %i bytes from %s port %i") << block.size() << from.toString() << port; + LOG_NET_XVERBOSE("Received %i bytes from %s port %i") << block.size() << from.toString() << port; if(block == discoveryMessage) { @@ -239,7 +239,7 @@ void Beacon::continueDiscovery() Block block(discoveryMessage); - LOG_TRACE("Broadcasting %i bytes") << block.size(); + LOG_NET_XVERBOSE("Broadcasting %i bytes") << block.size(); // Send a new broadcast to the whole listening range of the beacons. for(duint16 range = 0; range < MAX_LISTEN_RANGE; ++range) diff --git a/doomsday/libdeng2/src/net/listensocket.cpp b/doomsday/libdeng2/src/net/listensocket.cpp index ccbcd94d96..123b5e01fe 100644 --- a/doomsday/libdeng2/src/net/listensocket.cpp +++ b/doomsday/libdeng2/src/net/listensocket.cpp @@ -75,7 +75,7 @@ Socket *ListenSocket::accept() } QTcpSocket *s = d->incoming.takeFirst(); - LOG_MSG("Accepted new connection from %s.") << s->peerAddress().toString(); + LOG_NET_NOTE("Accepted new connection from %s") << s->peerAddress().toString(); // We can use this constructor because we are Socket's friend. return new Socket(s); diff --git a/doomsday/libdeng2/src/net/socket.cpp b/doomsday/libdeng2/src/net/socket.cpp index da08cc0891..a9dd0dcdba 100644 --- a/doomsday/libdeng2/src/net/socket.cpp +++ b/doomsday/libdeng2/src/net/socket.cpp @@ -398,7 +398,7 @@ Socket::Socket(Address const &address, TimeDelta const &timeOut) : d(new Instanc throw ConnectionError("Socket", "Opening the connection to " + address.asText() + " failed: " + msg); } - LOG_MSG("Connection opened to %s") << address.asText(); + LOG_NET_NOTE("Connection opened to %s") << address.asText(); d->target = address; @@ -412,7 +412,7 @@ void Socket::connect(Address const &address) // non-blocking DENG2_ASSERT(d->socket->state() == QAbstractSocket::UnconnectedState); LOG_AS("Socket"); - if(!d->quiet) LOG_MSG("Opening connection to %s") << address.asText(); + if(!d->quiet) LOG_NET_MSG("Opening connection to %s") << address.asText(); d->socket->connectToHost(address.host(), address.port()); d->target = address; @@ -567,7 +567,7 @@ void Socket::hostResolved(QHostInfo const &info) { if(info.error() != QHostInfo::NoError || info.addresses().isEmpty()) { - LOG_WARNING("Could not resolve host: ") << info.errorString(); + LOG_NET_ERROR("Could not resolve host: ") << info.errorString(); emit disconnected(); } else @@ -635,7 +635,7 @@ void Socket::socketError(QAbstractSocket::SocketError socketError) if(socketError != QAbstractSocket::SocketTimeoutError) { LOG_AS("Socket"); - if(!d->quiet) LOG_WARNING(d->socket->errorString()); + if(!d->quiet) LOG_NET_WARNING(d->socket->errorString()); emit disconnected(); //error(socketError); } diff --git a/doomsday/libdeng2/src/scriptsys/evaluator.cpp b/doomsday/libdeng2/src/scriptsys/evaluator.cpp index e6d45354aa..4dc43b91c1 100644 --- a/doomsday/libdeng2/src/scriptsys/evaluator.cpp +++ b/doomsday/libdeng2/src/scriptsys/evaluator.cpp @@ -159,8 +159,6 @@ void Evaluator::clearNames() void Evaluator::clearResults() { - //LOG_TRACE("Evaluator::clearResults"); - for(Results::iterator i = _results.begin(); i != _results.end(); ++i) { delete *i; diff --git a/doomsday/libdeng2/src/scriptsys/function.cpp b/doomsday/libdeng2/src/scriptsys/function.cpp index 97e7a32398..ebe430b090 100644 --- a/doomsday/libdeng2/src/scriptsys/function.cpp +++ b/doomsday/libdeng2/src/scriptsys/function.cpp @@ -233,7 +233,7 @@ void Function::setGlobals(Record *globals) } else if(d->globals != globals) { - LOG_WARNING("Function was offered a different namespace."); + LOG_SCR_WARNING("Function was offered a different namespace"); } } diff --git a/doomsday/libdeng2/src/scriptsys/process.cpp b/doomsday/libdeng2/src/scriptsys/process.cpp index a5c75535e6..7f40cf94fb 100644 --- a/doomsday/libdeng2/src/scriptsys/process.cpp +++ b/doomsday/libdeng2/src/scriptsys/process.cpp @@ -192,7 +192,7 @@ void Process::execute() else { // Exception uncaught by all contexts, script execution stops. - LOG_INFO("Stopping process: ") << err.asText(); + LOG_SCR_NOTE("Stopping process: ") << err.asText(); stop(); } } diff --git a/doomsday/libdeng2/src/scriptsys/scriptedinfo.cpp b/doomsday/libdeng2/src/scriptsys/scriptedinfo.cpp index f55e785cac..aac7376072 100644 --- a/doomsday/libdeng2/src/scriptsys/scriptedinfo.cpp +++ b/doomsday/libdeng2/src/scriptsys/scriptedinfo.cpp @@ -63,7 +63,7 @@ DENG2_PIMPL(ScriptedInfo) { processBlock(info.root()); - LOG_DEBUG("Processed contents:\n") << process.globals().asText(); + LOG_SCR_XVERBOSE("Processed contents:\n") << process.globals().asText(); } void processElement(Info::Element const *element) @@ -223,7 +223,7 @@ DENG2_PIMPL(ScriptedInfo) // Reset to the global namespace. currentNamespace = ""; } - LOG_TRACE("Namespace set to '%s' on line %i") << currentNamespace << block.lineNumber(); + LOG_SCR_XVERBOSE("Namespace set to '%s' on line %i") << currentNamespace << block.lineNumber(); } else if(!block.name().isEmpty()) { diff --git a/doomsday/libdeng2/src/scriptsys/scriptsystem.cpp b/doomsday/libdeng2/src/scriptsys/scriptsystem.cpp index 88ac508c20..8da230d652 100644 --- a/doomsday/libdeng2/src/scriptsys/scriptsystem.cpp +++ b/doomsday/libdeng2/src/scriptsys/scriptsystem.cpp @@ -184,7 +184,8 @@ File const *ScriptSystem::tryFindModuleSource(String const &name, String const & } matching.sort(sortFilesByModifiedAt); found = matching.back(); - LOG_VERBOSE("Chose ") << found->path() << " out of " << dint(matching.size()) << " candidates (latest modified)."; + LOG_SCR_VERBOSE("Chose ") << found->path() << " out of " << dint(matching.size()) + << " candidates (latest modified)"; } else {