Mercurial > hg > easyhg
comparison src/debug.cpp @ 489:86cdaa346e59
Merge
author | Chris Cannam |
---|---|
date | Wed, 17 Aug 2011 22:13:51 +0100 |
parents | 555496d418f1 |
children | 533519ebc0cb |
comparison
equal
deleted
inserted
replaced
488:2f59333952ce | 489:86cdaa346e59 |
---|---|
23 #include <QMutexLocker> | 23 #include <QMutexLocker> |
24 #include <QFile> | 24 #include <QFile> |
25 #include <QDir> | 25 #include <QDir> |
26 #include <QCoreApplication> | 26 #include <QCoreApplication> |
27 #include <QDateTime> | 27 #include <QDateTime> |
28 #include <QDesktopServices> | |
28 | 29 |
29 #include <cstdio> | 30 #include <cstdio> |
30 | 31 |
31 QDebug & | 32 QDebug & |
32 getEasyHgDebug() | 33 getEasyHgDebug() |
37 static char *prefix; | 38 static char *prefix; |
38 mutex.lock(); | 39 mutex.lock(); |
39 if (!debug) { | 40 if (!debug) { |
40 prefix = new char[20]; | 41 prefix = new char[20]; |
41 sprintf(prefix, "[%lu]", (unsigned long)QCoreApplication::applicationPid()); | 42 sprintf(prefix, "[%lu]", (unsigned long)QCoreApplication::applicationPid()); |
42 logFile = new QFile(QDir::homePath() + "/.easyhg.log"); | 43 QString logFileName = QDir::homePath() + "/.easyhg.log"; // the fallback |
44 QString logDir = QDesktopServices::storageLocation | |
45 (QDesktopServices::DataLocation); | |
46 if (logDir != "" && | |
47 (QDir(logDir).exists() || | |
48 QDir().mkpath(logDir))) { | |
49 logFileName = logDir + "/debug.log"; | |
50 } | |
51 logFile = new QFile(logFileName); | |
43 if (logFile->open(QIODevice::WriteOnly | QIODevice::Truncate)) { | 52 if (logFile->open(QIODevice::WriteOnly | QIODevice::Truncate)) { |
44 QDebug(QtDebugMsg) << (const char *)prefix | 53 QDebug(QtDebugMsg) << (const char *)prefix |
45 << "Opened debug log file " | 54 << "Opened debug log file " |
46 << logFile->fileName(); | 55 << logFile->fileName(); |
47 debug = new QDebug(logFile); | 56 debug = new QDebug(logFile); |