Commit | Line | Data |
---|---|---|
254bbf53 BS |
1 | /** @file |
2 | * @brief Logger class header. This class represents the Logging facility. | |
3 | * | |
4 | * | |
5 | * | |
6 | * @copyright Intra2net AG | |
7 | * @license GPLv2 | |
8 | */ | |
9 | ||
10 | #ifndef LOGGER_H | |
11 | #define LOGGER_H | |
12 | ||
88a594e8 | 13 | #include <string> |
2dd2db3e | 14 | #include <list> |
7f3ced8c | 15 | |
88a594e8 BS |
16 | #include <boost/program_options.hpp> |
17 | #include <boost/shared_ptr.hpp> | |
27baf279 | 18 | |
254bbf53 BS |
19 | class Logger |
20 | { | |
88a594e8 | 21 | |
8bca3c5d | 22 | private: |
88a594e8 BS |
23 | |
24 | typedef boost::shared_ptr<boost::program_options::options_description> Options_descriptionPtr; | |
25 | ||
8bca3c5d BS |
26 | int Loglevel; |
27 | bool Syslog; | |
cbbdeb6c BS |
28 | std::string ExternalWarningLog; |
29 | int ExternalWarningLevel; | |
254bbf53 BS |
30 | |
31 | public: | |
32 | ||
88a594e8 BS |
33 | typedef boost::shared_ptr<Logger> Ptr; |
34 | ||
254bbf53 BS |
35 | Logger(); |
36 | ||
37 | ~Logger(); | |
38 | ||
cbbdeb6c | 39 | void log_notice(const std::string& msg, int loglevel) const; |
59c8d63c | 40 | |
cbbdeb6c | 41 | void log_warning(const std::string& msg, int loglevel) const; |
59c8d63c | 42 | |
cbbdeb6c | 43 | void log_error(const std::string& msg, int loglevel) const; |
59c8d63c | 44 | |
e8d4a6f8 | 45 | void set_loglevel(const int _loglevel); |
8bca3c5d | 46 | |
b38684ce | 47 | int get_loglevel() const; |
8bca3c5d | 48 | |
e8d4a6f8 | 49 | void set_syslog(const bool _syslog); |
8bca3c5d | 50 | |
b38684ce | 51 | bool get_syslog() const; |
8bca3c5d | 52 | |
cbbdeb6c | 53 | void set_log_facility(const int _loglevel, const bool _syslog, const std::string& _external_error_log, const int _external_error_level); |
8bca3c5d | 54 | |
e8d4a6f8 | 55 | void print_usage(const Options_descriptionPtr opt_desc) const; |
254bbf53 | 56 | |
b38684ce | 57 | void print_version() const; |
254bbf53 | 58 | |
b38684ce | 59 | void print_cmd_parsed() const; |
254bbf53 | 60 | |
b38684ce | 61 | void print_conf_files_parsed() const; |
667c672c | 62 | |
e8d4a6f8 | 63 | void print_destructor_call(const std::string& _class) const; |
254bbf53 | 64 | |
e8d4a6f8 | 65 | void print_constructor_call(const std::string& _class) const; |
254bbf53 | 66 | |
e8d4a6f8 | 67 | void print_update_service(const std::string& service) const; |
254bbf53 | 68 | |
e8d4a6f8 | 69 | void print_unknown_cmd_option(const std::string& unknown_option) const; |
254bbf53 | 70 | |
e8d4a6f8 | 71 | void print_unknown_protocol(const std::string& protocol) const; |
254bbf53 | 72 | |
e8d4a6f8 | 73 | void print_load_service_conf(const std::string& filename) const; |
254bbf53 | 74 | |
e8d4a6f8 | 75 | void print_load_main_conf(const std::string& filename) const; |
254bbf53 | 76 | |
8a00a649 | 77 | void print_unknown_service_conf_option(const std::string& service_conf_file, const std::string& unknown_option) const; |
254bbf53 | 78 | |
e8d4a6f8 | 79 | void print_unknown_main_conf_option(const std::string& unknown_option) const; |
254bbf53 | 80 | |
e8d4a6f8 | 81 | void print_error_opening_r(const std::string& filename) const; |
667c672c | 82 | |
e8d4a6f8 | 83 | void print_error_opening_rw(const std::string& filename) const; |
254bbf53 | 84 | |
e8d4a6f8 | 85 | void print_error_config_path(const std::string& config_path) const; |
254bbf53 | 86 | |
e8d4a6f8 | 87 | void print_conf_loaded(const std::string& config_path) const; |
254bbf53 | 88 | |
e8d4a6f8 | 89 | void print_conf_not_loaded(const std::string& config_path) const; |
254bbf53 | 90 | |
b38684ce | 91 | void print_missing_cmd_service_option() const; |
388f4ab0 | 92 | |
8a00a649 BS |
93 | void print_missing_service_conf_option(const std::string& service_conf_file) const; |
94 | ||
e8d4a6f8 | 95 | void print_runnig_as_daemon(const int pid) const; |
388f4ab0 | 96 | |
e8d4a6f8 | 97 | void print_daemon_mode(const bool daemon_mode) const; |
388f4ab0 | 98 | |
b38684ce | 99 | void print_error_fork() const; |
388f4ab0 | 100 | |
e8d4a6f8 | 101 | void print_pid_found(const int pid) const; |
388f4ab0 | 102 | |
e8d4a6f8 | 103 | void print_process_already_running(const int pid) const; |
c5675c01 | 104 | |
b38684ce | 105 | void print_caught_sigterm() const; |
c5675c01 | 106 | |
b38684ce | 107 | void print_caught_siguser1() const; |
c5675c01 | 108 | |
b38684ce | 109 | void print_caught_sighup() const; |
8bca3c5d | 110 | |
e8d4a6f8 | 111 | void print_error_setting_signal(const std::string& signal) const; |
8bca3c5d | 112 | |
b38684ce | 113 | void print_init_log_facility() const; |
8bca3c5d | 114 | |
b38684ce | 115 | void print_offline_mode() const; |
27baf279 | 116 | |
b38684ce | 117 | void print_serialized_objects_success() const; |
27baf279 | 118 | |
b38684ce | 119 | void print_deserialized_objects_success() const; |
27baf279 | 120 | |
d5a516ba | 121 | void print_service_object(const std::string& message, const std::string& protocol, const std::string& hostname, const std::string& login, const std::string& password, const int update_interval, const int max_updates_within_interval, const int dns_cache_ttl , const std::string& actual_ip, std::list<int>* lastupdated) const; |
5d38cfe6 | 122 | |
e8d4a6f8 | 123 | void print_exception_serialize(const std::string& exception) const; |
667c672c | 124 | |
e8d4a6f8 | 125 | void print_exception_deserialize(const std::string& exception) const; |
667c672c | 126 | |
e8d4a6f8 | 127 | void print_error_kill_child(const int pid) const; |
667c672c | 128 | |
e8d4a6f8 | 129 | void print_child_killed(const int pid) const; |
584b9407 | 130 | |
e8d4a6f8 | 131 | void print_no_object_file(const std::string& object_file) const; |
0665b239 | 132 | |
e8d4a6f8 | 133 | void print_hostname(const std::string& hostname) const; |
0665b239 | 134 | |
c3dea5dc | 135 | void print_own_ipv4(const std::string& ip_addr_v4, const std::string& hostname) const; |
019dc0d9 | 136 | |
c3dea5dc | 137 | void print_own_ipv6(const std::string& ip_addr_v6, const std::string& hostname) const; |
0665b239 | 138 | |
e8d4a6f8 | 139 | void print_error_hostname_to_ip(const std::string& exception, const std::string& hostname) const; |
68c6b4af | 140 | |
e8d4a6f8 | 141 | void print_update_service_successful(const std::string& service) const; |
1c0908b5 BS |
142 | |
143 | void print_webcheck_no_ip() const; | |
144 | ||
e8d4a6f8 | 145 | void print_webcheck_url_connection_problem(const char * curl_err_buff, const std::string& url) const; |
1c0908b5 | 146 | |
e8d4a6f8 | 147 | void print_webcheck_error(const char * curl_err_buff, const std::string& url) const; |
1c0908b5 | 148 | |
e8d4a6f8 | 149 | void print_received_curl_data(const std::string& curl_data) const; |
1c0908b5 | 150 | |
e8d4a6f8 | 151 | void print_regex_found_ip(const std::string& ip) const; |
1c0908b5 | 152 | |
e8d4a6f8 | 153 | void print_regex_ip_not_found(const std::string& data) const; |
3c0cd271 | 154 | |
e8d4a6f8 | 155 | void print_multiple_cmd_option(const std::string& message) const; |
3c0cd271 | 156 | |
8a00a649 BS |
157 | void print_multiple_service_conf_option(const std::string& service_conf_file, const std::string& message) const; |
158 | ||
159 | void print_multiple_main_conf_option(const std::string& main_conf_file, const std::string& message) const; | |
160 | ||
3c0cd271 BS |
161 | void print_update_not_allowed(const int current_time, const int old_time, const int MaxUpdatesWithinInterval, const std::string& service) const; |
162 | ||
163 | void print_update_service_failure(const std::string& service) const; | |
e304c27b BS |
164 | |
165 | void print_starting_shutdown() const; | |
166 | ||
167 | void print_shutdown_succeeded() const; | |
168 | ||
169 | void print_shutdown_parent_succeeded() const; | |
170 | ||
171 | void print_starting_shutdown_parent() const; | |
0541cd71 BS |
172 | |
173 | void print_recheck_dns_entry(const std::string& hostname, const int lastupdated, const int dns_cache_ttl, const int current_time) const; | |
174 | ||
175 | void print_cached_dns_entry(const std::string& hostname, const std::string& cached_dns_entry, const std::string& lastupdated_ip) const; | |
8a00a649 BS |
176 | |
177 | void print_missing_cmd_proxy_option() const; | |
178 | ||
179 | void print_missing_conf_proxy_option(const std::string& main_conf_filename) const; | |
2dd2db3e BS |
180 | |
181 | void print_no_domain_part(const std::string& hostname) const; | |
d5a516ba BS |
182 | |
183 | void print_curl_error(const std::string& url, const int curl_err_code) const; | |
184 | ||
185 | void print_curl_error(const std::string& url, const int curl_err_code, const char * curl_err_buff) const; | |
186 | ||
187 | void print_curl_data(const std::string& curl_writedata_buff) const; | |
188 | ||
189 | void print_http_not_authorized(const std::string& url, const std::string& username, const std::string& password) const; | |
190 | ||
191 | void print_http_status_code(const std::string& url, const long http_code) const; | |
b6228761 BS |
192 | |
193 | void print_update_failure(const std::string& url, const std::string& curl_data) const; | |
1a00eac6 | 194 | |
b17fd691 BS |
195 | void print_update_failure(const std::string& url, const long http_status_code) const; |
196 | ||
1a00eac6 | 197 | void print_invalid_hostname(const std::string& hostname) const; |
4ef36a12 BS |
198 | |
199 | void print_ip_is_local(const std::string& ip) const; | |
200 | ||
201 | void print_regex_match(const std::string& regex, const std::string& matching_string) const; | |
a78b44b5 BS |
202 | |
203 | void print_no_regex_match(const std::string& regex, const std::string& not_matching_string) const; | |
204 | ||
205 | void print_could_not_parse_received_data(const std::string& curl_data) const; | |
206 | ||
207 | void print_could_not_get_initial_gnudip_data() const; | |
208 | ||
209 | void print_gnudip_requires_servername() const; | |
a2f5be94 BS |
210 | |
211 | void print_exception_md5_sum(const std::string& what) const; | |
254bbf53 BS |
212 | }; |
213 | ||
214 | #endif |