summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
6de2be9)
Initialize logging earlier, so output during core initialization
gets routed properly.
Enable the logging options also for quasselclient; there's no good
reason to limit this to the core and monolithic client. However, as
a side-effect, the default log level is now Info also for the client,
so "-l Debug" must be specified on the command line to get debug
output.
cliParser->addOption("configdir", 'c', "Specify the directory holding configuration files, the SQlite database and the SSL certificate", "path");
#endif
cliParser->addOption("datadir", 0, "DEPRECATED - Use --configdir instead", "path");
cliParser->addOption("configdir", 'c', "Specify the directory holding configuration files, the SQlite database and the SSL certificate", "path");
#endif
cliParser->addOption("datadir", 0, "DEPRECATED - Use --configdir instead", "path");
+ cliParser->addOption("loglevel", 'L', "Loglevel Debug|Info|Warning|Error", "level", "Info");
+#ifdef HAVE_SYSLOG
+ cliParser->addSwitch("syslog", 0, "Log to syslog");
+#endif
+ cliParser->addOption("logfile", 'l', "Log to a file", "path");
#ifndef BUILD_CORE
// put client-only arguments here
#ifndef BUILD_CORE
// put client-only arguments here
cliParser->addOption("listen", 0, "The address(es) quasselcore will listen on", "<address>[,<address>[,...]]", "::,0.0.0.0");
cliParser->addOption("port", 'p', "The port quasselcore will listen at", "port", "4242");
cliParser->addSwitch("norestore", 'n', "Don't restore last core's state");
cliParser->addOption("listen", 0, "The address(es) quasselcore will listen on", "<address>[,<address>[,...]]", "::,0.0.0.0");
cliParser->addOption("port", 'p', "The port quasselcore will listen at", "port", "4242");
cliParser->addSwitch("norestore", 'n', "Don't restore last core's state");
- cliParser->addOption("loglevel", 'L', "Loglevel Debug|Info|Warning|Error", "level", "Info");
-#ifdef HAVE_SYSLOG
- cliParser->addSwitch("syslog", 0, "Log to syslog");
-#endif
- cliParser->addOption("logfile", 'l', "Log to a file", "path");
cliParser->addSwitch("config-from-environment", 0, "Load configuration from environment variables");
cliParser->addOption("select-backend", 0, "Switch storage backend (migrating data if possible)", "backendidentifier");
cliParser->addOption("select-authenticator", 0, "Select authentication backend", "authidentifier");
cliParser->addSwitch("config-from-environment", 0, "Load configuration from environment variables");
cliParser->addOption("select-backend", 0, "Switch storage backend (migrating data if possible)", "backendidentifier");
cliParser->addOption("select-authenticator", 0, "Select authentication backend", "authidentifier");
- // 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();
- instance()->_logToSyslog = isOptionSet("syslog");
+ instance()->_logToSyslog = isOptionSet("syslog");
+#endif
+
+#if QT_VERSION < 0x050000
+ qInstallMsgHandler(Logger::logMessage);
+#else
+ qInstallMessageHandler(Logger::logMessage);
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
-#include "coreapplication.h"
-
+#include "coreapplication.h"
CoreApplicationInternal::CoreApplicationInternal()
: _coreCreated(false)
CoreApplicationInternal::CoreApplicationInternal()
: _coreCreated(false)
bool CoreApplicationInternal::init()
{
bool CoreApplicationInternal::init()
{
- /* FIXME
- 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.
- */
- QFile logFile;
- if (!Quassel::optionValue("logfile").isEmpty()) {
- logFile.setFileName(Quassel::optionValue("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();
- }
-
Core::instance(); // create and init the core
_coreCreated = true;
Core::instance(); // create and init the core
_coreCreated = true;
bool CoreApplication::init()
{
bool CoreApplication::init()
{
- if (Quassel::init() && _internal->init()) {
-#if QT_VERSION < 0x050000
- qInstallMsgHandler(Logger::logMessage);
-#else
- qInstallMessageHandler(Logger::logMessage);
-#endif
- return true;
- }
- return false;
+ return Quassel::init() && _internal->init();