22 #include <QCoreApplication> 28 static std::unique_ptr<SVDebug>
svdebug =
nullptr;
29 static std::unique_ptr<SVCerr>
svcerr =
nullptr;
65 if (qApp->applicationName() ==
"") {
66 cerr <<
"ERROR: Can't use SVDEBUG before setting application name" << endl;
67 throw std::logic_error(
"Can't use SVDEBUG before setting application name");
71 QDir logdir(QString(
"%1/%2").arg(pfx).arg(
"log"));
74 .arg(QCoreApplication::applicationPid())
78 if (!logdir.exists()) logdir.mkpath(logdir.path());
80 QString fileName = logdir.path() +
"/sv-debug.log";
82 m_stream.open(fileName.toLocal8Bit().data(), std::ios_base::out);
85 QDebug(QtWarningMsg) << (
const char *)
m_prefix 86 <<
"Failed to open debug log file " 87 << fileName <<
" for writing";
91 (*this) <<
"Debug log started at " 92 << QDateTime::currentDateTime().toString() << endl;
99 (*this) <<
"Debug log ends" << endl;
107 dbg << QString::fromUtf8(s.c_str());
114 return target << str.toUtf8().data();
120 return target <<
"<" << u.toString() <<
">";
static std::unique_ptr< SVCerr > svcerr
QString getUserResourcePrefix()
Return the root path for user-specific resource installation for this application (i...
SVDebug & operator<<(const T &t)
static std::unique_ptr< SVDebug > svdebug