From 518ab031c29f36095578c8819e0befa503d1ae1d Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Sun, 24 Apr 2011 17:28:07 +0200 Subject: new logger engine to output in file, configurable per cmdline / config file --- src/main.cpp | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 601a62e..24e0430 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -54,13 +54,17 @@ int main(int argc, char *argv[]) { NULL, 'c' }, { "url", required_argument, NULL, 'u' }, { "download", required_argument, NULL, 'd' }, { "serial", required_argument, NULL, 's' }, { "trigger", required_argument, NULL, 't' }, { "debug", - required_argument, NULL, 'D' }, { "help", no_argument, NULL, 'h' } }; + required_argument, NULL, 'D' }, { "help", no_argument, NULL, 'h' }, { + "logfile", required_argument, NULL, 'l' } }; int opt = getopt_long(argc, argv, optString, longOpts, &longIndex); while (opt != -1) { switch (opt) { case 'c': clOpts.insert("configFile", optarg); break; + case 'l': + clOpts.insert("logFile", optarg); + break; case 'u': clOpts.insert("url", optarg); break; @@ -90,18 +94,10 @@ int main(int argc, char *argv[]) { debugMode = clOpts.value("debug").toInt(); // start basic debug output on terminal qxtLog->disableLoggerEngine("DEFAULT"); + qxtLog->enableLogLevels(QxtLogger::DebugLevel); qxtLog->addLoggerEngine("std_logger", new LoggerEngine_std); qxtLog->initLoggerEngine("std_logger"); qxtLog->setMinimumLevel("std_logger", QxtLogger::DebugLevel); - qxtLog->enableLogLevels(QxtLogger::DebugLevel); - qxtLog->debug() << "Initializing fbgui..."; - // start debug logging to file. - qxtLog->addLoggerEngine("file_logger", new LoggerEngine_file); - - //qxtLog->initLoggerEngine("std_logger"); - //qxtLog->setMinimumLevel("std_logger", QxtLogger::DebugLevel); - //qxtLog->enableLogLevels(QxtLogger::DebugLevel); - } else debugMode = -1; @@ -175,12 +171,27 @@ int main(int argc, char *argv[]) { // save ip config location (file generated by uchpc) if (confFileSettings.contains("default/ip_config")) ipConfigFilePath = confFileSettings.value("default/ip_config").toString(); - //else - // ipConfigFilePath = QString("/tmp/ip_config"); + + // save path to log file + if (clOpts.contains("logFile")) + logFilePath = clOpts.value("logFile"); + else if (confFileSettings.contains("default/log_file")) + logFilePath = confFileSettings.value("default/log_file").toString(); + else + logFilePath = DEFAULT_LOG_FILE_PATH; + + // activate file logger if debug mode activated. + if (debugMode > -1) { + // start debug logging to file. + qxtLog->addLoggerEngine("file_logger", + new LoggerEngine_file(logFilePath)); + qxtLog->setMinimumLevel("file_logger", QxtLogger::DebugLevel); + } // print config qxtLog->debug() << "************* CONFIG INFO *************"; qxtLog->debug() << "configFilePath: " << configFilePath.toUtf8(); + qxtLog->debug() << "logFilePath: " << logFilePath.toUtf8(); qxtLog->debug() << "ipConfigFilePath:" << ipConfigFilePath.toUtf8(); qxtLog->debug() << "baseURL: " << baseURL.toString().toUtf8(); qxtLog->debug() << "downloadDir : " << downloadPath.toUtf8(); @@ -190,9 +201,13 @@ int main(int argc, char *argv[]) { // set invisible cursor QWSServer::instance()->setCursorVisible(false); - QWSServer::instance()->setDefaultKeyboard("TTY:/dev/tty0"); - QWSServer::instance()->setDefaultMouse("IntelliMouse:/dev/mice"); + + // set default keyboard / mouse drivers. TODO: fix this, doesn't work... + //QWSServer::instance()->setDefaultKeyboard("TTY:/dev/tty0"); + //QWSServer::instance()->setDefaultMouse("IntelliMouse:/dev/mice"); + // start fbgui + qxtLog->debug() << "Initializing fbgui..."; fbgui gui; gui.show(); return app.exec(); -- cgit v1.2.3-55-g7522