From 4fdd6c59847a93f69bed6f77c580ae51e49e55cc Mon Sep 17 00:00:00 2001 From: Christian Herdtweck Date: Wed, 5 Nov 2014 15:08:58 +0100 Subject: [PATCH] changes in logging output: added information and changed priority --- src/dns/dnsresolver.cpp | 4 ++-- src/icmp/icmpv4header.cpp | 4 ++++ src/ip/ipv4header.cpp | 8 +++++--- src/main.cpp | 1 + 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/dns/dnsresolver.cpp b/src/dns/dnsresolver.cpp index 4ac11cb..6e44343 100644 --- a/src/dns/dnsresolver.cpp +++ b/src/dns/dnsresolver.cpp @@ -93,7 +93,7 @@ bool DnsResolver::resolve() return true; } - GlobalLogger.info() << "Resolved IP(s) for host : " << HostDnsAddress << endl; + GlobalLogger.info() << "Trying to resolve IP(s) for host : " << HostDnsAddress << endl; try { @@ -216,7 +216,7 @@ bool DnsResolver::handle_ip_address() } catch ( const boost::system::system_error & /*ex*/ ) { - GlobalLogger.info() << "Host is not an IP: " << HostDnsAddress << endl; + GlobalLogger.debug() << "Host is not an IP: " << HostDnsAddress << endl; } return false; diff --git a/src/icmp/icmpv4header.cpp b/src/icmp/icmpv4header.cpp index fbf441c..fcfcd51 100644 --- a/src/icmp/icmpv4header.cpp +++ b/src/icmp/icmpv4header.cpp @@ -11,6 +11,9 @@ #include "icmp/icmpechorequestmessage.h" #include "icmp/icmpgenericmessage.h" +#include +using I2n::Logger::GlobalLogger; + using namespace std; using boost::shared_ptr; @@ -132,6 +135,7 @@ void Icmpv4Header::set_icmp_message_format( const Icmpv4Type type ) break; case Icmpv4Type_InvalidLast: default: + GlobalLogger.error() << "Invalid ICMPv4 message type " << static_cast(type) << "!"; BOOST_ASSERT( !"Try to set an invalid ICMPv4 message type" ); break; } diff --git a/src/ip/ipv4header.cpp b/src/ip/ipv4header.cpp index 1c0dc22..42ba81e 100644 --- a/src/ip/ipv4header.cpp +++ b/src/ip/ipv4header.cpp @@ -217,10 +217,12 @@ istream &operator>>( // and stores in the buffer object (void) header.Payload.read( is ); - if ( header.get_version() != 4 ) + uint8_t header_version = header.get_version(); + if ( header_version != 4 ) { - GlobalLogger.error() << "Error: invalid IP header version." << endl; + GlobalLogger.error() << "Error: invalid IP header version: " << static_cast(header_version) << endl; is.setstate( ios::failbit ); + return is; } // read the consecutive N bytes (for options field) from the input stream @@ -229,7 +231,7 @@ istream &operator>>( static_cast( Ipv4HeaderSizeInBytes ); if ( ( options_length < 0 ) || ( 40 < options_length ) ) { - GlobalLogger.error() << "Error: invalid IP options length value." << endl; + GlobalLogger.error() << "Error: invalid IP options length value:" << options_length << endl; is.setstate( ios::failbit ); } else if ( ( 0 < options_length ) && ( options_length <= 40 ) ) diff --git a/src/main.cpp b/src/main.cpp index 916e5f1..44e96c0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -341,6 +341,7 @@ int main( int argc, const char *argv[] ) { int log_level = configuration->get_log_level(); I2n::Logger::set_log_level( log_level ); //lint !e534 + GlobalLogger.info() << "Set LogLevel to " << I2n::Logger::level_string() << endl; set_log_output( configuration ); -- 1.7.1