From: Thomas Jarosch Date: Wed, 6 Oct 2010 15:39:29 +0000 (+0200) Subject: Log once if we can't determine our IP. Also log if we are unable to look up the dyndn... X-Git-Tag: v1.1~77 X-Git-Url: http://developer.intra2net.com/git/?p=bpdyndnsd;a=commitdiff_plain;h=f314167593a9f95c4904bd96d5f67e34922b371b Log once if we can't determine our IP. Also log if we are unable to look up the dyndns hostname --- diff --git a/src/logger.cpp b/src/logger.cpp index bce5a27..08852c3 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -542,7 +542,7 @@ void Logger::print_runnig_as_daemon(const int pid) const if ( level <= Loglevel ) { ostringstream msg; - msg << "Runnig as daemon: " << pid << endl; + msg << "Running as daemon: " << pid << endl; log_notice(msg.str()); } } @@ -1789,14 +1789,39 @@ void Logger::print_error_getting_local_wan_ip(const std::string& system_call, co /** * Could not get IP address of local wan interface. + * @param override_log_level Override log level with zero if true + */ +void Logger::print_no_wan_ip(bool override_log_level) const +{ + int level = 1; + + if (override_log_level) + level = 0; + + if ( level <= Loglevel ) + { + ostringstream msg; + msg << "Could not get IP address of local wan interface. Will retry later." << endl; + log_error(msg.str()); + } +} + + +/** + * Could not resolve current IP for DNS name + * @param override_log_level Override log level with zero if true */ -void Logger::print_no_wan_ip() const +void Logger::print_dns_lookup_failed(bool override_log_level, const std::string &hostname) const { int level = 1; + + if (override_log_level) + level = 0; + if ( level <= Loglevel ) { ostringstream msg; - msg << "Could not get IP address of local wan interface." << endl; + msg << "Could not resolve IP address for host " << hostname << ". Will retry later." << endl; log_error(msg.str()); } } diff --git a/src/logger.hpp b/src/logger.hpp index 8e6d25a..5015037 100644 --- a/src/logger.hpp +++ b/src/logger.hpp @@ -160,7 +160,9 @@ public: void print_webcheck_no_ip(); - void print_no_wan_ip() const; + void print_no_wan_ip(bool override_log_level) const; + + void print_dns_lookup_failed(bool override_log_level, const std::string &hostname) const; void print_webcheck_url_connection_problem(const char * curl_err_buff, const std::string& url); diff --git a/src/updater.cpp b/src/updater.cpp index 028a152..e2d26a0 100644 --- a/src/updater.cpp +++ b/src/updater.cpp @@ -226,7 +226,7 @@ void Updater::update_services(bool changed_to_online) const string ip_host = IPAddrHelp->get_actual_ip(Conf->get_webcheck_enabled()); if ( ip_host.empty() ) { - Log->print_no_wan_ip(); + Log->print_no_wan_ip(changed_to_online); return; } @@ -250,7 +250,10 @@ void Updater::update_services(bool changed_to_online) const // Test if the DNS-Record could not be found. if ( ip_dns_recheck.empty() ) + { + Log->print_dns_lookup_failed(changed_to_online, hostname); continue; + } // Test if the actual DNS-Record differs from the host's IP. if (ip_host == ip_dns_recheck )