comparison base/Debug.cpp @ 1251:67aee57e32c8 3.0-integration

Merge from branch piper
author Chris Cannam
date Fri, 04 Nov 2016 14:57:03 +0000
parents 8f076d02569a
children ad2d3e0a8b7c
comparison
equal deleted inserted replaced
1241:c6bdf247016a 1251:67aee57e32c8
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 }