X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fmain.cpp;h=e72166d20545e536861a9c1f50b42da58e122620;hp=d7cd4e54df163d327e3571e7779fa2eda4830357;hb=0d66a6f9ed6ea90493bca69ff781a1131d981503;hpb=5b4437c6ce729f4d51f7664ca839680853fd21c1 diff --git a/src/common/main.cpp b/src/common/main.cpp index d7cd4e54..e72166d2 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,8 @@ 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","./quassel.log"); + Global::parser.addOption("loglevel",'L',"Loglevel Debug|Info|Warning|Error","Info"); #endif // BUILD_QTUI #ifndef BUILD_CORE // put client-only arguments here @@ -101,6 +102,21 @@ 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())); + logFile.close(); + } + else qWarning("Warning: Couldn't open logfile '%s' - will log to stdout instead",qPrintable(logFile.fileName())); + } + qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); // Set up i18n support