Skip to content

Commit

Permalink
libdeng2|filesys: Log full paths making use of NativePath where suitable
Browse files Browse the repository at this point in the history
Logging just the name of the file is not particularly helpful.
  • Loading branch information
danij-deng committed Dec 6, 2012
1 parent ec2b0f5 commit e9a0dd9
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 55 deletions.
42 changes: 23 additions & 19 deletions doomsday/libdeng2/src/filesys/archivefeed.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
/*
* The Doomsday Engine Project -- libdeng2
/** @file archivefeed.cpp Archive Feed.
* @ingroup fs
*
* Copyright (c) 2009-2012 Jaakko Keränen <jaakko.keranen@iki.fi>
* @author Copyright &copy; 2009-2012 Jaakko Keränen <jaakko.keranen@iki.fi>
* @author Copyright &copy; 2012 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/

#include "de/ArchiveFeed"
Expand All @@ -25,6 +27,7 @@
#include "de/Folder"
#include "de/FS"
#include "de/Log"
#include "de/NativePath"

namespace de {

Expand Down Expand Up @@ -58,13 +61,13 @@ struct ArchiveFeed::Instance
// Open the archive.
if(bytes)
{
LOG_TRACE("Source %s is a byte array") << f.name();
LOG_TRACE("Source %s is a byte array") << NativePath(f.path()).pretty();

arch = new ZipArchive(*bytes);
}
else
{
LOG_TRACE("Source %s is a stream") << f.name();
LOG_TRACE("Source %s is a stream") << NativePath(f.path()).pretty();

// 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 +87,7 @@ struct ArchiveFeed::Instance
// If modified, the archive is written back to the file.
if(arch->modified())
{
LOG_MSG("Updating archive in ") << file.name();
LOG_MSG("Updating archive in ") << NativePath(file.path()).pretty();

// Make sure we have either a compressed or uncompressed version of
// each entry in memory before destroying the source file.
Expand All @@ -95,7 +98,8 @@ struct ArchiveFeed::Instance
}
else
{
LOG_VERBOSE("Not updating archive in %s (not changed)") << file.name();
LOG_VERBOSE("Not updating archive in %s (not changed)")
<< NativePath(file.path()).pretty();
}
delete arch;
}
Expand Down Expand Up @@ -157,7 +161,7 @@ struct ArchiveFeed::Instance
if(archFeed && &archFeed->archive() == &archive() && archFeed->basePath() == subBasePath)
{
// It's got it.
LOG_DEBUG("Feed for ") << archFeed->basePath() << " already there.";
LOG_DEBUG("Feed for ") << NativePath(archFeed->basePath()).pretty() << " already there.";
return;
}
}
Expand Down
36 changes: 19 additions & 17 deletions doomsday/libdeng2/src/filesys/directoryfeed.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
/*
* The Doomsday Engine Project -- libdeng2
/** @file directoryfeed.cpp Directory Feed.
* @ingroup fs
*
* Copyright (c) 2009-2012 Jaakko Keränen <jaakko.keranen@iki.fi>
* @author Copyright &copy; 2009-2012 Jaakko Keränen <jaakko.keranen@iki.fi>
* @author Copyright &copy; 2012 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/

#include "de/DirectoryFeed"
Expand Down Expand Up @@ -90,7 +92,7 @@ void DirectoryFeed::populateSubFolder(Folder &folder, String const &entryName)
if(dirFeed && dirFeed->_nativePath == subFeedPath)
{
// Already got this fed. Nothing else needs done.
LOG_DEBUG("Feed for ") << subFeedPath << " already there.";
LOG_DEBUG("Feed for ") << subFeedPath.pretty() << " already there.";
return;
}
}
Expand Down Expand Up @@ -143,7 +145,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_VERBOSE("%s: status has changed, pruning!") << nativeFile->nativePath().pretty();
return true;
}
}
Expand All @@ -164,7 +166,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_VERBOSE("%s: no longer exists, pruning!") << _nativePath.pretty();
return true;
}
}
Expand Down
41 changes: 22 additions & 19 deletions doomsday/libdeng2/src/filesys/fs.cpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
/*
* The Doomsday Engine Project -- libdeng2
/**
* @file fs.cpp File System
*
* Copyright (c) 2009-2012 Jaakko Keränen <jaakko.keranen@iki.fi>
* @author Copyright &copy; 2009-2012 Jaakko Keränen <jaakko.keranen@iki.fi>
* @author Copyright &copy; 2012 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/

#include "de/FS"
#include "de/LibraryFile"
#include "de/DirectoryFeed"
#include "de/ArchiveFeed"
#include "de/NativePath"
#include "de/PackageFolder"
#include "de/ZipArchive"
#include "de/Log"
Expand Down Expand Up @@ -89,7 +92,7 @@ File *FS::interpret(File *sourceData)
{
if(LibraryFile::recognize(*sourceData))
{
LOG_VERBOSE("Interpreted ") << sourceData->name() << " as a shared library";
LOG_VERBOSE("Interpreted ") << NativePath(sourceData->path()).pretty() << " as a shared library";

// It is a shared library intended for Doomsday.
return new LibraryFile(sourceData);
Expand All @@ -98,7 +101,7 @@ File *FS::interpret(File *sourceData)
{
try
{
LOG_VERBOSE("Interpreted %s as a ZIP format archive") << sourceData->name();
LOG_VERBOSE("Interpreted %s as a ZIP format archive") << NativePath(sourceData->path()).pretty();

// It is a ZIP archive: we will represent it as a folder.
std::auto_ptr<PackageFolder> package(new PackageFolder(*sourceData, sourceData->name()));
Expand All @@ -111,15 +114,15 @@ File *FS::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->name();
LOG_WARNING("Archive in %s is invalid") << NativePath(sourceData->path()).pretty();
}
catch(IByteArray::OffsetError const &)
{
LOG_WARNING("Archive in %s is truncated") << sourceData->name();
LOG_WARNING("Archive in %s is truncated") << NativePath(sourceData->path()).pretty();
}
catch(IIStream::InputError const &)
{
LOG_WARNING("%s cannot be read") << sourceData->name();
LOG_WARNING("%s cannot be read") << NativePath(sourceData->path()).pretty();
}
}
}
Expand Down

0 comments on commit e9a0dd9

Please sign in to comment.