Added logging for external logging failures and removed unneccessary statements.
authorBjoern Sikora <bjoern.sikora@intra2net.com>
Thu, 17 Sep 2009 16:16:56 +0000 (18:16 +0200)
committerBjoern Sikora <bjoern.sikora@intra2net.com>
Thu, 17 Sep 2009 16:16:56 +0000 (18:16 +0200)
src/logger.cpp
src/logger.h

index 4f9ce3c..1b7da66 100644 (file)
@@ -72,8 +72,10 @@ void Logger::log_warning(const string& msg, int level) const
         external.append("\"");
         external.append(msg);
         external.append("\"");
-        int ret_val = system(external.c_str());
-        // TODO: parse return code and error handling
+        if ( system(external.c_str()) != 0 )
+        {
+            print_error_external_logging(external);
+        }
     }
 }
 
@@ -154,7 +156,7 @@ void Logger::set_log_facility(const int _loglevel, const bool _syslog, const str
 void Logger::print_usage(const Options_descriptionPtr opt_desc) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Usage: bpdyndnsd [Command line options]" << "\n" << endl;
@@ -171,7 +173,7 @@ void Logger::print_usage(const Options_descriptionPtr opt_desc) const
 void Logger::print_version() const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Bullet proof dynamic dns daemon.\nbpdyndnsd " << VERSION << "." << REVISION << "." << RELEASE << endl;
@@ -186,7 +188,7 @@ void Logger::print_version() const
 void Logger::print_cmd_parsed() const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         log_notice("Command line options successfully parsed.",level);
     }
@@ -196,7 +198,7 @@ void Logger::print_cmd_parsed() const
 void Logger::print_conf_files_parsed() const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         log_notice("Config files successfully parsed.",level);
     }
@@ -210,7 +212,7 @@ void Logger::print_conf_files_parsed() const
 void Logger::print_conf_loaded(const string& config_path) const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Config files successfully loaded in: " << config_path << endl;
@@ -226,7 +228,7 @@ void Logger::print_conf_loaded(const string& config_path) const
 void Logger::print_conf_not_loaded(const string& config_path) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Config files couldn't be loaded in: " << config_path << endl;
@@ -242,7 +244,7 @@ void Logger::print_conf_not_loaded(const string& config_path) const
 void Logger::print_error_opening_r(const string& filename) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Error opening file for reading: " << filename << endl;
@@ -258,7 +260,7 @@ void Logger::print_error_opening_r(const string& filename) const
 void Logger::print_error_opening_rw(const string& filename) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Error opening file for writing: " << filename << endl;
@@ -274,7 +276,7 @@ void Logger::print_error_opening_rw(const string& filename) const
 void Logger::print_destructor_call(const string& _class) const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Destructor call: " << _class << endl;
@@ -290,7 +292,7 @@ void Logger::print_destructor_call(const string& _class) const
 void Logger::print_constructor_call(const string& _class) const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Constructor call: " << _class << endl;
@@ -306,7 +308,7 @@ void Logger::print_constructor_call(const string& _class) const
 void Logger::print_update_service(const string& service) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Running update for service: " << service << endl;
@@ -322,7 +324,7 @@ void Logger::print_update_service(const string& service) const
 void Logger::print_unknown_cmd_option(const string& unknown_option) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Unknown option on command line detected: " << unknown_option << endl;
@@ -338,7 +340,7 @@ void Logger::print_unknown_cmd_option(const string& unknown_option) const
 void Logger::print_unknown_protocol(const string& protocol) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Unknown protocol defined: " << protocol << endl;
@@ -354,7 +356,7 @@ void Logger::print_unknown_protocol(const string& protocol) const
 void Logger::print_load_service_conf(const string& filename) const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Loading service config file: " << filename << endl;
@@ -370,7 +372,7 @@ void Logger::print_load_service_conf(const string& filename) const
 void Logger::print_load_main_conf(const string& filename) const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Loading main config file: " << filename << endl;
@@ -386,7 +388,7 @@ void Logger::print_load_main_conf(const string& filename) const
 void Logger::print_unknown_service_conf_option(const string& service_conf_file, const string& unknown_option) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Unknown option in service config file detected: " << service_conf_file << " Unknown option: " << unknown_option << endl;
@@ -402,7 +404,7 @@ void Logger::print_unknown_service_conf_option(const string& service_conf_file,
 void Logger::print_unknown_main_conf_option(const string& unknown_option) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Unknown option in main config file detected: " << unknown_option << endl;
@@ -418,7 +420,7 @@ void Logger::print_unknown_main_conf_option(const string& unknown_option) const
 void Logger::print_error_config_path(const string& config_path) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Config path doesn't exists or is not a diretory: " << config_path << endl;
@@ -433,7 +435,7 @@ void Logger::print_error_config_path(const string& config_path) const
 void Logger::print_missing_cmd_service_option() const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         log_error("Missing option to initialize service. Protocol, host, login and password must be specified.",level);
     }
@@ -447,7 +449,7 @@ void Logger::print_missing_cmd_service_option() const
 void Logger::print_missing_service_conf_option(const string& service_conf_file) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Missing option in service config file " << service_conf_file << " to initialize service. Protocol, host, login and password must be specified." << endl;
@@ -463,7 +465,7 @@ void Logger::print_missing_service_conf_option(const string& service_conf_file)
 void Logger::print_runnig_as_daemon(const int pid) const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Runnig as daemon: " << pid << endl;
@@ -479,7 +481,7 @@ void Logger::print_runnig_as_daemon(const int pid) const
 void Logger::print_daemon_mode(const bool daemon_mode) const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         string mode = "disabled";
         if (daemon_mode == true)
@@ -497,9 +499,9 @@ void Logger::print_daemon_mode(const bool daemon_mode) const
 void Logger::print_error_fork() const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
-        log_notice("Error while trying to fork.",level);
+        log_error("Error while trying to fork.",level);
     }
 }
 
@@ -511,7 +513,7 @@ void Logger::print_error_fork() const
 void Logger::print_pid_found(const int pid) const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Pidfile found: " << pid << ". Checking if process is still runnig..." << endl;
@@ -527,7 +529,7 @@ void Logger::print_pid_found(const int pid) const
 void Logger::print_process_already_running(const int pid) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Another bpdyndnsd process with PID " << pid << " is already running!" << endl;
@@ -542,7 +544,7 @@ void Logger::print_process_already_running(const int pid) const
 void Logger::print_caught_sigterm() const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         log_notice("Caught SIGTERM. Exiting...",level);
     }
@@ -555,7 +557,7 @@ void Logger::print_caught_sigterm() const
 void Logger::print_caught_siguser1() const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         log_notice("Caught SIGUSR1. Switching to offline mode...",level);
     }
@@ -568,7 +570,7 @@ void Logger::print_caught_siguser1() const
 void Logger::print_caught_sighup() const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         log_notice("Caught SIGHUP. Reloading config and switching to online mode...",level);
     }
@@ -581,7 +583,7 @@ void Logger::print_caught_sighup() const
 void Logger::print_error_setting_signal(const string& signal) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Error while setting signal handler for: " << signal << endl;
@@ -596,7 +598,7 @@ void Logger::print_error_setting_signal(const string& signal) const
 void Logger::print_init_log_facility() const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Initialized logging facility." << " Loglevel: " << Loglevel << " Syslog: " << Syslog << endl;
@@ -611,7 +613,7 @@ void Logger::print_init_log_facility() const
 void Logger::print_offline_mode() const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         log_notice("Offline mode...",level);
     }
@@ -624,7 +626,7 @@ void Logger::print_offline_mode() const
 void Logger::print_serialized_objects_success() const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         log_notice("Serialized objects successfully.",level);
     }
@@ -637,7 +639,7 @@ void Logger::print_serialized_objects_success() const
 void Logger::print_deserialized_objects_success() const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         log_notice("De-serialized objects successfully.",level);
     }
@@ -657,7 +659,7 @@ void Logger::print_deserialized_objects_success() const
 void Logger::print_service_object(const string& message, const string& protocol, const string& hostname, const string& login, const string& password, const int update_interval, const int max_updates_within_interval, const int dns_cache_ttl , const string& actual_ip, list<int>* lastupdated) const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << message << endl;
@@ -685,7 +687,7 @@ void Logger::print_service_object(const string& message, const string& protocol,
 void Logger::print_exception_serialize(const string& exception) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Error while trying to serialize Serviceholder object: " << exception << endl;
@@ -701,7 +703,7 @@ void Logger::print_exception_serialize(const string& exception) const
 void Logger::print_exception_deserialize(const string& exception) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Error while trying to de-serialize Serviceholder object: " << exception << endl;
@@ -717,7 +719,7 @@ void Logger::print_exception_deserialize(const string& exception) const
 void Logger::print_error_kill_child(const int pid) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Could not kill child process with PID: " << pid << endl;
@@ -733,7 +735,7 @@ void Logger::print_error_kill_child(const int pid) const
 void Logger::print_child_killed(const int pid) const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Killed child process with PID: " << pid << endl;
@@ -765,7 +767,7 @@ void Logger::print_no_object_file(const string& object_file) const
 void Logger::print_hostname(const string& hostname) const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Detected following hostname of localhost: " << hostname << endl;
@@ -781,7 +783,7 @@ void Logger::print_hostname(const string& hostname) const
 void Logger::print_own_ipv4(const string& ip_addr_v4, const string& hostname) const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Detected following IPv4-Address of host: " << hostname << " : " << ip_addr_v4 << endl;
@@ -797,7 +799,7 @@ void Logger::print_own_ipv4(const string& ip_addr_v4, const string& hostname) co
 void Logger::print_own_ipv6(const string& ip_addr_v6, const string& hostname) const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Detected following IPv6-Address of host: " << hostname << " : " << ip_addr_v6 << endl;
@@ -814,7 +816,7 @@ void Logger::print_own_ipv6(const string& ip_addr_v6, const string& hostname) co
 void Logger::print_error_hostname_to_ip(const string& exception, const string& hostname) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Could not resolve the hostname: " << hostname << " to an IP-Address: " << exception << endl;
@@ -830,7 +832,7 @@ void Logger::print_error_hostname_to_ip(const string& exception, const string& h
 void Logger::print_update_service_successful(const string& service) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Updated service successful: " << service << endl;
@@ -877,7 +879,7 @@ void Logger::print_webcheck_url_connection_problem(const char * curl_err_buff, c
 void Logger::print_webcheck_error(const char * curl_err_buff, const string& url) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "There was an error while trying to connect to following URL: " << url << " CURL error: " << curl_err_buff << endl;
@@ -893,7 +895,7 @@ void Logger::print_webcheck_error(const char * curl_err_buff, const string& url)
 void Logger::print_received_curl_data(const string& curl_data) const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Received CURL data: " << curl_data << endl;
@@ -909,7 +911,7 @@ void Logger::print_received_curl_data(const string& curl_data) const
 void Logger::print_regex_found_ip(const string& ip) const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Found IP-Address via regex: " << ip << endl;
@@ -941,7 +943,7 @@ void Logger::print_regex_ip_not_found(const string& data) const
 void Logger::print_multiple_cmd_option(const string& message) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "The same option is only allowed once: " << message << endl;
@@ -991,7 +993,7 @@ void Logger::print_update_service_failure(const string& service) const
 void Logger::print_starting_shutdown() const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         log_notice("Shutting down ...",level);
     }
@@ -1004,7 +1006,7 @@ void Logger::print_starting_shutdown() const
 void Logger::print_shutdown_succeeded() const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         log_notice("Shutting down complete ...",level);
     }
@@ -1017,7 +1019,7 @@ void Logger::print_shutdown_succeeded() const
 void Logger::print_shutdown_parent_succeeded() const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         log_notice("Shutting down parent process completed ...",level);
     }
@@ -1030,7 +1032,7 @@ void Logger::print_shutdown_parent_succeeded() const
 void Logger::print_starting_shutdown_parent() const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         log_notice("Shutting down parent process ...",level);
     }
@@ -1047,7 +1049,7 @@ void Logger::print_starting_shutdown_parent() const
 void Logger::print_recheck_dns_entry(const string& hostname, const int lastupdated, const int dns_cache_ttl, const int current_time) const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "DNS cache record for host <" << hostname << "> expired or host will be updated for the first time: Lastupdated: " << lastupdated << " DNS cache ttl: " << dns_cache_ttl << " Current time: " << current_time << " Checking current DNS cache status." << endl;
@@ -1064,7 +1066,7 @@ void Logger::print_recheck_dns_entry(const string& hostname, const int lastupdat
 void Logger::print_cached_dns_entry(const string& hostname, const string& cached_dns_entry, const string& lastupdated_ip) const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Cached DNS record for host <" << hostname << "> : " << cached_dns_entry << " Last updated IP: " << lastupdated_ip << endl;
@@ -1079,7 +1081,7 @@ void Logger::print_cached_dns_entry(const string& hostname, const string& cached
 void Logger::print_missing_cmd_proxy_option() const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         log_error("Missing option to initialize proxy. http_proxy and http_proxy_port must be specified.",level);
     }
@@ -1094,7 +1096,7 @@ void Logger::print_missing_cmd_proxy_option() const
 void Logger::print_multiple_service_conf_option(const string& service_conf_file, const string& message) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Multiple occurrences of the same option in service config file detected: " << service_conf_file << " " << message << endl;
@@ -1111,7 +1113,7 @@ void Logger::print_multiple_service_conf_option(const string& service_conf_file,
 void Logger::print_multiple_main_conf_option(const string& main_conf_file, const string& message) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Multiple occurrences of the same option in main config file detected: " << main_conf_file << " " << message << endl;
@@ -1127,7 +1129,7 @@ void Logger::print_multiple_main_conf_option(const string& main_conf_file, const
 void Logger::print_missing_conf_proxy_option(const string& main_conf_filename) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Missing option to initialize proxy in main config file: " << main_conf_filename << " http_proxy and http_proxy_port must be specified." << endl;
@@ -1143,7 +1145,7 @@ void Logger::print_missing_conf_proxy_option(const string& main_conf_filename) c
 void Logger::print_no_domain_part(const string& hostname) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "There is no domain part in the given hostname: " << hostname << endl;
@@ -1216,7 +1218,7 @@ void Logger::print_curl_error(const string& url, const int curl_err_code, const
 void Logger::print_curl_data(const string& curl_writedata_buff) const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Data received by curl: " << curl_writedata_buff << endl;
@@ -1251,7 +1253,7 @@ void Logger::print_service_not_authorized(const string& service, const string& u
 void Logger::print_http_status_code(const std::string& url, const long http_code) const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Requested URL: " << url << " Received HTTP status code: " << http_code << endl;
@@ -1333,7 +1335,7 @@ void Logger::print_ip_is_local(const string& ip) const
 void Logger::print_regex_match(const string& regex, const string& matching_string) const
 {
     int level = 1;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "Regex: " << regex << " is matching in: " << matching_string << endl;
@@ -1409,7 +1411,7 @@ void Logger::print_gnudip_requires_servername() const
 void Logger::print_exception_md5_sum(const std::string& what) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "An exception occured while computing a md5 sum: " << what << endl;
@@ -1425,7 +1427,7 @@ void Logger::print_exception_md5_sum(const std::string& what) const
 void Logger::print_network_error(const std::string& what) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "An netowrk exception occured: " << what << endl;
@@ -1442,10 +1444,25 @@ void Logger::print_network_error(const std::string& what) const
 void Logger::print_undefined_protocol_error(const std::string& protocol, const std::string& error) const
 {
     int level = 0;
-    if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
+    if ( level <= Loglevel )
     {
         ostringstream msg;
         msg << "An undefined protocol error occured. Protocol: " << protocol << " Error: " << error << endl;
         log_error(msg.str(),level);
     }
 }
+
+/**
+ * Error while trying to log through external program.
+ * @param external_prog The external program called.
+ */
+void Logger::print_error_external_logging(const std::string& external_prog) const
+{
+    int level = 0;
+    if ( level <= Loglevel )
+    {
+        ostringstream msg;
+        msg << "Error while trying to log through external program: " << external_prog << endl;
+        log_notice(msg.str(),level);
+    }
+}
index d946d50..97bec42 100644 (file)
@@ -211,6 +211,8 @@ public:
     void print_network_error(const std::string& what) const;
 
     void print_undefined_protocol_error(const std::string& protocol, const std::string& error) const;
+
+    void print_error_external_logging(const std::string& external_prog) const;
 };
 
 #endif