diff --git a/src/core/log.cpp b/src/core/log.cpp index 33b641a..3ea7f36 100644 --- a/src/core/log.cpp +++ b/src/core/log.cpp @@ -53,14 +53,17 @@ public: static QFile *s_file = NULL; if (!s_out) { QString name = QString("%1/libsnore/%2-log.txt").arg(QDir::tempPath(), qApp->applicationName().isEmpty() ? QString::number(qApp->applicationPid()) : qApp->applicationName()); - if (!qgetenv("LIBSNORE_LOGFILE").isNull()) { name = QString(qgetenv("LIBSNORE_LOGFILE")); + } else { + QDir::temp().mkpath("libsnore"); } std::cout << "Started logging to " << name.toUtf8().constData() << std::endl; s_file = new QFile(name); - s_file->open(QFile::WriteOnly); + if(!s_file->open(QFile::WriteOnly)) { + qFatal("Failed to open log file %s", qPrintable(name)); + } s_out = new QTextStream(s_file); } return *s_out; diff --git a/src/core/snore_p.cpp b/src/core/snore_p.cpp index b7ecc75..d7d652a 100644 --- a/src/core/snore_p.cpp +++ b/src/core/snore_p.cpp @@ -87,7 +87,12 @@ QString SnoreCorePrivate::tempPath() static QTemporaryDir dir; return dir.path(); #else - return QString("%1/%2").arg(QDir::tempPath(), "libsnore"); + static QString dir; + if(dir.isEmpty()) { + dir = QString("%1/%2").arg(QDir::tempPath(), "libsnore"); + QDir::temp().mkpath("libsnore"); + } + return dir; #endif }