Signal handling changed to be able to go offline, online or online with webcheck ip.
[bpdyndnsd] / src / logger.cpp
1 /** @file
2  * @brief Logger class implementation. This class implements the Logging facility.
3  *
4  *
5  *
6  * @copyright Intra2net AG
7  * @license GPLv2
8 */
9
10
11 #include "logger.h"
12
13 #include <iostream>
14 #include <syslog.h>
15 #include <sstream>
16
17 #include <boost/foreach.hpp>
18
19 #define VERSION     0
20 #define REVISION    1
21 #define RELEASE     0
22
23 namespace po = boost::program_options;
24
25 typedef boost::shared_ptr<boost::program_options::options_description> Options_descriptionPtr;
26
27 using namespace std;
28
29 /**
30  * Default Constructor
31  */
32 Logger::Logger()
33     : Loglevel(0)
34     , Syslog(false)
35     , ExternalWarningLevel(0)
36 {
37     set_log_facility(Loglevel,Syslog,ExternalWarningLog,ExternalWarningLevel);
38 }
39
40
41 /**
42  * Default Destructor
43  */
44 Logger::~Logger()
45 {
46 }
47
48
49 /**
50  * Decides if Logging through syslog if enabled or through std.
51  * @param msg The message to log.
52  */
53 void Logger::log_notice(const string& msg) const
54 {
55     if ( Syslog )
56         syslog(LOG_NOTICE,msg.c_str());
57     else
58         cout << msg << endl;;
59 }
60
61
62 /**
63  * Decides if Logging through syslog if enabled or through std.
64  * @param msg The message to log.
65  */
66 void Logger::log_warning(const string& msg, int level) const
67 {
68     if ( Syslog )
69         syslog(LOG_WARNING,msg.c_str());
70     else
71         cout << msg << endl;
72
73     if ( (level <= ExternalWarningLevel) && (!ExternalWarningLog.empty()) )
74     {
75         string external = ExternalWarningLog;
76         external.append(" ");
77         external.append("\"");
78         external.append(msg);
79         external.append("\"");
80         if ( system(external.c_str()) != 0 )
81             print_error_external_logging(external);
82     }
83 }
84
85
86 /**
87  * Decides if Logging through syslog if enabled or through std.
88  * @param msg The message to log.
89  */
90 void Logger::log_error(const string& msg) const
91 {
92     if ( Syslog )
93         syslog(LOG_ERR,msg.c_str());
94     else
95         cerr << msg << endl;
96 }
97
98
99 /**
100  * Setter for member Loglevel.
101  * @param _loglevel Value to set Loglevel to.
102  */
103 void Logger::set_loglevel(const int _loglevel)
104 {
105     Loglevel = _loglevel;
106     cout << "Loglevel set" << endl;
107 }
108
109
110 /**
111  * Getter for member Loglevel.
112  * @return Loglevel.
113  */
114 int Logger::get_loglevel() const
115 {
116     return Loglevel;
117 }
118
119
120 /**
121  * Setter for member Syslog.
122  * @param _syslog Wether to log through syslog or not.
123  */
124 void Logger::set_syslog(const bool _syslog)
125 {
126     Syslog = _syslog;
127 }
128
129
130 /**
131  * Getter for member Syslog.
132  * @return True if logging through syslog is enabled, false otherwise.
133  */
134 bool Logger::get_syslog() const
135 {
136     return Syslog;
137 }
138
139
140 /**
141  * Initialize the logging facility.
142  */
143 void Logger::set_log_facility(const int _loglevel, const bool _syslog, const string& _external_error_log, const int _external_error_level)
144 {
145     Loglevel = _loglevel;
146     Syslog = _syslog;
147     ExternalWarningLog = _external_error_log;
148     ExternalWarningLevel = _external_error_level;
149
150
151     if ( Syslog )
152         openlog("bpdyndnsd",LOG_PID,LOG_DAEMON);
153 }
154
155
156 /**
157  * Prints out the usage to the command line.
158  */
159 void Logger::print_usage(const Options_descriptionPtr opt_desc) const
160 {
161     int level = 0;
162     if ( level <= Loglevel )
163     {
164         ostringstream msg;
165         msg << "Usage: bpdyndnsd [Command line options]" << "\n" << endl;
166         msg << *opt_desc << endl;
167         log_notice(msg.str());
168     }
169 }
170
171
172 /**
173  * Prints out the programm name and the given version string on stdout.
174  * @param version Version string.
175  */
176 void Logger::print_version() const
177 {
178     int level = 0;
179     if ( level <= Loglevel )
180     {
181         ostringstream msg;
182         msg << "Bullet proof dynamic dns daemon.\nbpdyndnsd " << VERSION << "." << REVISION << "." << RELEASE << endl;
183         log_notice(msg.str());
184     }
185 }
186
187
188 /**
189  * Prints out the successful parsing of the command line options.
190  */
191 void Logger::print_cmd_parsed() const
192 {
193     int level = 1;
194     if ( level <= Loglevel )
195     {
196         log_notice("Command line options successfully parsed.");
197     }
198 }
199
200
201 void Logger::print_conf_files_parsed() const
202 {
203     int level = 1;
204     if ( level <= Loglevel )
205     {
206         log_notice("Config files successfully parsed.");
207     }
208 }
209
210
211 /**
212  * Prints out the successful parsing of the config files.
213  * @param config_path The specified config path.
214  */
215 void Logger::print_conf_loaded(const string& config_path) const
216 {
217     int level = 1;
218     if ( level <= Loglevel )
219     {
220         ostringstream msg;
221         msg << "Config files successfully loaded in: " << config_path << endl;
222         log_notice(msg.str());
223     }
224 }
225
226
227 /**
228  * Prints out the unsuccessful parsing of the config files.
229  * @param config_path The specified config path.
230  */
231 void Logger::print_conf_not_loaded(const string& config_path) const
232 {
233     int level = 0;
234     if ( level <= Loglevel )
235     {
236         ostringstream msg;
237         msg << "Config files couldn't be loaded in: " << config_path << endl;
238         log_error(msg.str());
239     }
240 }
241
242
243 /**
244  * A file could not be opened for reading.
245  * @param filename The filename.
246  */
247 void Logger::print_error_opening_r(const string& filename) const
248 {
249     int level = 0;
250     if ( level <= Loglevel )
251     {
252         ostringstream msg;
253         msg << "Error opening file for reading: " << filename << endl;
254         log_error(msg.str());
255     }
256 }
257
258
259 /**
260  * A file could not be opened for writing.
261  * @param filename The filename.
262  */
263 void Logger::print_error_opening_rw(const string& filename) const
264 {
265     int level = 0;
266     if ( level <= Loglevel )
267     {
268         ostringstream msg;
269         msg << "Error opening file for writing: " << filename << endl;
270         log_error(msg.str());
271     }
272 }
273
274
275 /**
276  * Desctructor of specified class was called.
277  * @param _class Name of the class.
278  */
279 void Logger::print_destructor_call(const string& _class) const
280 {
281     int level = 1;
282     if ( level <= Loglevel )
283     {
284         ostringstream msg;
285         msg << "Destructor call: " << _class << endl;
286         log_notice(msg.str());
287     }
288 }
289
290
291 /**
292  * Constructor of specified class was called.
293  * @param _class Name of the class.
294  */
295 void Logger::print_constructor_call(const string& _class) const
296 {
297     int level = 1;
298     if ( level <= Loglevel )
299     {
300         ostringstream msg;
301         msg << "Constructor call: " << _class << endl;
302         log_notice(msg.str());
303     }
304 }
305
306
307 /**
308  * Update method for specified service was called.
309  * @param service The service for which is the update running.
310  */
311 void Logger::print_update_service(const string& service) const
312 {
313     int level = 0;
314     if ( level <= Loglevel )
315     {
316         ostringstream msg;
317         msg << "Running update for service: " << service << endl;
318         log_notice(msg.str());
319     }
320 }
321
322
323 /**
324  * An unknown option on the command line was detected.
325  * @param unknown_option The unknown option.
326  */
327 void Logger::print_unknown_cmd_option(const string& unknown_option) const
328 {
329     int level = 0;
330     if ( level <= Loglevel )
331     {
332         ostringstream msg;
333         msg << "Unknown option on command line detected: " << unknown_option << endl;
334         log_error(msg.str());
335     }
336 }
337
338
339 /**
340  * An unknown protocol was specified.
341  * @param protocol The unknown protocol.
342  */
343 void Logger::print_unknown_protocol(const string& protocol) const
344 {
345     int level = 0;
346     if ( level <= Loglevel )
347     {
348         ostringstream msg;
349         msg << "Unknown protocol defined: " << protocol << endl;
350         log_error(msg.str());
351     }
352 }
353
354
355 /**
356  * Loading a service config file.
357  * @param filename The service config file.
358  */
359 void Logger::print_load_service_conf(const string& filename) const
360 {
361     int level = 1;
362     if ( level <= Loglevel )
363     {
364         ostringstream msg;
365         msg << "Loading service config file: " << filename << endl;
366         log_notice(msg.str());
367     }
368 }
369
370
371 /**
372  * Loading the main config file.
373  * @param filename The main config file.
374  */
375 void Logger::print_load_main_conf(const string& filename) const
376 {
377     int level = 1;
378     if ( level <= Loglevel )
379     {
380         ostringstream msg;
381         msg << "Loading main config file: " << filename << endl;
382         log_notice(msg.str());
383     }
384 }
385
386
387 /**
388  * There is an unknown option in a service config file.
389  * @param unknown_option The unknown option.
390  */
391 void Logger::print_unknown_service_conf_option(const string& service_conf_file, const string& unknown_option) const
392 {
393     int level = 0;
394     if ( level <= Loglevel )
395     {
396         ostringstream msg;
397         msg << "Unknown option in service config file detected: " << service_conf_file << " Unknown option: " << unknown_option << endl;
398         log_error(msg.str());
399     }
400 }
401
402
403 /**
404  * There is an unknown option in the main config file.
405  * @param unknown_option The unknown option.
406  */
407 void Logger::print_unknown_main_conf_option(const string& unknown_option) const
408 {
409     int level = 0;
410     if ( level <= Loglevel )
411     {
412         ostringstream msg;
413         msg << "Unknown option in main config file detected: " << unknown_option << endl;
414         log_error(msg.str());
415     }
416 }
417
418
419 /**
420  * The defined config path doesn't exist or is not a directory.
421  * @param config_path The defined config path.
422  */
423 void Logger::print_error_config_path(const string& config_path) const
424 {
425     int level = 0;
426     if ( level <= Loglevel )
427     {
428         ostringstream msg;
429         msg << "Config path doesn't exists or is not a diretory: " << config_path << endl;
430         log_error(msg.str());
431     }
432 }
433
434
435 /**
436  * There is a missing command line option to initialize a service object.
437  */
438 void Logger::print_missing_cmd_service_option() const
439 {
440     int level = 0;
441     if ( level <= Loglevel )
442     {
443         log_error("Missing option to initialize service. Protocol, host, login and password must be specified.");
444     }
445 }
446
447
448 /**
449  * Missing option in service config file.
450  * @param service_conf_file Service config file
451  */
452 void Logger::print_missing_service_conf_option(const string& service_conf_file) const
453 {
454     int level = 0;
455     if ( level <= Loglevel )
456     {
457         ostringstream msg;
458         msg << "Missing option in service config file " << service_conf_file << " to initialize service. Protocol, host, login and password must be specified." << endl;
459         log_error(msg.str());
460     }
461 }
462
463
464 /**
465  * Process running as daemon.
466  * @param pid The pid of the daemon.
467  */
468 void Logger::print_runnig_as_daemon(const int pid) const
469 {
470     int level = 1;
471     if ( level <= Loglevel )
472     {
473         ostringstream msg;
474         msg << "Runnig as daemon: " << pid << endl;
475         log_notice(msg.str());
476     }
477 }
478
479
480 /**
481  * Prints out the daemon mode.
482  * @param daemon_mode The daemon mode.
483  */
484 void Logger::print_daemon_mode(const bool daemon_mode) const
485 {
486     int level = 1;
487     if ( level <= Loglevel )
488     {
489         string mode = "disabled";
490         if (daemon_mode == true)
491             mode = "enabled";
492         ostringstream msg;
493         msg << "Daemon mode is " << mode << "." << endl;
494         log_notice(msg.str());
495     }
496 }
497
498
499 /**
500  * There was an error while trying to fork.
501  */
502 void Logger::print_error_fork() const
503 {
504     int level = 0;
505     if ( level <= Loglevel )
506     {
507         log_error("Error while trying to fork.");
508     }
509 }
510
511
512 /**
513  * A pid in the pidfile was found.
514  * @param pid The pid found in the pidfile.
515  */
516 void Logger::print_pid_found(const int pid) const
517 {
518     int level = 1;
519     if ( level <= Loglevel )
520     {
521         ostringstream msg;
522         msg << "Pidfile found: " << pid << ". Checking if process is still runnig..." << endl;
523         log_notice(msg.str());
524     }
525 }
526
527
528 /**
529  * Another process is already running.
530  * @param pid The pid of the other process.
531  */
532 void Logger::print_process_already_running(const int pid) const
533 {
534     int level = 0;
535     if ( level <= Loglevel )
536     {
537         ostringstream msg;
538         msg << "Another bpdyndnsd process with PID " << pid << " is already running!" << endl;
539         log_error(msg.str());
540     }
541 }
542
543
544 /**
545  * SIGTERM caught.
546  */
547 void Logger::print_caught_sigterm() const
548 {
549     int level = 0;
550     if ( level <= Loglevel )
551     {
552         log_notice("Caught SIGTERM. Exiting...");
553     }
554 }
555
556
557 /**
558  * SIGUSR1 caught.
559  */
560 void Logger::print_caught_siguser1() const
561 {
562     int level = 0;
563     if ( level <= Loglevel )
564     {
565         log_notice("Caught SIGUSR1. Switching to offline mode...");
566     }
567 }
568
569
570 /**
571  * SIGHUP caught.
572  */
573 void Logger::print_caught_sighup() const
574 {
575     int level = 1;
576     if ( level <= Loglevel )
577     {
578         log_notice("Caught SIGHUP. Reloading config...");
579     }
580 }
581
582
583 /**
584  * SIGUSR2 caught.
585  */
586 void Logger::print_caught_siguser2() const
587 {
588     int level = 1;
589     if ( level <= Loglevel )
590     {
591         log_notice("Caught SIGUSR2. Switching to online mode...");
592     }
593 }
594
595
596 /**
597  * SIGRTMIN caught.
598  */
599 void Logger::print_caught_sigrtmin() const
600 {
601     int level = 1;
602     if ( level <= Loglevel )
603     {
604         log_notice("Caught SIGRTMIN. Switching to online mode with webcheck enabled...");
605     }
606 }
607
608
609 /**
610  * Error while setting signal handler.
611  */
612 void Logger::print_error_setting_signal(const string& signal) const
613 {
614     int level = 0;
615     if ( level <= Loglevel )
616     {
617         ostringstream msg;
618         msg << "Error while setting signal handler for: " << signal << endl;
619         log_error(msg.str());
620     }
621 }
622
623
624 /**
625  * Error while setting signal handler.
626  */
627 void Logger::print_init_log_facility() const
628 {
629     int level = 1;
630     if ( level <= Loglevel )
631     {
632         ostringstream msg;
633         msg << "Initialized logging facility." << " Loglevel: " << Loglevel << " Syslog: " << Syslog << endl;
634         log_notice(msg.str());
635     }
636 }
637
638
639 /**
640  * Be verbose. Currently we are in offline mode.
641  */
642 void Logger::print_offline_mode() const
643 {
644     int level = 0;
645     if ( level <= Loglevel )
646     {
647         log_notice("Offline mode...");
648     }
649 }
650
651
652 /**
653  * Objects successfully serialized.
654  */
655 void Logger::print_serialized_objects_success() const
656 {
657     int level = 1;
658     if ( level <= Loglevel )
659     {
660         log_notice("Serialized objects successfully.");
661     }
662 }
663
664
665 /**
666  * Objects successfully de-serialized.
667  */
668 void Logger::print_deserialized_objects_success() const
669 {
670     int level = 1;
671     if ( level <= Loglevel )
672     {
673         log_notice("De-serialized objects successfully.");
674     }
675 }
676
677
678 /**
679  * Prints out the content of a service object.
680  * @param message Message to be added on output first.
681  * @param protocol Service's protocol.
682  * @param hostname Service's hostname.
683  * @param login Service's login.
684  * @param password Service's password.
685  * @param actual_ip Service's actual_ip.
686  * @param lastupdated Service's lastupdated.
687  */
688 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<time_t> lastupdated) const
689 {
690     int level = 1;
691     if ( level <= Loglevel )
692     {
693         ostringstream msg;
694         msg << message << endl;
695         msg << "\t" << "Protocol:         " << protocol << endl;
696         msg << "\t" << "Hostname:         " << hostname << endl;
697         msg << "\t" << "Login:            " << login << endl;
698         msg << "\t" << "Password:         " << password << endl;
699         msg << "\t" << "Update Interval:  " << update_interval << endl;
700         msg << "\t" << "Max Updates:      " << max_updates_within_interval << endl;
701         msg << "\t" << "DNS Cache TTL:    " << dns_cache_ttl << endl;
702         msg << "\t" << "Actual_IP:        " << actual_ip << endl;
703         BOOST_FOREACH( time_t update_time, lastupdated)
704         {
705             msg << "\t" << "Lastupdated:      " << update_time << endl;
706         }
707         log_notice(msg.str());
708     }
709 }
710
711
712 /**
713  * Caught exception while serialize.
714  * @param exception Exception message.
715  */
716 void Logger::print_exception_serialize(const string& errMsg) const
717 {
718     int level = 0;
719     if ( level <= Loglevel )
720     {
721         ostringstream msg;
722         msg << "Error while trying to serialize Serviceholder object: " << errMsg << endl;
723         log_error(msg.str());
724     }
725 }
726
727
728 /**
729  * Caught exception while de-serialize.
730  * @param exception Exception message.
731  */
732 void Logger::print_exception_deserialize(const string& errMsg) const
733 {
734     int level = 0;
735     if ( level <= Loglevel )
736     {
737         ostringstream msg;
738         msg << "Error while trying to de-serialize Serviceholder object: " << errMsg << endl;
739         log_error(msg.str());
740     }
741 }
742
743
744 /**
745  * Child couldn't be killed by parent.
746  * @param pid Pid of the child.
747  */
748 void Logger::print_error_kill_child(const int pid) const
749 {
750     int level = 0;
751     if ( level <= Loglevel )
752     {
753         ostringstream msg;
754         msg << "Could not kill child process with PID: " << pid << endl;
755         log_error(msg.str());
756     }
757 }
758
759
760 /**
761  * Child was killed by parent because of error.
762  * @param pid The pid (child) killed.
763  */
764 void Logger::print_child_killed(const int pid) const
765 {
766     int level = 1;
767     if ( level <= Loglevel )
768     {
769         ostringstream msg;
770         msg << "Killed child process with PID: " << pid << endl;
771         log_notice(msg.str());
772     }
773 }
774
775
776 /**
777  * There is no object file.
778  * @param object_file The object file.
779  */
780 void Logger::print_no_object_file(const string& object_file) const
781 {
782     int level = 1;
783     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
784     {
785         ostringstream msg;
786         msg << "There is no object file: " << object_file << ". Continue without recovering state from old services!" << endl;
787         log_warning(msg.str(),level);
788     }
789 }
790
791
792 /**
793  * Prints out the given hostname
794  * @param hostname Hostname as string.
795  */
796 void Logger::print_hostname(const string& hostname) const
797 {
798     int level = 1;
799     if ( level <= Loglevel )
800     {
801         ostringstream msg;
802         msg << "Detected following hostname of localhost: " << hostname << endl;
803         log_notice(msg.str());
804     }
805 }
806
807
808 /**
809  * Prints out the detected own ipv4 address
810  * @param ip_addr String representation of the detected ip.
811  */
812 void Logger::print_own_ipv4(const string& ip_addr_v4, const string& hostname) const
813 {
814     int level = 1;
815     if ( level <= Loglevel )
816     {
817         ostringstream msg;
818         msg << "Detected following IPv4-Address of host: " << hostname << " : " << ip_addr_v4 << endl;
819         log_notice(msg.str());
820     }
821 }
822
823
824 /**
825  * Prints out the detected own ipv5 address
826  * @param ip_addr String representation of the detected ip.
827  */
828 void Logger::print_own_ipv6(const string& ip_addr_v6, const string& hostname) const
829 {
830     int level = 1;
831     if ( level <= Loglevel )
832     {
833         ostringstream msg;
834         msg << "Detected following IPv6-Address of host: " << hostname << " : " << ip_addr_v6 << endl;
835         log_notice(msg.str());
836     }
837 }
838
839
840 /**
841  * Exception while trying to resolve hostname to ip.
842  * @param exception The exception caught.
843  * @param hostname The hostname.
844  */
845 void Logger::print_error_hostname_to_ip(const string& errMsg, const string& hostname) const
846 {
847     int level = 0;
848     if ( level <= Loglevel )
849     {
850         ostringstream msg;
851         msg << "Could not resolve the hostname: " << hostname << " to an IP-Address: " << errMsg << endl;
852         log_warning(msg.str(),level);
853     }
854 }
855
856
857 /**
858  * The update of the given service was successful.
859  * @param service The service.
860  */
861 void Logger::print_update_service_successful(const string& service) const
862 {
863     int level = 0;
864     if ( level <= Loglevel )
865     {
866         ostringstream msg;
867         msg << "Updated service successful: " << service << endl;
868         log_notice(msg.str());
869     }
870 }
871
872
873 /**
874  * No ip could be determined through webcheck
875  */
876 void Logger::print_webcheck_no_ip() const
877 {
878     int level = 0;
879     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
880     {
881         log_warning("IP-Address of this host could not be determined through any configured webcheck url.",level);
882     }
883 }
884
885
886 /**
887  * Connection problem while trying to get ip through webcheck url
888  * @param curl_err_buff Curl error message
889  * @param url the url
890  */
891 void Logger::print_webcheck_url_connection_problem(const char * curl_err_buff, const string& url) const
892 {
893     int level = 1;
894     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
895     {
896         ostringstream msg;
897         msg << "There was a problem while trying to connect to following URL: " << url << " CURL error: " << curl_err_buff << endl;
898         log_warning(msg.str(),level);
899     }
900 }
901
902
903 /**
904  * Prints out curl error.
905  * @param curl_err_buff Curl error message.
906  * @param url URL
907  */
908 void Logger::print_webcheck_error(const char * curl_err_buff, const string& url) const
909 {
910     int level = 0;
911     if ( level <= Loglevel )
912     {
913         ostringstream msg;
914         msg << "There was an error while trying to connect to following URL: " << url << " CURL error: " << curl_err_buff << endl;
915         log_error(msg.str());
916     }
917 }
918
919
920 /**
921  * Prints out the received data through curl.
922  * @param curl_data Data string
923  */
924 void Logger::print_received_curl_data(const string& curl_data) const
925 {
926     int level = 1;
927     if ( level <= Loglevel )
928     {
929         ostringstream msg;
930         msg << "Received CURL data: " << curl_data << endl;
931         log_notice(msg.str());
932     }
933 }
934
935
936 /**
937  * IP was foudn through regex
938  * @param ip The IP found.
939  */
940 void Logger::print_regex_found_ip(const string& ip) const
941 {
942     int level = 1;
943     if ( level <= Loglevel )
944     {
945         ostringstream msg;
946         msg << "Found IP-Address via regex: " << ip << endl;
947         log_notice(msg.str());
948     }
949 }
950
951
952 /**
953  * No IP was found through regex.
954  * @param data The data string which should contain a valid IP.s
955  */
956 void Logger::print_regex_ip_not_found(const string& data) const
957 {
958     int level = 1;
959     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
960     {
961         ostringstream msg;
962         msg << "Could not extract an IP-Address via regex from following data:\n" << data << endl;
963         log_warning(msg.str(),level);
964     }
965 }
966
967
968 /**
969  * Detected multiple occurrences of the same option.
970  * @param message Error message.
971  */
972 void Logger::print_multiple_cmd_option(const string& message) const
973 {
974     int level = 0;
975     if ( level <= Loglevel )
976     {
977         ostringstream msg;
978         msg << "The same option is only allowed once: " << message << endl;
979         log_error(msg.str());
980     }
981 }
982
983
984 /**
985  * An update would exceed the update interval. Prints out a warning message.
986  * @param current_time Current time.
987  * @param old_time Time of update #MaxUpdatesWithinInterval ago.
988  * @param MaxUpdatesWithinInterval Number of allowed updates in one update interval.
989  * @param service The service which exceeds update interval.
990  */
991 void Logger::print_update_not_allowed(const time_t current_time, const time_t old_time, const int MaxUpdatesWithinInterval, const string& service) const
992 {
993     int level = 1;
994     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
995     {
996         ostringstream msg;
997         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;
998         log_warning(msg.str(),level);
999     }
1000 }
1001
1002
1003 /**
1004  * Failure while running update for service.
1005  * @param service Services' name.
1006  */
1007 void Logger::print_update_service_failure(const string& service) const
1008 {
1009     int level = 0;
1010     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
1011     {
1012         ostringstream msg;
1013         msg << "Could not update service: " << service << endl;
1014         log_warning(msg.str(),level);
1015     }
1016 }
1017
1018
1019 /**
1020  * Starting shutdown
1021  */
1022 void Logger::print_starting_shutdown() const
1023 {
1024     int level = 0;
1025     if ( level <= Loglevel )
1026     {
1027         log_notice("Shutting down ...");
1028     }
1029 }
1030
1031
1032 /**
1033  * Shutdown complete
1034  */
1035 void Logger::print_shutdown_succeeded() const
1036 {
1037     int level = 0;
1038     if ( level <= Loglevel )
1039     {
1040         log_notice("Shutting down complete ...");
1041     }
1042 }
1043
1044
1045 /**
1046  * Shutdown parent succeeded
1047  */
1048 void Logger::print_shutdown_parent_succeeded() const
1049 {
1050     int level = 0;
1051     if ( level <= Loglevel )
1052     {
1053         log_notice("Shutting down parent process completed ...");
1054     }
1055 }
1056
1057
1058 /**
1059  * Starting shutdown parent
1060  */
1061 void Logger::print_starting_shutdown_parent() const
1062 {
1063     int level = 0;
1064     if ( level <= Loglevel )
1065     {
1066         log_notice("Shutting down parent process ...");
1067     }
1068 }
1069
1070
1071 /**
1072  * DNS cache record timeout
1073  * @param hostname Hostname
1074  * @param lastupdated Lastupdated
1075  * @param dns_cache_ttl DNS cache TTL
1076  * @param current_time Current time
1077  */
1078 void Logger::print_recheck_dns_entry(const string& hostname, const int lastupdated, const int dns_cache_ttl, const int current_time) const
1079 {
1080     int level = 1;
1081     if ( level <= Loglevel )
1082     {
1083         ostringstream msg;
1084         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;
1085         log_notice(msg.str());
1086     }
1087 }
1088
1089
1090 /**
1091  * Missing proxy option on command line.
1092  */
1093 void Logger::print_missing_cmd_proxy_option() const
1094 {
1095     int level = 0;
1096     if ( level <= Loglevel )
1097     {
1098         log_error("Missing option to initialize proxy. http_proxy and http_proxy_port must be specified.");
1099     }
1100 }
1101
1102
1103 /**
1104  * Multiple option in service config file.
1105  * @param service_conf_file Service config file
1106  * @param message Multiple option text
1107  */
1108 void Logger::print_multiple_service_conf_option(const string& service_conf_file, const string& message) const
1109 {
1110     int level = 0;
1111     if ( level <= Loglevel )
1112     {
1113         ostringstream msg;
1114         msg << "Multiple occurrences of the same option in service config file detected: " << service_conf_file << " " << message << endl;
1115         log_error(msg.str());
1116     }
1117 }
1118
1119
1120 /**
1121  * Multiple option in main config file.
1122  * @param service_conf_file Service config file
1123  * @param message Multiple option text
1124  */
1125 void Logger::print_multiple_main_conf_option(const string& main_conf_file, const string& message) const
1126 {
1127     int level = 0;
1128     if ( level <= Loglevel )
1129     {
1130         ostringstream msg;
1131         msg << "Multiple occurrences of the same option in main config file detected: " << main_conf_file << " " << message << endl;
1132         log_error(msg.str());
1133     }
1134 }
1135
1136
1137 /**
1138  * Missing proxy option in main config file.
1139  * @param main_conf_filename The concerning config file.
1140  */
1141 void Logger::print_missing_conf_proxy_option(const string& main_conf_filename) const
1142 {
1143     int level = 0;
1144     if ( level <= Loglevel )
1145     {
1146         ostringstream msg;
1147         msg << "Missing option to initialize proxy in main config file: " << main_conf_filename << " http_proxy and http_proxy_port must be specified." << endl;
1148         log_error(msg.str());
1149     }
1150 }
1151
1152
1153 /**
1154  * There is no domain part in the given hostname
1155  * @param hostname The hostname with no domain part in it.
1156  */
1157 void Logger::print_no_domain_part(const string& hostname) const
1158 {
1159     int level = 0;
1160     if ( level <= Loglevel )
1161     {
1162         ostringstream msg;
1163         msg << "There is no domain part in the given hostname: " << hostname << endl;
1164         log_notice(msg.str());
1165     }
1166 }
1167
1168
1169 /**
1170  * Service is not initialized properly.
1171  * @param service The service.
1172  */
1173 void Logger::print_service_not_initialized(const std::string& service) const
1174 {
1175     int level = 0;
1176     if ( level <= Loglevel )
1177     {
1178         ostringstream msg;
1179         msg << "Service: " << service << " is not initialized properly." << endl;
1180         log_warning(msg.str(),level);
1181     }
1182 }
1183
1184
1185 /**
1186  * An curl error occured.
1187  * @param msg The error message
1188  * @param curl_err_code The resulting curl error code
1189  */
1190 void Logger::print_curl_error_init(const std::string& err_msg, const CURLcode curl_err_code) const
1191 {
1192     string curl_err = "";
1193
1194     if ( curl_err_code == CURLE_FAILED_INIT )
1195         curl_err = "CURLE_FAILED_INIT";
1196     else
1197         curl_err = "UNKNOWN";
1198
1199     int level = 0;
1200     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
1201     {
1202         ostringstream msg;
1203         msg << "Curl error: " << err_msg << " Curl error code: " << curl_err_code << " " << curl_err << endl; /*lint !e641 */
1204         log_error(msg.str());
1205     }
1206 }
1207
1208
1209 /**
1210  * An curl error occured.
1211  * @param url The url requested by the curl operation
1212  * @param curl_err_code The resulting curl error code
1213  */
1214 void Logger::print_curl_error(const string& url, const CURLcode curl_err_code) const
1215 {
1216     string curl_err = "";
1217
1218     if ( curl_err_code == CURLE_URL_MALFORMAT )
1219         curl_err = "CURLE_URL_MALFORMAT";
1220     else if ( curl_err_code == CURLE_COULDNT_RESOLVE_HOST )
1221         curl_err = "CURLE_COULDNT_RESOLVE_HOST";
1222     else if ( curl_err_code == CURLE_COULDNT_CONNECT )
1223         curl_err = "CURLE_COULDNT_CONNECT";
1224     else
1225         curl_err = "UNKNOWN";
1226
1227     int level = 0;
1228     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
1229     {
1230         ostringstream msg;
1231         msg << "Curl error while requesting following url: " << url << " Curl error code: " << curl_err_code << " " << curl_err << endl; /*lint !e641 */
1232         log_warning(msg.str(),level);
1233     }
1234 }
1235
1236
1237 /**
1238  * An curl error occured.
1239  * @param url The url requested by the curl operation
1240  * @param curl_err_code The resulting curl error code
1241  * @param curl_err_buff The curl error buffer
1242  */
1243 void Logger::print_curl_error(const string& url, const CURLcode curl_err_code, const char * curl_err_buff) const
1244 {
1245     string curl_err = "";
1246
1247     if ( curl_err_code == CURLE_URL_MALFORMAT )
1248         curl_err = "CURLE_URL_MALFORMAT";
1249     else if ( curl_err_code == CURLE_COULDNT_RESOLVE_HOST )
1250         curl_err = "CURLE_COULDNT_RESOLVE_HOST";
1251     else if ( curl_err_code == CURLE_COULDNT_CONNECT )
1252         curl_err = "CURLE_COULDNT_CONNECT";
1253     else
1254         curl_err = "UNKNOWN";
1255
1256     int level = 0;
1257     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
1258     {
1259         ostringstream msg;
1260         msg << "Curl error while requesting following url: " << url << " Curl error code: " << curl_err_code << " " << curl_err << " " << curl_err_buff << endl; /*lint !e641 */
1261         log_warning(msg.str(),level);
1262     }
1263 }
1264
1265
1266 /**
1267  * Prints out the data received by curl operation
1268  * @param CurlWritedataBuff 
1269  */
1270 void Logger::print_curl_data(const string& curl_writedata_buff) const
1271 {
1272     int level = 1;
1273     if ( level <= Loglevel )
1274     {
1275         ostringstream msg;
1276         msg << "Data received by curl: " << curl_writedata_buff << endl;
1277         log_notice(msg.str());
1278     }
1279 }
1280
1281
1282 /**
1283  * Not authorized to perform requested update operation
1284  * @param service The requested service.
1285  * @param username Username
1286  * @param password Password
1287  */
1288 void Logger::print_service_not_authorized(const string& service, const string& username, const string& password) const
1289 {
1290     int level = 0;
1291     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
1292     {
1293         ostringstream msg;
1294         msg << "Not authorized to perform update operation on service: " << service << " Please check username and password: " << username << ":" << password << endl;
1295         log_warning(msg.str(),level);
1296     }
1297 }
1298
1299
1300 /**
1301  * Prints out the http status code
1302  * @param url Url
1303  * @param output HTTP status code
1304  */
1305 void Logger::print_http_status_code(const string& url, const long http_code) const
1306 {
1307     int level = 1;
1308     if ( level <= Loglevel )
1309     {
1310         ostringstream msg;
1311         msg << "Requested URL: " << url << " Received HTTP status code: " << http_code << endl;
1312         log_notice(msg.str());
1313     }
1314 }
1315
1316
1317 /**
1318  * Generic failure while trying to update service
1319  * @param url The requested URL
1320  * @param curl_data The received curl_data from the server
1321  */
1322 void Logger::print_update_failure(const string& url, const string& curl_data) const
1323 {
1324     int level = 0;
1325     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
1326     {
1327         ostringstream msg;
1328         msg << "Problem while trying to updating service. Requested URL: " << url << " Error Code from Server: " << curl_data << endl;
1329         log_warning(msg.str(),level);
1330     }
1331 }
1332
1333
1334 /**
1335  * Generic failure while trying to update service
1336  * @param url The requested URL
1337  * @param http_status_code The received http status code
1338  */
1339 void Logger::print_update_failure(const string& url, const long http_status_code) const
1340 {
1341     int level = 0;
1342     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
1343     {
1344         ostringstream msg;
1345         msg << "Problem while trying to updating service. Requested URL: " << url << " Error Code from Server: " << http_status_code << endl;
1346         log_warning(msg.str(),level);
1347     }
1348 }
1349
1350 /**
1351  * Hostname is invalid, contains no or only one domain part.
1352  * @param hostname The full qualified host name. 
1353  */
1354 void Logger::print_invalid_hostname(const string& hostname) const
1355 {
1356     int level = 0;
1357     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
1358     {
1359         ostringstream msg;
1360         msg << "The configured hostname: " << hostname << " is invalid. Please add the corresponding domain part." << endl;
1361         log_warning(msg.str(),level);
1362     }
1363 }
1364
1365
1366 /**
1367  * An IP in a private range was detected
1368  * @param ip The private IP
1369  */
1370 void Logger::print_ip_is_local(const string& ip) const
1371 {
1372     int level = 0;
1373     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
1374     {
1375         ostringstream msg;
1376         msg << "The detected IP is within a private IP range: " << ip << endl;
1377         log_warning(msg.str(),level);
1378     }
1379 }
1380
1381
1382 /**
1383  * Regex is matching in string
1384  * @param regex The regex pattern
1385  * @param matching_string The string
1386  */
1387 void Logger::print_regex_match(const string& regex, const string& matching_string) const
1388 {
1389     int level = 1;
1390     if ( level <= Loglevel )
1391     {
1392         ostringstream msg;
1393         msg << "Regex: " << regex << " is matching in: " << matching_string << endl;
1394         log_notice(msg.str());
1395     }
1396 }
1397
1398
1399 /**
1400  * Regex is not matching
1401  * @param regex Regex
1402  * @param not_matching_string String
1403  */
1404 void Logger::print_no_regex_match(const string& regex, const string& not_matching_string) const
1405 {
1406     int level = 1;
1407     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
1408     {
1409         ostringstream msg;
1410         msg << "Regex: " << regex << " is not matching in: " << not_matching_string << endl;
1411         log_warning(msg.str(),level);
1412     }
1413 }
1414
1415
1416 /**
1417  * Could not parse gnudip initial reply.
1418  * @param curl_data The data received from gnudip server which should contain salt, time and sign.
1419  */
1420 void Logger::print_could_not_parse_received_data(const string& curl_data) const
1421 {
1422     int level = 0;
1423     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
1424     {
1425         ostringstream msg;
1426         msg << "Could not parse salt, time and sign from initial gnudip server reply: " << curl_data << endl;
1427         log_warning(msg.str(),level);
1428     }
1429 }
1430
1431
1432 /**
1433  * Gnudip salt, time and sign could not be got from map
1434  */
1435 void Logger::print_could_not_get_initial_gnudip_data() const
1436 {
1437     int level = 0;
1438     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
1439     {
1440         log_warning("Could not get salt, time and sign from map.",level);
1441     }
1442 }
1443
1444
1445
1446 /**
1447  * Gnudip protocol requires explicit declaration of a servername.
1448  */
1449 void Logger::print_gnudip_requires_servername() const
1450 {
1451     int level = 0;
1452     if ( (level <= Loglevel) || ((level <= ExternalWarningLevel) && (!ExternalWarningLog.empty())) )
1453     {
1454         log_warning("Gnudip requires explicit definition of servername via config!",level);
1455     }
1456 }
1457
1458
1459 /**
1460  * An exception occured while computing the md5 sum.
1461  * @param what The exception occured.
1462  */
1463 void Logger::print_exception_md5_sum(const string& what) const
1464 {
1465     int level = 0;
1466     if ( level <= Loglevel )
1467     {
1468         ostringstream msg;
1469         msg << "An exception occured while computing a md5 sum: " << what << endl;
1470         log_error(msg.str());
1471     }
1472 }
1473
1474
1475 /**
1476  * An network exception occured.
1477  * @param what The exception occured.
1478  */
1479 void Logger::print_network_error(const string& what) const
1480 {
1481     int level = 0;
1482     if ( level <= Loglevel )
1483     {
1484         ostringstream msg;
1485         msg << "An netowrk exception occured: " << what << endl;
1486         log_error(msg.str());
1487     }
1488 }
1489
1490
1491 /**
1492  * An undefined protocol error occured.
1493  * @param protocol The protocol
1494  * @param error The error
1495  */
1496 void Logger::print_undefined_protocol_error(const string& protocol, const string& error) const
1497 {
1498     int level = 0;
1499     if ( level <= Loglevel )
1500     {
1501         ostringstream msg;
1502         msg << "An undefined protocol error occured. Protocol: " << protocol << " Error: " << error << endl;
1503         log_error(msg.str());
1504     }
1505 }
1506
1507 /**
1508  * Error while trying to log through external program.
1509  * @param external_prog The external program called.
1510  */
1511 void Logger::print_error_external_logging(const string& external_prog) const
1512 {
1513     int level = 0;
1514     if ( level <= Loglevel )
1515     {
1516         ostringstream msg;
1517         msg << "Error while trying to log through external program: " << external_prog << endl;
1518         log_notice(msg.str());
1519     }
1520 }
1521
1522
1523 /**
1524  * Error while parsing config file.
1525  * @param error Error occured.
1526  * @param config_file Config file.
1527  */
1528 void Logger::print_error_parsing_config_file(const string& filename, const string& error) const
1529 {
1530     int level = 0;
1531     if ( level <= Loglevel )
1532     {
1533         ostringstream msg;
1534         msg << "Error while parsing config file: " << filename << " Error: " << error << endl;
1535         log_notice(msg.str());
1536     }
1537 }
1538
1539
1540 /**
1541  * Error while parsing cmd option
1542  * @param error Error
1543  */
1544 void Logger::print_error_parsing_cmd(const string& error) const
1545 {
1546     int level = 0;
1547     if ( level <= Loglevel )
1548     {
1549         ostringstream msg;
1550         msg << "Error while parsing cmd options: " << error << endl;
1551         log_error(msg.str());
1552     }
1553 }
1554
1555
1556 /**
1557  * The webcheck interval was exceeded, so webcheck not allowed.
1558  * @param last_webcheck Time of last webcheck.
1559  * @param webcheck_interval Webcheck interval time.
1560  * @param current_time Current system time.
1561  */
1562 void Logger::print_webcheck_exceed_interval( const time_t last_webcheck, const int webcheck_interval, const time_t current_time ) const
1563 {
1564     int level = 0;
1565     if ( level <= Loglevel )
1566     {
1567         ostringstream msg;
1568         msg << "Exceeding webcheck interval: LastWebcheck " << last_webcheck << " + WebcheckInterval(sec) " << webcheck_interval << " >= CurrentTime " << current_time << endl;
1569         log_notice(msg.str());
1570     }
1571 }
1572
1573
1574 /**
1575  * Checking if hosts needs update.
1576  * @param hostname Hostname
1577  * @param current_time Current time
1578  * @param lastupdated Last updated
1579  */
1580 void Logger::print_check_service_update(const string& hostname, const time_t current_time, const time_t lastupdated) const
1581 {
1582     int level = 1;
1583     if ( level <= Loglevel )
1584     {
1585         ostringstream msg;
1586         msg << "Checking if host: " << hostname << " needs update. Current time: " << current_time << " Last updated: " << lastupdated << endl;
1587         log_notice(msg.str());
1588     }
1589 }
1590
1591
1592 /**
1593  * Cached DNS entry
1594  * @param hostname Hostname
1595  * @param ip_dns_recheck DNS recheck IP
1596  * @param ip_last_update IP set in last update
1597  * @param ip_host Hosts' IP
1598  */
1599 void Logger::print_cached_dns_entry(const string& hostname, const string& ip_dns_recheck, const string& ip_last_update, const string& ip_host) const
1600 {
1601     int level = 1;
1602     if ( level <= Loglevel )
1603     {
1604         ostringstream msg;
1605         msg << "Cached DNS record for host <" << hostname << "> : " << ip_dns_recheck << " Last updated IP: " << ip_last_update << " Hosts IP: " << ip_host << endl;
1606         log_notice(msg.str());
1607     }
1608 }
1609
1610
1611 /**
1612  * Updating service for the first time.
1613  * @param hostname Hostname
1614  * @param ip_dns_recheck Cached DNS entry
1615  * @param ip_host Hosts IP
1616  */
1617 void Logger::print_update_service_firttime(const string& hostname, const string& ip_dns_recheck, const string& ip_host) const
1618 {
1619     int level = 1;
1620     if ( level <= Loglevel )
1621     {
1622         ostringstream msg;
1623         msg << "Updating service for the first time. Hostname: " << hostname << " DNS-Record: " << ip_dns_recheck << " Hosts IP: " << ip_host << endl;
1624         log_notice(msg.str());
1625     }
1626 }
1627
1628
1629 /**
1630  * Updating service
1631  * @param hostname Hostname
1632  * @param ip_dns_recheck Cached DNS entry
1633  * @param ip_last_update IP set in last update
1634  * @param ip_host Hosts IP
1635  * @param lastupdated Lastupdated
1636  */
1637 void Logger::print_update_service(const string& hostname, const string& ip_dns_recheck, const string& ip_last_update, const string& ip_host, const time_t lastupdated) const{
1638     int level = 1;
1639     if ( level <= Loglevel )
1640     {
1641         ostringstream msg;
1642         msg << "Updating service. Hostname: " << hostname << " DNS-Record: " << ip_dns_recheck << " IP set in last update: " << ip_last_update << " Lastupdated: " << lastupdated << " Hosts IP: " << ip_host << endl;
1643         log_notice(msg.str());
1644     }
1645 }
1646
1647
1648 /**
1649  * TTL expired
1650  * @param hostname Hostname
1651  * @param ip_dns_recheck Cached DNS entry
1652  * @param ip_last_update IP set in last update
1653  * @param ip_host Hosts IP
1654  * @param lastupdated Last updated
1655  * @param dns_cache_ttl DNS cache ttl
1656  * @param current_time Current time
1657  */
1658 void Logger::print_update_service_ttl_expired(const string& hostname, const string& ip_dns_recheck, const string& ip_last_update, const string& ip_host, const time_t lastupdated, const int dns_cache_ttl, const time_t current_time) const
1659 {
1660     int level = 1;
1661     if ( level <= Loglevel )
1662     {
1663         ostringstream msg;
1664         msg << "TTL for service expired and still pointing to old IP. Hostname: " << hostname << " DNS-Record: " << ip_dns_recheck << " IP set in last update: " << ip_last_update << " Lastupdated: " << lastupdated << "DNS Cache TTL: " << dns_cache_ttl << " Current Time: " << current_time << " Hosts IP: " << ip_host << endl;
1665         log_notice(msg.str());
1666     }
1667 }
1668
1669
1670 /**
1671  * TTL expired
1672  * @param hostname Hostname
1673  * @param ip_dns_recheck Cached DNS entry
1674  * @param ip_last_update IP set in last update
1675  * @param ip_host Hosts IP
1676  * @param lastupdated Last updated
1677  * @param dns_cache_ttl DNS cache ttl
1678  * @param current_time Current time
1679  */
1680 void Logger::print_update_service_ttl_not_expired(const string& hostname, const string& ip_dns_recheck, const string& ip_last_update, const string& ip_host, const time_t lastupdated, const int dns_cache_ttl, const time_t current_time) const
1681 {
1682     int level = 1;
1683     if ( level <= Loglevel )
1684     {
1685         ostringstream msg;
1686         msg << "Waiting for DNS cache TTL to expire. Hostname: " << hostname << " DNS-Record: " << ip_dns_recheck << " IP set in last update: " << ip_last_update << " Lastupdated: " << lastupdated << "DNS Cache TTL: " << dns_cache_ttl << " Current Time: " << current_time << " Hosts IP: " << ip_host << endl;
1687         log_notice(msg.str());
1688     }
1689 }
1690
1691
1692 /**
1693  * No update needed
1694  * @param hostname Hostname
1695  * @param ip_dns_recheck Cached DNS entry
1696  * @param ip_last_update IP set in last update
1697  * @param ip_host Hosts IP
1698  * @param lastupdated Last updated
1699  */
1700 void Logger::print_no_update_needed(const string& hostname, const string& ip_dns_recheck, const string& ip_last_update, const string& ip_host, const time_t lastupdated) const
1701 {
1702     int level = 1;
1703     if ( level <= Loglevel )
1704     {
1705         ostringstream msg;
1706         msg << "No update needed for host: " << hostname << " Cached DNS record: " << ip_dns_recheck << " IP set in last update: " << ip_last_update << " Hosts IP: " << ip_host << " Last updated: " << lastupdated << endl;
1707         log_notice(msg.str());
1708     }
1709 }
1710
1711
1712 /**
1713  * Error while trying to get local wan interface IP address through getifaddrs.
1714  * @param error The system call which raised the error.
1715  * @param error The error set by getifaddrs.
1716  */
1717 void Logger::print_error_getting_local_wan_ip(const std::string& system_call, const std::string& error) const
1718 {
1719     int level = 0;
1720     if ( level <= Loglevel )
1721     {
1722         ostringstream msg;
1723         msg << "Error while trying to get local wan interface IP address through '" << system_call << "': " << error << endl;
1724         log_error(msg.str());
1725     }
1726 }
1727
1728
1729 /**
1730  * Could not get IP address of local wan interface.
1731  */
1732 void Logger::print_no_wan_ip() const
1733 {
1734     int level = 0;
1735     if ( level <= Loglevel )
1736     {
1737         ostringstream msg;
1738         msg << "Could not get IP address of local wan interface." << endl;
1739         log_error(msg.str());
1740     }
1741 }