diff options
author | Sebastian Schmelzer | 2011-12-08 11:13:29 +0100 |
---|---|---|
committer | Sebastian Schmelzer | 2011-12-08 11:13:29 +0100 |
commit | 754bf0837778bf7bb8de72e62e46b91c9d29dffe (patch) | |
tree | 1735fd9153316eba11465d5bc02be689f894c503 /src/fbgui | |
parent | cleanup logging stuff (diff) | |
download | fbgui-754bf0837778bf7bb8de72e62e46b91c9d29dffe.tar.gz fbgui-754bf0837778bf7bb8de72e62e46b91c9d29dffe.tar.xz fbgui-754bf0837778bf7bb8de72e62e46b91c9d29dffe.zip |
fix empty log message bug ..
Diffstat (limited to 'src/fbgui')
-rw-r--r-- | src/fbgui/networkdiscovery.cpp | 185 |
1 files changed, 107 insertions, 78 deletions
diff --git a/src/fbgui/networkdiscovery.cpp b/src/fbgui/networkdiscovery.cpp index 1505763..49aa148 100644 --- a/src/fbgui/networkdiscovery.cpp +++ b/src/fbgui/networkdiscovery.cpp @@ -9,7 +9,7 @@ * */ - +#include <QTextStream> #include <sys/types.h> #include <signal.h> @@ -605,83 +605,112 @@ void NetworkDiscovery::handleNewInput() { */ void NetworkDiscovery::handleNewInputLine(QLocalSocket * client, QString logMsg) { - if (logMsg.trimmed().size() < 1) return; - - QString interface = logMsg.section(";", 0, 0); - QString s_state = logMsg.section(";", 1, 1); - QString s_subState = logMsg.section(";", 2, 2); - QString msg = logMsg.section(";", 3, 3); - int st = s_state.trimmed().toInt(); - int sst = s_subState.trimmed().toInt(); - //LOG4CXX_DEBUG(ndcLogger, logMsg); - - if (_ifNameToClient.size() < _numberOfProcesses && !_ifNameToClient.contains( - interface)) { - _ifNameToClient.insert(interface, client); - } - - switch (st) { - 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); - break; - default: - LOG4CXX_DEBUG(ndcLogger, "received unknown substatus: " << msg); - break; - } - break; - case LOG_ERR: - LOG4CXX_DEBUG(ndcLogger, "received error: " << msg); - break; - default: - LOG4CXX_DEBUG(ndcLogger, "" << logMsg); - break; - } + if (logMsg.trimmed().size() < 1) return; + + QString interface = logMsg.section(";", 0, 0); + QString s_state = logMsg.section(";", 1, 1); + QString s_subState = logMsg.section(";", 2, 2); + QString msg = logMsg.section(";", 3, 3); + int st = s_state.trimmed().toInt(); + int sst = s_subState.trimmed().toInt(); + //LOG4CXX_DEBUG(ndcLogger, logMsg); + + if (_ifNameToClient.size() < _numberOfProcesses + && !_ifNameToClient.contains(interface)) + { + _ifNameToClient.insert(interface, client); + } + + // st states + + // #define LOG_EMERG 0 /* system is unusable */ + // #define LOG_ALERT 1 /* action must be taken immediately */ + // #define LOG_CRIT 2 /* critical conditions */ + // #define LOG_ERR 3 /* error conditions */ + // #define LOG_WARNING 4 /* warning conditions */ + // #define LOG_NOTICE 5 /* normal but significant condition */ + // #define LOG_INFO 6 /* informational */ + // #define LOG_DEBUG 7 /* debug-level messages */ + + QString out; + QTextStream outStream(&out); + + switch (sst) + { + case DHCP_DISCOVER: + emit changeProgressBarValue(interface, 10); + outStream << interface << " send discover"; + break; + case DHCP_OFFER: + emit changeProgressBarValue(interface, 20); + outStream << interface << " got offer"; + break; + case DHCP_REQUEST: + emit changeProgressBarValue(interface, 30); + outStream << interface << " send request"; + break; + case DHCP_ACK: + emit changeProgressBarValue(interface, 40); + outStream << interface << " ack"; + break; + case DHCP_NAK: + emit changeProgressBarValue(interface, 40); + outStream << interface << " nak"; + break; + case DHCP_RELEASE: + outStream << interface << " release"; + break; + case DHCP_INFORM: + break; + case DHCPCD_ARP_TEST: + emit changeProgressBarValue(interface, 50); + outStream << interface << " do arp test"; + break; + case DHCP_DECLINE: + emit changeProgressBarValue(interface, 60); + break; + case DHCPCD_CONFIGURE: + emit changeProgressBarValue(interface, 70); + outStream << interface << " do configure interface"; + break; + case DHCPCD_WRITE: + emit changeProgressBarValue(interface, 80); + outStream << interface << " write conf file"; + break; + case DHCPCD_EXIT: + emit changeProgressBarValue(interface, 100); + outStream << interface << " exiting"; + break; + case DHCPCD_LOG: + outStream << "received dhcpcd log: " << msg; + break; + default: + outStream << "received unknown substatus: " << msg; + break; + } + + switch (st) + { + + case LOG_INFO: + LOG4CXX_INFO(ndcLogger, out); + break; + case LOG_NOTICE: + LOG4CXX_WARN(ndcLogger, out); + break; + case LOG_WARNING: + LOG4CXX_WARN(ndcLogger, out); + break; + case LOG_DEBUG: + LOG4CXX_DEBUG(ndcLogger, out); + break; + case LOG_ERR: + LOG4CXX_ERROR(ndcLogger, out); + break; + default: + LOG4CXX_DEBUG(ndcLogger, out); + break; + } } |