X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcommon%2Fmain.cpp;h=50221a2ad4ca836e0b8183cab7ec1d0c528d4768;hb=92789e6323ca73383a7954d834ecfc093234f5e2;hp=d7cd4e54df163d327e3571e7779fa2eda4830357;hpb=665faa937a52fc6175741292737c4a52875b4f75;p=quassel.git diff --git a/src/common/main.cpp b/src/common/main.cpp index d7cd4e54..50221a2a 100644 --- a/src/common/main.cpp +++ b/src/common/main.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include "global.h" #include "logger.h" @@ -64,8 +65,6 @@ int main(int argc, char **argv) { signal(SIGTERM, handle_signal); signal(SIGINT, handle_signal); - // Logger logger; - Global::registerMetaTypes(); Global::setupVersion(); @@ -86,6 +85,9 @@ int main(int argc, char **argv) { // put core-only arguments here Global::parser.addOption("port",'p',"The port quasselcore will listen at",QString("4242")); Global::parser.addSwitch("norestore", 'n', "Don't restore last core's state"); + Global::parser.addOption("logfile",'l',"Path to logfile"); + Global::parser.addOption("loglevel",'L',"Loglevel Debug|Info|Warning|Error","Info"); + Global::parser.addOption("datadir", 0, "Specify the directory holding datafiles like the Sqlite DB and the SSL Cert"); #endif // BUILD_QTUI #ifndef BUILD_CORE // put client-only arguments here @@ -101,6 +103,20 @@ int main(int argc, char **argv) { return 1; } + /* + This is an initial check if logfile is writable since the warning would spam stdout if done + in current Logger implementation. Can be dropped whenever the logfile is only opened once. + */ + if(Global::runMode != Global::ClientOnly) { + QFile logFile; + if(!Global::parser.value("logfile").isEmpty()) { + logFile.setFileName(Global::parser.value("logfile")); + if(!logFile.open(QIODevice::Append | QIODevice::Text)) + qWarning("Warning: Couldn't open logfile '%s' - will log to stdout instead",qPrintable(logFile.fileName())); + else logFile.close(); + } + } + qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); // Set up i18n support