Changed some loglevels and ignore invalid service config rather than exit.
authorBjoern Sikora <bjoern.sikora@intra2net.com>
Fri, 21 May 2010 10:05:41 +0000 (12:05 +0200)
committerBjoern Sikora <bjoern.sikora@intra2net.com>
Fri, 21 May 2010 10:05:41 +0000 (12:05 +0200)
src/config.cpp
src/logger.cpp
src/logger.h

index 7afc166..e409103 100644 (file)
@@ -249,7 +249,9 @@ int Config::parse_cmd_line(int argc, char *argv[])
                 Log->print_service_object("New Service object from command line options:", service->get_protocol(), service->get_hostname(), service->get_login() ,service->get_password(), service->get_update_interval(), service->get_max_updates_within_interval(), service->get_dns_cache_ttl() , service->get_actual_ip(), service->get_last_updates());
             }
             else
-                return -1;
+            {
+                Log->print_invalid_service_config();
+            }
         }
         else if ( VariablesMap.count("protocol") || VariablesMap.count("host") || VariablesMap.count("login") || VariablesMap.count("password") )
         {
@@ -353,7 +355,7 @@ Service::Ptr Config::create_service(const string &protocol, const string& server
     ba::split(fqhn_parts,hostname,boost::is_any_of("."));
     if ( fqhn_parts.size() < 3 )
     {
-        Log->print_invalid_hostname(protocol);
+        Log->print_invalid_hostname(hostname);
         Service::Ptr service;
         return service;
     }
@@ -469,7 +471,9 @@ int Config::load_service_config_file(const string& full_filename)
                     Log->print_service_object("New Service object from config:", service->get_protocol(), service->get_hostname(), service->get_login() ,service->get_password(), service->get_update_interval(), service->get_max_updates_within_interval(), service->get_dns_cache_ttl() , service->get_actual_ip(), service->get_last_updates());
                 }
                 else
-                    return -1;
+                {
+                    Log->print_invalid_service_config();
+                }
             }
             else if ( vm.count("protocol") || vm.count("host") || vm.count("login") || vm.count("password") )
             {
index cb0fb30..68d4cad 100644 (file)
@@ -572,7 +572,7 @@ void Logger::print_caught_siguser1() const
  */
 void Logger::print_caught_sighup() const
 {
-    int level = 1;
+    int level = 0;
     if ( level <= Loglevel )
     {
         log_notice("Caught SIGHUP. Reloading config...");
@@ -585,7 +585,7 @@ void Logger::print_caught_sighup() const
  */
 void Logger::print_caught_siguser2() const
 {
-    int level = 1;
+    int level = 0;
     if ( level <= Loglevel )
     {
         log_notice("Caught SIGUSR2. Switching to online mode...");
@@ -598,7 +598,7 @@ void Logger::print_caught_siguser2() const
  */
 void Logger::print_caught_sigrtmin() const
 {
-    int level = 1;
+    int level = 0;
     if ( level <= Loglevel )
     {
         log_notice("Caught SIGRTMIN. Switching to online mode with webcheck enabled...");
@@ -641,7 +641,7 @@ void Logger::print_init_log_facility() const
  */
 void Logger::print_offline_mode() const
 {
-    int level = 0;
+    int level = 1;
     if ( level <= Loglevel )
     {
         log_notice("Offline mode...");
@@ -1369,7 +1369,7 @@ void Logger::print_invalid_hostname(const string& hostname) const
  */
 void Logger::print_ip_is_local(const string& ip) const
 {
-    int level = 0;
+    int level = 1;
     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
     {
         ostringstream msg;
@@ -1561,7 +1561,7 @@ void Logger::print_error_parsing_cmd(const string& error) const
  */
 void Logger::print_webcheck_exceed_interval( const time_t last_webcheck, const int webcheck_interval, const time_t current_time ) const
 {
-    int level = 0;
+    int level = 1;
     if ( level <= Loglevel )
     {
         ostringstream msg;
@@ -1731,7 +1731,7 @@ void Logger::print_error_getting_local_wan_ip(const std::string& system_call, co
  */
 void Logger::print_no_wan_ip() const
 {
-    int level = 0;
+    int level = 1;
     if ( level <= Loglevel )
     {
         ostringstream msg;
@@ -1739,3 +1739,16 @@ void Logger::print_no_wan_ip() const
         log_error(msg.str());
     }
 }
+
+
+/**
+ * Invalid service config was detected.
+ */
+void Logger::print_invalid_service_config() const
+{
+    int level = 0;
+    if ( level <= Loglevel )
+    {
+        log_error("Ignoring invalid service. Please check.\n");
+    }
+}
index 06f4534..2f1b153 100644 (file)
@@ -245,6 +245,8 @@ public:
     void print_no_update_needed(const std::string& hostname, const std::string& ip_dns_recheck, const std::string& ip_last_update, const std::string& ip_host, const time_t lastupdated) const;
 
     void print_error_getting_local_wan_ip(const std::string& system_call, const std::string& error) const;
+
+    void print_invalid_service_config() const;
 };
 
 #endif