Fix #674
This commit is contained in:
parent
cb50fd0e2c
commit
3f38e780f4
1 changed files with 18 additions and 1 deletions
|
@ -2,6 +2,8 @@
|
||||||
#include "settingscache.h"
|
#include "settingscache.h"
|
||||||
#include <QSocketNotifier>
|
#include <QSocketNotifier>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QDir>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -26,8 +28,23 @@ ServerLogger::~ServerLogger()
|
||||||
void ServerLogger::startLog(const QString &logFileName)
|
void ServerLogger::startLog(const QString &logFileName)
|
||||||
{
|
{
|
||||||
if (!logFileName.isEmpty()) {
|
if (!logFileName.isEmpty()) {
|
||||||
|
QFileInfo fi(logFileName);
|
||||||
|
QDir fileDir(fi.path());
|
||||||
|
if (!fileDir.exists() && !fileDir.mkpath(fileDir.absolutePath())) {
|
||||||
|
std::cerr << "ERROR: logfile folder doesn't exist and i can't create it." << std::endl;
|
||||||
|
logFile = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
logFile = new QFile(logFileName, this);
|
logFile = new QFile(logFileName, this);
|
||||||
logFile->open(QIODevice::Append);
|
if(!logFile->open(QIODevice::Append)) {
|
||||||
|
std::cerr << "ERROR: can't open() logfile." << std::endl;
|
||||||
|
delete logFile;
|
||||||
|
logFile = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_UNIX
|
#ifdef Q_OS_UNIX
|
||||||
::socketpair(AF_UNIX, SOCK_STREAM, 0, sigHupFD);
|
::socketpair(AF_UNIX, SOCK_STREAM, 0, sigHupFD);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue