Log once if we can't determine our IP. Also log if we are unable to look up the dyndn...
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Wed, 6 Oct 2010 15:39:29 +0000 (17:39 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Wed, 6 Oct 2010 15:39:29 +0000 (17:39 +0200)
src/logger.cpp
src/logger.hpp
src/updater.cpp

index bce5a27..08852c3 100644 (file)
@@ -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());
     }
 }
index 8e6d25a..5015037 100644 (file)
@@ -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);
 
index 028a152..e2d26a0 100644 (file)
@@ -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 )