Skip to content

Commit

Permalink
libdeng2: Updated logging with domain-specific LOG macros
Browse files Browse the repository at this point in the history
Also, tweaked the entry levels to be more suitable within the domain.
  • Loading branch information
skyjake committed Jan 4, 2014
1 parent cba0940 commit edc678b
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 40 deletions.
4 changes: 2 additions & 2 deletions doomsday/libdeng2/src/core/app.cpp
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libdeng2/src/core/commandline.cpp
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions doomsday/libdeng2/src/core/textapp.cpp
Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions doomsday/libdeng2/src/data/pathtree.cpp
Expand Up @@ -458,18 +458,18 @@ 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))
{
qSort(found.begin(), found.end());

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
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libdeng2/src/data/pathtreenode.cpp
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions doomsday/libdeng2/src/filesys/archivefeed.cpp
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions doomsday/libdeng2/src/filesys/directoryfeed.cpp
Expand Up @@ -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;
}
}
Expand All @@ -159,7 +159,7 @@ bool DirectoryFeed::prune(File &file) const
DirectoryFeed *dirFeed = dynamic_cast<DirectoryFeed *>(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;
}
}
Expand Down
16 changes: 8 additions & 8 deletions doomsday/libdeng2/src/filesys/filesystem.cpp
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand All @@ -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<PackageFolder> package(new PackageFolder(*sourceData, sourceData->name()));
Expand All @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions doomsday/libdeng2/src/filesys/folder.cpp
Expand Up @@ -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())
Expand All @@ -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;
}
Expand Down Expand Up @@ -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();
}
}
Expand Down
4 changes: 2 additions & 2 deletions doomsday/libdeng2/src/net/beacon.cpp
Expand Up @@ -171,7 +171,7 @@ void Beacon::readIncoming()
d->socket->readDatagram(reinterpret_cast<char *>(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)
{
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libdeng2/src/net/listensocket.cpp
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions doomsday/libdeng2/src/net/socket.cpp
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 0 additions & 2 deletions doomsday/libdeng2/src/scriptsys/evaluator.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libdeng2/src/scriptsys/function.cpp
Expand Up @@ -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");
}
}

Expand Down
2 changes: 1 addition & 1 deletion doomsday/libdeng2/src/scriptsys/process.cpp
Expand Up @@ -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();
}
}
Expand Down
4 changes: 2 additions & 2 deletions doomsday/libdeng2/src/scriptsys/scriptedinfo.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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())
{
Expand Down
3 changes: 2 additions & 1 deletion doomsday/libdeng2/src/scriptsys/scriptsystem.cpp
Expand Up @@ -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
{
Expand Down

0 comments on commit edc678b

Please sign in to comment.