comparison base/Debug.cpp @ 1247:8f076d02569a piper

Make SVDEBUG always write to a log file -- formerly this was disabled in NDEBUG builds. I think there's little use to that, it just means that we keep adding more cerr debug output because we aren't getting the log we need. And SVDEBUG logging is not usually used in tight loops, I don't think the performance overhead is too serious. Also update the About box.
author Chris Cannam
date Thu, 03 Nov 2016 14:57:00 +0000
parents c1e43c8d2527
children ad2d3e0a8b7c
comparison
equal deleted inserted replaced
1246:75aefcc9f07d 1247:8f076d02569a
19 #include <QMutex> 19 #include <QMutex>
20 #include <QDir> 20 #include <QDir>
21 #include <QUrl> 21 #include <QUrl>
22 #include <QCoreApplication> 22 #include <QCoreApplication>
23 23
24 #ifndef NDEBUG 24 #include <stdexcept>
25 25
26 static SVDebug *debug = 0; 26 static SVDebug *debug = 0;
27 static QMutex mutex; 27 static QMutex mutex;
28 28
29 SVDebug &getSVDebug() { 29 SVDebug &getSVDebug() {
38 SVDebug::SVDebug() : 38 SVDebug::SVDebug() :
39 m_prefix(0), 39 m_prefix(0),
40 m_ok(false), 40 m_ok(false),
41 m_eol(false) 41 m_eol(false)
42 { 42 {
43 if (qApp->applicationName() == "") {
44 cerr << "ERROR: Can't use SVDEBUG before setting application name" << endl;
45 throw std::logic_error("Can't use SVDEBUG before setting application name");
46 }
47
43 QString pfx = ResourceFinder().getUserResourcePrefix(); 48 QString pfx = ResourceFinder().getUserResourcePrefix();
44 QDir logdir(QString("%1/%2").arg(pfx).arg("log")); 49 QDir logdir(QString("%1/%2").arg(pfx).arg("log"));
45 50
46 m_prefix = strdup(QString("[%1]") 51 m_prefix = strdup(QString("[%1]")
47 .arg(QCoreApplication::applicationPid()) 52 .arg(QCoreApplication::applicationPid())
74 { 79 {
75 dbg << QString::fromUtf8(s.c_str()); 80 dbg << QString::fromUtf8(s.c_str());
76 return dbg; 81 return dbg;
77 } 82 }
78 83
79 #endif
80
81 std::ostream & 84 std::ostream &
82 operator<<(std::ostream &target, const QString &str) 85 operator<<(std::ostream &target, const QString &str)
83 { 86 {
84 return target << str.toStdString(); 87 return target << str.toStdString();
85 } 88 }