diff options
author | Sebastian Schmelzer | 2011-12-06 16:51:46 +0100 |
---|---|---|
committer | Sebastian Schmelzer | 2011-12-06 16:51:46 +0100 |
commit | 2b23951018043146001b49d71eb056fa111638e0 (patch) | |
tree | f6ede13fd9efeb97adaa93d7aded6577087204f0 /src/fbgui | |
parent | bigger log dialog (diff) | |
download | fbgui-2b23951018043146001b49d71eb056fa111638e0.tar.gz fbgui-2b23951018043146001b49d71eb056fa111638e0.tar.xz fbgui-2b23951018043146001b49d71eb056fa111638e0.zip |
cleanup logging stuff
Diffstat (limited to 'src/fbgui')
-rw-r--r-- | src/fbgui/html/js/networkDiscovery.js | 8 | ||||
-rw-r--r-- | src/fbgui/networkdiscovery.cpp | 190 |
2 files changed, 100 insertions, 98 deletions
diff --git a/src/fbgui/html/js/networkDiscovery.js b/src/fbgui/html/js/networkDiscovery.js index 65574b0..10b4f19 100644 --- a/src/fbgui/html/js/networkDiscovery.js +++ b/src/fbgui/html/js/networkDiscovery.js @@ -49,13 +49,13 @@ var showLog = function (t) { $("#nd_show_log_dialog").dialog( { buttons: { "Cancel": function() { $(this).dialog("close");}}, - minWidth: 86%, - maxHeight: 520, + minWidth: 920, + maxHeight: 620, modal: true, draggable: false, - closeOnEscape: false, + closeOnEscape: true, open: function(event, ui) { - $(this).css({'max-height': 520, 'overflow-y': 'auto'}); + $(this).css({'max-height': 620, 'overflow-y': 'auto'}); }, }); }; diff --git a/src/fbgui/networkdiscovery.cpp b/src/fbgui/networkdiscovery.cpp index 429ba89..1505763 100644 --- a/src/fbgui/networkdiscovery.cpp +++ b/src/fbgui/networkdiscovery.cpp @@ -115,7 +115,7 @@ void NetworkDiscovery::initAndRun(QString serverIp, bool userChoice, bool autoUp emit updateStatus("try to create server socket"); if (!_server->listen(serverPath)) { // emit signal to the gui that a critial error occoured - LOG4CXX_DEBUG(ndcLogger, " Unable to start server: " << _server->errorString()); + LOG4CXX_DEBUG(ndcLogger, "Unable to start server: " << _server->errorString()); emit abortBoot("Unable to start server: " + _server->errorString()); return; @@ -127,7 +127,7 @@ void NetworkDiscovery::initAndRun(QString serverIp, bool userChoice, bool autoUp emit updateStatus("check if cdhcpcd is available"); QFileInfo fInfo(_pathToDhcpcdExe); if (!fInfo.exists()) { - LOG4CXX_DEBUG(ndcLogger, " could not find customdhcpcd exe. Please check the path to this file."); + LOG4CXX_DEBUG(ndcLogger, "could not find customdhcpcd exe. Please check the path to this file."); emit abortBoot( "could not find customdhcpcd exe. Please check the path to this file."); return; @@ -185,19 +185,19 @@ void NetworkDiscovery::getListOfNetworkInterfacesWithAutoUp() { { LOG4CXX_DEBUG(ndcLogger, "found Interface:" << nI.humanReadableName()); if ((nI.flags() & QNetworkInterface::CanBroadcast)) { - LOG4CXX_DEBUG(ndcLogger, " flags: can broadcast "); + LOG4CXX_DEBUG(ndcLogger, "flags: can broadcast "); } if ((nI.flags() & QNetworkInterface::IsLoopBack)) { - LOG4CXX_DEBUG(ndcLogger, " flags: is LoopBack "); + LOG4CXX_DEBUG(ndcLogger, "flags: is LoopBack "); } if ((nI.flags() & QNetworkInterface::IsPointToPoint)) { - LOG4CXX_DEBUG(ndcLogger, " flags: is Point to Point "); + LOG4CXX_DEBUG(ndcLogger, "flags: is Point to Point "); } if ((nI.flags() & QNetworkInterface::IsRunning)) { - LOG4CXX_DEBUG(ndcLogger, " flags: is Running "); + LOG4CXX_DEBUG(ndcLogger, "flags: is Running "); } if ((nI.flags() & QNetworkInterface::IsUp)) { - LOG4CXX_DEBUG(ndcLogger, " flags: is Up "); + LOG4CXX_DEBUG(ndcLogger, "flags: is Up "); } if (((!(nI.flags() & QNetworkInterface::CanBroadcast) @@ -211,7 +211,7 @@ void NetworkDiscovery::getListOfNetworkInterfacesWithAutoUp() { } else if (!(nI.flags() & QNetworkInterface::IsUp)) { _networkManager->bringInterfaceUP(nI.humanReadableName()); - LOG4CXX_DEBUG(ndcLogger, " interface is down, try to bring up: " << nI.humanReadableName() ); + LOG4CXX_DEBUG(ndcLogger, "interface is down, try to bring up: " << nI.humanReadableName() ); _ifDownList.append(nI.humanReadableName()); } else if (!(nI.flags() & QNetworkInterface::IsRunning)) { @@ -219,7 +219,7 @@ void NetworkDiscovery::getListOfNetworkInterfacesWithAutoUp() { } } } else { - LOG4CXX_DEBUG(ndcLogger, " no interfaces found! "); + LOG4CXX_DEBUG(ndcLogger, "no interfaces found! "); } } @@ -238,19 +238,19 @@ void NetworkDiscovery::getListOfNetworkInterfaces() { { LOG4CXX_DEBUG(ndcLogger, "found Interface:" << nI.humanReadableName()); if ((nI.flags() & QNetworkInterface::CanBroadcast)) { - LOG4CXX_DEBUG(ndcLogger, " flags: can broadcast "); + LOG4CXX_DEBUG(ndcLogger, "flags: can broadcast "); } if ((nI.flags() & QNetworkInterface::IsLoopBack)) { - LOG4CXX_DEBUG(ndcLogger, " flags: is LoopBack "); + LOG4CXX_DEBUG(ndcLogger, "flags: is LoopBack "); } if ((nI.flags() & QNetworkInterface::IsPointToPoint)) { - LOG4CXX_DEBUG(ndcLogger, " flags: is Point to Point "); + LOG4CXX_DEBUG(ndcLogger, "flags: is Point to Point "); } if ((nI.flags() & QNetworkInterface::IsRunning)) { - LOG4CXX_DEBUG(ndcLogger, " flags: is Running "); + LOG4CXX_DEBUG(ndcLogger, "flags: is Running "); } if ((nI.flags() & QNetworkInterface::IsUp)) { - LOG4CXX_DEBUG(ndcLogger, " flags: is Up "); + LOG4CXX_DEBUG(ndcLogger, "flags: is Up "); } if (((!(nI.flags() & QNetworkInterface::CanBroadcast) || nI.flags() & QNetworkInterface::IsLoopBack) @@ -266,7 +266,7 @@ void NetworkDiscovery::getListOfNetworkInterfaces() { } } } else { - LOG4CXX_DEBUG(ndcLogger, " no interfaces found! "); + LOG4CXX_DEBUG(ndcLogger, "no interfaces found! "); } } @@ -307,17 +307,17 @@ void NetworkDiscovery::checkForIsRunning() { void NetworkDiscovery::slotReadyForRun() { if (_ifUpList.size() > 0) { foreach(QString i, _ifUpList) { - LOG4CXX_DEBUG(ndcLogger, " emit addInterface : " << i); + LOG4CXX_DEBUG(ndcLogger, "emit addInterface : " << i); emit addInterface(i); } _numberOfProcesses = _ifUpList.size(); emit updateStatus("start dhcp client for each interface"); runDHCPCD( _ifUpList); } else { - LOG4CXX_DEBUG(ndcLogger, " list is empty. Have not found usable interface. "); + LOG4CXX_DEBUG(ndcLogger, "list is empty. Have not found usable interface. "); emit foreach(QString i, _ifDownList) { - LOG4CXX_DEBUG(ndcLogger, " " << i << " is not in running state. (check cable)"); + LOG4CXX_DEBUG(ndcLogger, "" << i << " is not in running state. (check cable)"); } abortBoot("All interfaces are not usable. (e.g. please check if all network cables are plugged in. Read the log for more informations.)"); return; @@ -352,7 +352,7 @@ void NetworkDiscovery::runDHCPCD(QString interface) { _dhcpcdArguments.append(interface); QProcess * p = new QProcess(this); - LOG4CXX_DEBUG(ndcLogger, " start cdhcpcd with arguments: " << _dhcpcdArguments.join(", ")); + LOG4CXX_DEBUG(ndcLogger, "start cdhcpcd with arguments: " << _dhcpcdArguments.join(", ")); _clientProcessToIfNameMap.insert(p, interface); p->start(_pathToDhcpcdExe, _dhcpcdArguments); @@ -373,7 +373,7 @@ void NetworkDiscovery::runDHCPCD(QString interface) { void NetworkDiscovery::handleProcessStarted() { QProcess* p = qobject_cast<QProcess *> (QObject::sender()); QString ifName = _clientProcessToIfNameMap.value(p, "ifName"); - LOG4CXX_DEBUG(ndcLogger, " process started for interface: " << ifName); + LOG4CXX_DEBUG(ndcLogger, "process started for interface: " << ifName); } @@ -413,15 +413,15 @@ void NetworkDiscovery::handleProcessFinished(int exitCode, _numberOfProcesses = _numberOfProcesses - 1; if (!_blocked) { //_blocked becomes true, if _userChoice is false and we already found a usable interface if (ifName.compare("ifName") == 0) { - LOG4CXX_DEBUG(ndcLogger, " haven't found process!"); + LOG4CXX_DEBUG(ndcLogger, "haven't found process!"); } else { - LOG4CXX_DEBUG(ndcLogger, " process for interface " << ifName << " finished " << " exit code: " << exitCode << " exit status " << exitStatus); + LOG4CXX_DEBUG(ndcLogger, "process for interface " << ifName << " finished " << " exit code: " << exitCode << " exit status " << exitStatus); if (exitCode > 0) { - LOG4CXX_DEBUG(ndcLogger, " process exited unexpected: " << p->errorString()); + LOG4CXX_DEBUG(ndcLogger, "process exited unexpected: " << p->errorString()); emit updateIfStatus(ifName, "process exited unexpected" + p->errorString()); } else { - LOG4CXX_DEBUG(ndcLogger, " process normal exit "); + LOG4CXX_DEBUG(ndcLogger, "process normal exit "); emit changeProgressBarValue(ifName, 100); emit @@ -447,7 +447,7 @@ void NetworkDiscovery::handleProcessFinished(int exitCode, } } } else { - LOG4CXX_DEBUG(ndcLogger, " already blocked"); + LOG4CXX_DEBUG(ndcLogger, "already blocked"); emit updateIfStatus(ifName, "finished DHCP"); } } @@ -490,12 +490,12 @@ bool NetworkDiscovery::checkConnectivity(QString ifName) { ifConf->getGateway(), mss, AF_INET); if (checkConnectivityViaTcp(_serverIp)) { - LOG4CXX_DEBUG(ndcLogger, " passed connectivity check! for interface " << ifName); + LOG4CXX_DEBUG(ndcLogger, "passed connectivity check! for interface " << ifName); emit updateIfStatus(ifName, "connection possible"); return true; } else { - LOG4CXX_DEBUG(ndcLogger, " failed connectivity check! for interface " << ifName); + LOG4CXX_DEBUG(ndcLogger, "failed connectivity check! for interface " << ifName); emit updateIfStatus(ifName, "connection not possible"); return false; @@ -523,11 +523,11 @@ bool NetworkDiscovery::checkConnectivityViaTcp() { */ bool NetworkDiscovery::checkConnectivityViaTcp(QString server) { // check connectivity via tcp connection - LOG4CXX_DEBUG(ndcLogger, " check connectivity to server: " << server); + LOG4CXX_DEBUG(ndcLogger, "check connectivity to server: " << server); // do host lookup //QHostInfo hostInfo = QHostInfo::fromName(server); QTcpSocket *tcpSocket = new QTcpSocket(this); - //LOG4CXX_DEBUG(ndcLogger, " hostInfo first address: " << hostInfo.addresses().first().toString()); //hostInfo.addresses().first() + //LOG4CXX_DEBUG(ndcLogger, "hostInfo first address: " << hostInfo.addresses().first().toString()); //hostInfo.addresses().first() tcpSocket->connectToHost(server, 80); if (!tcpSocket->waitForConnected(500)) { LOG4CXX_DEBUG(ndcLogger, tcpSocket->errorString()); @@ -603,9 +603,10 @@ void NetworkDiscovery::handleNewInput() { * @param data * the message. (format <interfaceName>;<state>;<subState>;<msg> ) */ -void NetworkDiscovery::handleNewInputLine(QLocalSocket * client, QString data) { +void NetworkDiscovery::handleNewInputLine(QLocalSocket * client, QString logMsg) { + + if (logMsg.trimmed().size() < 1) return; - QString logMsg(data); QString interface = logMsg.section(";", 0, 0); QString s_state = logMsg.section(";", 1, 1); QString s_subState = logMsg.section(";", 2, 2); @@ -620,64 +621,65 @@ void NetworkDiscovery::handleNewInputLine(QLocalSocket * client, QString data) { } switch (st) { - case LOG_INFO: + case LOG_INFO: switch (sst) { - case DHCP_DISCOVER: - emit changeProgressBarValue(interface, 10); - LOG4CXX_DEBUG(ndcLogger, " " << interface << " send discover"); - break; - case DHCP_OFFER: - emit changeProgressBarValue(interface, 20); - LOG4CXX_DEBUG(ndcLogger, " " << interface << " got offer"); - break; - case DHCP_REQUEST: - emit changeProgressBarValue(interface, 30); - LOG4CXX_DEBUG(ndcLogger, " " << interface << " send request"); - break; - case DHCP_ACK: - emit changeProgressBarValue(interface, 40); - LOG4CXX_DEBUG(ndcLogger, " " << interface << " ack"); - break; - case DHCP_NAK: - emit changeProgressBarValue(interface, 40); - LOG4CXX_DEBUG(ndcLogger, " " << interface << " nak"); - break; - case DHCPCD_ARP_TEST: - emit changeProgressBarValue(interface, 50); - LOG4CXX_DEBUG(ndcLogger, " " << interface << " do arp test"); - break; - case DHCP_DECLINE: - emit changeProgressBarValue(interface, 60); - break; - case DHCP_RELEASE: - LOG4CXX_DEBUG(ndcLogger, " " << interface << " release"); - break; - case DHCP_INFORM: - break; - case DHCPCD_CONFIGURE: - emit changeProgressBarValue(interface, 70); - LOG4CXX_DEBUG(ndcLogger, " " << interface << " do configure interface"); - break; - case DHCPCD_WRITE: - emit changeProgressBarValue(interface, 80); - LOG4CXX_DEBUG(ndcLogger, " " << interface << " write conf file"); - break; - case DHCPCD_EXIT: - emit changeProgressBarValue(interface, 100); - LOG4CXX_DEBUG(ndcLogger, " " << interface << " exiting"); - break; - case DHCPCD_LOG: - LOG4CXX_DEBUG(ndcLogger, " received dhcpcd log: " << msg); - default: - LOG4CXX_DEBUG(ndcLogger, " received unknown substatus: " << msg); - break; - } + case DHCP_DISCOVER: + emit changeProgressBarValue(interface, 10); + LOG4CXX_DEBUG(ndcLogger, "" << interface << " send discover"); + break; + case DHCP_OFFER: + emit changeProgressBarValue(interface, 20); + LOG4CXX_DEBUG(ndcLogger, "" << interface << " got offer"); + break; + case DHCP_REQUEST: + emit changeProgressBarValue(interface, 30); + LOG4CXX_DEBUG(ndcLogger, "" << interface << " send request"); + break; + case DHCP_ACK: + emit changeProgressBarValue(interface, 40); + LOG4CXX_DEBUG(ndcLogger, "" << interface << " ack"); + break; + case DHCP_NAK: + emit changeProgressBarValue(interface, 40); + LOG4CXX_DEBUG(ndcLogger, "" << interface << " nak"); + break; + case DHCPCD_ARP_TEST: + emit changeProgressBarValue(interface, 50); + LOG4CXX_DEBUG(ndcLogger, "" << interface << " do arp test"); + break; + case DHCP_DECLINE: + emit changeProgressBarValue(interface, 60); + break; + case DHCP_RELEASE: + LOG4CXX_DEBUG(ndcLogger, "" << interface << " release"); + break; + case DHCP_INFORM: + break; + case DHCPCD_CONFIGURE: + emit changeProgressBarValue(interface, 70); + LOG4CXX_DEBUG(ndcLogger, "" << interface << " do configure interface"); + break; + case DHCPCD_WRITE: + emit changeProgressBarValue(interface, 80); + LOG4CXX_DEBUG(ndcLogger, "" << interface << " write conf file"); + break; + case DHCPCD_EXIT: + emit changeProgressBarValue(interface, 100); + LOG4CXX_DEBUG(ndcLogger, "" << interface << " exiting"); + break; + case DHCPCD_LOG: + LOG4CXX_DEBUG(ndcLogger, "received dhcpcd log: " << msg); + break; + default: + LOG4CXX_DEBUG(ndcLogger, "received unknown substatus: " << msg); + break; + } break; case LOG_ERR: - LOG4CXX_DEBUG(ndcLogger, " received error: " << msg); + LOG4CXX_DEBUG(ndcLogger, "received error: " << msg); break; default: - LOG4CXX_DEBUG(ndcLogger, " " << logMsg); + LOG4CXX_DEBUG(ndcLogger, "" << logMsg); break; } } @@ -721,10 +723,10 @@ int NetworkDiscovery::ip4_setManualConfiguration(QVariantMap result) { result["broadcast"].toString(), result["gateway"].toString(), 0, AF_INET, "/etc/", dns); - LOG4CXX_DEBUG(ndcLogger, " set man conf. and check connectivity"); + LOG4CXX_DEBUG(ndcLogger, "set man conf. and check connectivity"); if (!checkConnectivityViaTcp(_serverIp)) { - LOG4CXX_DEBUG(ndcLogger, " no connectivity. reset conf."); + LOG4CXX_DEBUG(ndcLogger, "no connectivity. reset conf."); interfaceconfiguration * ifc = _ifcMap.value( result["ifname"].toString(), NULL); if (ifc != NULL) { @@ -738,7 +740,7 @@ int NetworkDiscovery::ip4_setManualConfiguration(QVariantMap result) { return 0; } - LOG4CXX_DEBUG(ndcLogger, " emit signal continueBootWithoutCheck(" << result["ifname"].toString() << ")"); + LOG4CXX_DEBUG(ndcLogger, "emit signal continueBootWithoutCheck(" << result["ifname"].toString() << ")"); emit continueBootWithoutCheck(result["ifname"].toString()); return 0; @@ -762,7 +764,7 @@ QString NetworkDiscovery::getGatewayForInterface(QString ifName) { return ifConf->getGateway(); } else { - LOG4CXX_DEBUG(ndcLogger, " could not find interface configuration"); + LOG4CXX_DEBUG(ndcLogger, "could not find interface configuration"); return ""; } @@ -786,12 +788,12 @@ QString NetworkDiscovery::readLogFile() { } } else { - LOG4CXX_DEBUG(ndcLogger, " could not open log file"); + LOG4CXX_DEBUG(ndcLogger, "could not open log file"); retval = "could not open log file"; } } else { - LOG4CXX_DEBUG(ndcLogger, " log file does not exist at: " << _pathToLogFile); + LOG4CXX_DEBUG(ndcLogger, "log file does not exist at: " << _pathToLogFile); retval = " log file does not exist at: " + _pathToLogFile; } return retval; @@ -801,12 +803,12 @@ QString NetworkDiscovery::readLogFile() { /**/ void NetworkDiscovery::killDHCPCD() { - LOG4CXX_DEBUG(ndcLogger, " kill cdhcpcd processes"); + LOG4CXX_DEBUG(ndcLogger, "kill cdhcpcd processes"); QProcess * p = new QProcess(this); p->start("killall cdhcpcd"); p->waitForFinished(); if (p->exitCode() > 0) - LOG4CXX_DEBUG(ndcLogger, " [tryAgain] " << p->errorString()); + LOG4CXX_DEBUG(ndcLogger, "[tryAgain] " << p->errorString()); delete p; } @@ -875,7 +877,7 @@ QVariantMap NetworkDiscovery::getInterfaceConfig(QString ifName) { * connects the client readyRead signal with the handleNewInput slot. */ void NetworkDiscovery::handleNewConnection() { - LOG4CXX_DEBUG(ndcLogger, " New Connection arrived"); + LOG4CXX_DEBUG(ndcLogger, "New Connection arrived"); /*QLocalSocket **/ _client = _server->nextPendingConnection(); @@ -895,7 +897,7 @@ void NetworkDiscovery::handleClientDisconnect() { QLocalSocket * client = _clients.value(socket); - LOG4CXX_DEBUG(ndcLogger, " disconnect client"); + LOG4CXX_DEBUG(ndcLogger, "disconnect client"); handleNewInput(client); client->deleteLater(); } |