Logger::Logger()
: Loglevel(0)
, Syslog(false)
+ , ExternalWarningLog("")
+ , ExternalWarningLevel(0)
{
- set_log_facility(Loglevel,Syslog);
+ set_log_facility(Loglevel,Syslog,ExternalWarningLog,ExternalWarningLevel);
}
* Decides if Logging through syslog if enabled or through std.
* @param msg The message to log.
*/
-void Logger::log_notice(const string& msg) const
+void Logger::log_notice(const string& msg, int level) const
{
if ( Syslog )
syslog(LOG_NOTICE,msg.c_str());
* Decides if Logging through syslog if enabled or through std.
* @param msg The message to log.
*/
-void Logger::log_warning(const string& msg) const
+void Logger::log_warning(const string& msg, int level) const
{
if ( Syslog )
syslog(LOG_WARNING,msg.c_str());
else
cout << msg << endl;
+
+ if ( (level <= ExternalWarningLevel) && (!ExternalWarningLog.empty()) )
+ {
+ string external = ExternalWarningLog;
+ external.append(" ");
+ external.append(msg);
+ int ret_val = system(external.c_str());
+ }
}
* Decides if Logging through syslog if enabled or through std.
* @param msg The message to log.
*/
-void Logger::log_error(const string& msg) const
+void Logger::log_error(const string& msg, int level) const
{
if ( Syslog )
syslog(LOG_ERR,msg.c_str());
/**
* Initialize the logging facility.
*/
-void Logger::set_log_facility(const int _loglevel, const bool _syslog)
+void Logger::set_log_facility(const int _loglevel, const bool _syslog, const string& _external_error_log, const int _external_error_level)
{
Loglevel = _loglevel;
Syslog = _syslog;
+ ExternalWarningLog = _external_error_log;
+ ExternalWarningLevel = _external_error_level;
+
if ( Syslog )
openlog("bpdyndnsd",LOG_PID,LOG_DAEMON);
*/
void Logger::print_usage(const Options_descriptionPtr opt_desc) const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Usage: bpdyndnsd [Command line options]" << "\n" << endl;
msg << *opt_desc << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_version() const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Bullet proof dynamic dns daemon.\nbpdyndnsd " << VERSION << "." << REVISION << "." << RELEASE << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_cmd_parsed() const
{
- if ( 1 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Command line options successfully parsed." << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
void Logger::print_conf_files_parsed() const
{
- if ( 1 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Config files successfully parsed." << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_conf_loaded(const string& config_path) const
{
- if ( 1 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Config files successfully loaded in: " << config_path << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_conf_not_loaded(const string& config_path) const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Config files couldn't be loaded in: " << config_path << endl;
- log_error(msg.str());
+ log_error(msg.str(),level);
}
}
*/
void Logger::print_error_opening_r(const string& filename) const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Error opening file for reading: " << filename << endl;
- log_error(msg.str());
+ log_error(msg.str(),level);
}
}
*/
void Logger::print_error_opening_rw(const string& filename) const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Error opening file for writing: " << filename << endl;
- log_error(msg.str());
+ log_error(msg.str(),level);
}
}
*/
void Logger::print_destructor_call(const string& _class) const
{
- if ( 1 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Destructor call: " << _class << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_constructor_call(const string& _class) const
{
- if ( 1 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Constructor call: " << _class << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_update_service(const string& service) const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Running update for service: " << service << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_unknown_cmd_option(const string& unknown_option) const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Unknown option on command line detected: " << unknown_option << endl;
- log_error(msg.str());
+ log_error(msg.str(),level);
}
}
*/
void Logger::print_unknown_protocol(const string& protocol) const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Unknown protocol defined: " << protocol << endl;
- log_error(msg.str());
+ log_error(msg.str(),level);
}
}
*/
void Logger::print_load_service_conf(const string& filename) const
{
- if ( 1 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Loading service config file: " << filename << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_load_main_conf(const string& filename) const
{
- if ( 1 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Loading main config file: " << filename << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_unknown_service_conf_option(const string& service_conf_file, const string& unknown_option) const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Unknown option in service config file detected: " << service_conf_file << " Unknown option: " << unknown_option << endl;
- log_error(msg.str());
+ log_error(msg.str(),level);
}
}
*/
void Logger::print_unknown_main_conf_option(const string& unknown_option) const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Unknown option in main config file detected: " << unknown_option << endl;
- log_error(msg.str());
+ log_error(msg.str(),level);
}
}
*/
void Logger::print_error_config_path(const string& config_path) const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Config path doesn't exists or is not a diretory: " << config_path << endl;
- log_error(msg.str());
+ log_error(msg.str(),level);
}
}
*/
void Logger::print_missing_cmd_service_option() const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Missing option to initialize service. Protocol, host, login and password must be specified." << endl;
- log_error(msg.str());
+ log_error(msg.str(),level);
}
}
*/
void Logger::print_missing_service_conf_option(const string& service_conf_file) const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Missing option in service config file " << service_conf_file << " to initialize service. Protocol, host, login and password must be specified." << endl;
- log_error(msg.str());
+ log_error(msg.str(),level);
}
}
*/
void Logger::print_runnig_as_daemon(const int pid) const
{
- if ( 1 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Runnig as daemon: " << pid << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_daemon_mode(const bool daemon_mode) const
{
- if ( 1 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
string mode = "disabled";
if (daemon_mode == true)
mode = "enabled";
ostringstream msg;
msg << "Daemon mode is " << mode << "." << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_error_fork() const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Error while trying to fork." << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_pid_found(const int pid) const
{
- if ( 1 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Pidfile found: " << pid << ". Checking if process is still runnig..." << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_process_already_running(const int pid) const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Another bpdyndnsd process with PID " << pid << " is already running!" << endl;
- log_error(msg.str());
+ log_error(msg.str(),level);
}
}
*/
void Logger::print_caught_sigterm() const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Caught SIGTERM. Exiting..." << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_caught_siguser1() const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Caught SIGUSR1. Switching to offline mode..." << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_caught_sighup() const
{
- if ( 0 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Caught SIGHUP. Reloading config and switching to online mode..." << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_error_setting_signal(const string& signal) const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Error while setting signal handler for: " << signal << endl;
- log_error(msg.str());
+ log_error(msg.str(),level);
}
}
*/
void Logger::print_init_log_facility() const
{
- if ( 1 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Initialized logging facility." << " Loglevel: " << Loglevel << " Syslog: " << Syslog << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_offline_mode() const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Offline mode..." << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_serialized_objects_success() const
{
- if ( 1 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Serialized objects successfully." << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_deserialized_objects_success() const
{
- if ( 1 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "De-serialized objects successfully." << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
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 string& actual_ip, list<int>* lastupdated) const
{
- if ( 1 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << message << endl;
{
msg << "\t" << "Lastupdated: " << update_time << endl;
}
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_exception_serialize(const string& exception) const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Error while trying to serialize Serviceholder object: " << exception << endl;
- log_error(msg.str());
+ log_error(msg.str(),level);
}
}
*/
void Logger::print_exception_deserialize(const string& exception) const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Error while trying to de-serialize Serviceholder object: " << exception << endl;
- log_error(msg.str());
+ log_error(msg.str(),level);
}
}
*/
void Logger::print_error_kill_child(const int pid) const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Could not kill child process with PID: " << pid << endl;
- log_error(msg.str());
+ log_error(msg.str(),level);
}
}
*/
void Logger::print_child_killed(const int pid) const
{
- if ( 0 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Killed child process with PID: " << pid << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_no_object_file(const string& object_file) const
{
- if ( 1 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "There is no object file: " << object_file << ". Continue without recovering state from old services!" << endl;
- log_warning(msg.str());
+ log_warning(msg.str(),level);
}
}
*/
void Logger::print_hostname(const string& hostname) const
{
- if ( 1 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Detected following hostname of localhost: " << hostname << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_own_ipv4(const string& ip_addr_v4, const string& hostname) const
{
- if ( 1 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Detected following IPv4-Address of host: " << hostname << " : " << ip_addr_v4 << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_own_ipv6(const string& ip_addr_v6, const string& hostname) const
{
- if ( 1 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Detected following IPv6-Address of host: " << hostname << " : " << ip_addr_v6 << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_error_hostname_to_ip(const string& exception, const string& hostname) const
{
- if ( 1 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Could not resolve the hostname: " << hostname << " to an IP-Address: " << exception << endl;
- log_error(msg.str());
+ log_error(msg.str(),level);
}
}
*/
void Logger::print_update_service_successful(const string& service) const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Updated service successful: " << service << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_webcheck_no_ip() const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "This hosts' IP could not be determined through any configured webcheck url." << endl;
- log_error(msg.str());
+ log_warning(msg.str(),level);
}
}
*/
void Logger::print_webcheck_url_connection_problem(const char * curl_err_buff, const string& url) const
{
- if ( 1 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "There was a problem while trying to connect to following URL: " << url << " CURL error: " << curl_err_buff << endl;
- log_warning(msg.str());
+ log_warning(msg.str(),level);
}
}
*/
void Logger::print_webcheck_error(const char * curl_err_buff, const string& url) const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "There was an error while trying to connect to following URL: " << url << " CURL error: " << curl_err_buff << endl;
- log_error(msg.str());
+ log_error(msg.str(),level);
}
}
*/
void Logger::print_received_curl_data(const string& curl_data) const
{
- if ( 1 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Received CURL data: " << curl_data << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_regex_found_ip(const string& ip) const
{
- if ( 1 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Found IP-Address via regex: " << ip << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_regex_ip_not_found(const string& data) const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Could not extract an IP-Address via regex from following data:\n" << data << endl;
- log_warning(msg.str());
+ log_warning(msg.str(),level);
}
}
*/
void Logger::print_multiple_cmd_option(const string& message) const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "The same option is only allowed once: " << message << endl;
- log_error(msg.str());
+ log_error(msg.str(),level);
}
}
*/
void Logger::print_update_not_allowed(const int current_time, const int old_time, const int MaxUpdatesWithinInterval, const string& service) const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Update not allowed for service: " << service << ". Too many updates within max update interval. Current time: " << current_time << ". Update time before " << MaxUpdatesWithinInterval << " updates: " << old_time << endl;
- log_warning(msg.str());
+ log_warning(msg.str(),level);
}
}
*/
void Logger::print_update_service_failure(const string& service) const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Could not update service: " << service << endl;
- log_warning(msg.str());
+ log_warning(msg.str(),level);
}
}
*/
void Logger::print_starting_shutdown() const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Shutting down ..." << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_shutdown_succeeded() const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Shutting down complete ..." << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_shutdown_parent_succeeded() const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Shutting down parent process completed ..." << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_starting_shutdown_parent() const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Shutting down parent process ..." << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_recheck_dns_entry(const string& hostname, const int lastupdated, const int dns_cache_ttl, const int current_time) const
{
- if ( 1 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "DNS cache record for host <" << hostname << "> expired: Lastupdated: " << lastupdated << " DNS cache ttl: " << dns_cache_ttl << " Current time: " << current_time << " Checking current DNS cache status." << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_cached_dns_entry(const string& hostname, const string& cached_dns_entry, const string& lastupdated_ip) const
{
- if ( 1 <= Loglevel )
+ int level = 1;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Cached DNS record for host <" << hostname << "> : " << cached_dns_entry << " Last updated IP: " << lastupdated_ip << endl;
- log_notice(msg.str());
+ log_notice(msg.str(),level);
}
}
*/
void Logger::print_missing_cmd_proxy_option() const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Missing option to initialize proxy. http_proxy and http_proxy_port must be specified." << endl;
- log_error(msg.str());
+ log_error(msg.str(),level);
}
}
*/
void Logger::print_multiple_service_conf_option(const string& service_conf_file, const string& message) const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Multiple occurrences of the same option in service config file detected: " << service_conf_file << " " << message << endl;
- log_error(msg.str());
+ log_error(msg.str(),level);
}
}
*/
void Logger::print_multiple_main_conf_option(const string& main_conf_file, const string& message) const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
ostringstream msg;
msg << "Multiple occurrences of the same option in main config file detected: " << main_conf_file << " " << message << endl;
- log_error(msg.str());
+ log_error(msg.str(),level);
}
}
*/
void Logger::print_missing_conf_proxy_option(const string& main_conf_filename) const
{
- if ( 0 <= Loglevel )
+ int level = 0;
+ if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
{
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;
- log_error(msg.str());
+ log_error(msg.str(),level);
}
}