X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcommon%2Fquassel.cpp;h=67eac802fd1f7023f14d42bdf3b8ee1b070e1864;hb=fa56ee7fc1b94ea27da6b27c919d6df1c0e0490d;hp=c75836a33f399780b22dce04997dcb94e9271824;hpb=899709300734acc2bac01b1d57a1fd8fe2a6d923;p=quassel.git diff --git a/src/common/quassel.cpp b/src/common/quassel.cpp index c75836a3..67eac802 100644 --- a/src/common/quassel.cpp +++ b/src/common/quassel.cpp @@ -104,7 +104,7 @@ bool Quassel::init() instance()->setupEnvironment(); instance()->registerMetaTypes(); - Network::setDefaultCodecForServer("ISO-8859-1"); + Network::setDefaultCodecForServer("UTF-8"); Network::setDefaultCodecForEncoding("UTF-8"); Network::setDefaultCodecForDecoding("ISO-8859-15"); @@ -118,37 +118,41 @@ bool Quassel::init() return false; } - // set up logging - if (Quassel::runMode() != Quassel::ClientOnly) { - if (isOptionSet("loglevel")) { - QString level = optionValue("loglevel"); - - if (level == "Debug") - setLogLevel(DebugLevel); - else if (level == "Info") - setLogLevel(InfoLevel); - else if (level == "Warning") - setLogLevel(WarningLevel); - else if (level == "Error") - setLogLevel(ErrorLevel); - else { - qWarning() << qPrintable(tr("Invalid log level %1; supported are Debug|Info|Warning|Error").arg(level)); - return false; - } + // Set up logging + if (isOptionSet("loglevel")) { + QString level = optionValue("loglevel").toLower(); + + if (level == "debug") + setLogLevel(DebugLevel); + else if (level == "info") + setLogLevel(InfoLevel); + else if (level == "warning") + setLogLevel(WarningLevel); + else if (level == "error") + setLogLevel(ErrorLevel); + else { + qWarning() << qPrintable(tr("Invalid log level %1; supported are Debug|Info|Warning|Error").arg(level)); + return false; } + } - QString logfilename = optionValue("logfile"); - if (!logfilename.isEmpty()) { - instance()->_logFile.reset(new QFile{logfilename}); - if (!logFile()->open(QIODevice::Append | QIODevice::Text)) { - qWarning() << "Could not open log file" << logfilename << ":" << logFile()->errorString(); - instance()->_logFile.reset(); - } + QString logfilename = optionValue("logfile"); + if (!logfilename.isEmpty()) { + instance()->_logFile.reset(new QFile{logfilename}); + if (!logFile()->open(QIODevice::Append | QIODevice::Text)) { + qWarning() << qPrintable(tr("Could not open log file \"%1\": %2").arg(logfilename, logFile()->errorString())); + instance()->_logFile.reset(); } + } #ifdef HAVE_SYSLOG - instance()->_logToSyslog = isOptionSet("syslog"); + instance()->_logToSyslog = isOptionSet("syslog"); +#endif + +#if QT_VERSION < 0x050000 + qInstallMsgHandler(Logger::logMessage); +#else + qInstallMessageHandler(Logger::logMessage); #endif - } return true; } @@ -295,12 +299,13 @@ void Quassel::setupBuildInfo() // Check if we got a commit hash if (!QString(GIT_HEAD).isEmpty()) { buildInfo.commitHash = GIT_HEAD; - QDateTime date; - date.setTime_t(GIT_COMMIT_DATE); - buildInfo.commitDate = date.toString(); + // Set to Unix epoch, wrapped as a string for backwards-compatibility + buildInfo.commitDate = QString::number(GIT_COMMIT_DATE); } else if (!QString(DIST_HASH).contains("Format")) { buildInfo.commitHash = DIST_HASH; + // Leave as Unix epoch if set as Unix epoch, but don't force this for + // backwards-compatibility with existing packaging/release tools that might set strings. buildInfo.commitDate = QString(DIST_DATE); } @@ -505,6 +510,8 @@ QString Quassel::configDirPath() #endif /* Q_OS_MAC */ } + path = QFileInfo{path}.absoluteFilePath(); + if (!path.endsWith(QDir::separator()) && !path.endsWith('/')) path += QDir::separator(); @@ -517,7 +524,6 @@ QString Quassel::configDirPath() } instance()->_configDirPath = path; - return path; }