# HG changeset patch # User Chris Cannam # Date 1311690174 -3600 # Node ID 555496d418f1f30eb1e4868e23de645f806a1fe6 # Parent 7e8688784980693546e4c5397b07a59e381de062 Place debug log in application data directory (fixes #193) diff -r 7e8688784980 -r 555496d418f1 src/debug.cpp --- a/src/debug.cpp Tue Jul 26 15:21:45 2011 +0100 +++ b/src/debug.cpp Tue Jul 26 15:22:54 2011 +0100 @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -39,7 +40,15 @@ if (!debug) { prefix = new char[20]; sprintf(prefix, "[%lu]", (unsigned long)QCoreApplication::applicationPid()); - logFile = new QFile(QDir::homePath() + "/.easyhg.log"); + QString logFileName = QDir::homePath() + "/.easyhg.log"; // the fallback + QString logDir = QDesktopServices::storageLocation + (QDesktopServices::DataLocation); + if (logDir != "" && + (QDir(logDir).exists() || + QDir().mkpath(logDir))) { + logFileName = logDir + "/debug.log"; + } + logFile = new QFile(logFileName); if (logFile->open(QIODevice::WriteOnly | QIODevice::Truncate)) { QDebug(QtDebugMsg) << (const char *)prefix << "Opened debug log file "