Implementation of log.h. More...
#include "config.h"#include "util/log.h"#include "util/locks.h"#include <time.h>#include <syslog.h>Functions | |
| void | log_init (const char *filename, int use_syslog, const char *chrootdir) |
| call this to initialize logging services. | |
| void | log_file (FILE *f) |
| Set logging to go to the specified file *. | |
| void | log_thread_set (int *num) |
| Init a thread (will print this number for the thread log entries). | |
| void | log_ident_set (const char *id) |
| Set identity to print, default is 'unbound'. | |
| void | log_set_time (uint32_t *t) |
| Set the time value to print in log entries. | |
| void | log_set_time_asc (int use_asc) |
| Set if the time value is printed ascii or decimal in log entries. | |
| void | log_vmsg (int pri, const char *type, const char *format, va_list args) |
| va_list argument version of log_info. | |
| void | log_info (const char *format,...) |
| implementation of log_info | |
| void | log_err (const char *format,...) |
| implementation of log_err | |
| void | log_warn (const char *format,...) |
| implementation of log_warn | |
| void | fatal_exit (const char *format,...) |
| implementation of fatal_exit | |
| void | verbose (enum verbosity_value level, const char *format,...) |
| implementation of verbose | |
| static void | log_hex_f (enum verbosity_value v, const char *msg, void *data, size_t length) |
| log hex data | |
| void | log_hex (const char *msg, void *data, size_t length) |
| Log a hex-string to the log. | |
| void | log_buf (enum verbosity_value level, const char *msg, ldns_buffer *buf) |
| Easy alternative for log_hex, takes a ldns_buffer. | |
Variables | |
| enum verbosity_value | verbosity = 0 |
| The global verbosity setting. | |
| static FILE * | logfile = 0 |
| the file logged to. | |
| static int | key_created = 0 |
| if key has been created | |
| static ub_thread_key_t | logkey |
| pthread key for thread ids in logfile | |
| static const char * | ident = "unbound" |
| the identity of this executable/process | |
| static int | logging_to_syslog = 0 |
| are we using syslog(3) to log to | |
| static uint32_t * | log_now = NULL |
| time to print in log, if NULL, use time(2) | |
| static int | log_time_asc = 0 |
| print time in UTC or in secondsfrom1970 | |
Implementation of log.h.
| void log_init | ( | const char * | filename, |
| int | use_syslog, | ||
| const char * | chrootdir | ||
| ) |
call this to initialize logging services.
| filename,: | if NULL stderr is used. |
| use_syslog,: | set to true to ignore filename and use syslog(3). |
| chrootdir,: | to which directory we have been chrooted, if any. |
References key_created, logkey, logfile, logging_to_syslog, verbose(), VERB_QUERY, ident, and log_err().
Referenced by do_log_reopen(), perform_setup(), run_daemon(), main(), context_finalize(), ub_ctx_create(), service_init(), and service_start().
| void log_file | ( | FILE * | f | ) |
Set logging to go to the specified file *.
This setting does not affect the use_syslog setting.
| f,: | to that file, or pass NULL to disable logging. |
References logfile.
Referenced by context_finalize(), and ub_ctx_debugout().
| void log_thread_set | ( | int * | num | ) |
Init a thread (will print this number for the thread log entries).
Must be called from the thread itself. If not called 0 is printed.
| num,: | number to print for this thread. Owned by caller, must continue to exist. |
References logkey.
Referenced by thread_start(), daemon_cleanup(), libworker_dobg(), ext_thread(), test_thr_main(), and win_do_cron().
| void log_ident_set | ( | const char * | id | ) |
Set identity to print, default is 'unbound'.
| id,: | string to print. Name of executable. |
References ident.
Referenced by ub_ctx_create(), and main().
| void log_set_time | ( | uint32_t * | t | ) |
Set the time value to print in log entries.
| t,: | the point is copied and used to find the time. if NULL, time(2) is used. |
References log_now.
Referenced by worker_init(), and worker_delete().
| void log_set_time_asc | ( | int | use_asc | ) |
Set if the time value is printed ascii or decimal in log entries.
| use_asc,: | if true, ascii is printed, otherwise decimal. If the conversion fails or you have no time functions, decimal is printed. |
References log_time_asc.
Referenced by config_apply().
| void log_vmsg | ( | int | pri, |
| const char * | type, | ||
| const char * | format, | ||
| va_list | args | ||
| ) |
va_list argument version of log_info.
| pri,: | priority type, for example 5 (INFO). |
| type,: | string to designate type of message (info, error). |
| format,: | the printf style format to print. no newline. |
| args,: | arguments for format string. |
References logkey, logging_to_syslog, MSG_GENERIC_ERR, MSG_GENERIC_INFO, MSG_GENERIC_WARN, MSG_GENERIC_SUCCESS, ident, SERVICE_NAME, logfile, log_now, and log_time_asc.
Referenced by log_info(), log_err(), log_warn(), fatal_exit(), and verbose().
| void log_info | ( | const char * | format, |
| ... | |||
| ) |
implementation of log_info
| format,: | format string printf-style. |
References log_vmsg().
Referenced by daemon_fork(), server_stats_log(), worker_mem_report(), worker_handle_control_cmd(), delegpt_log(), invalidateQueryInCache(), local_zones_print(), mesh_stats(), log_pkt(), pending_find_match(), pending_matches_range(), answer_check_it(), fake_front_query(), moment_assign(), time_passes(), autotrust_check(), do_infra_rtt(), do_moment_and_advance(), run_scenario(), comm_point_send_reply(), comm_point_drop_reply(), pending_udp_query(), pending_tcp_query(), outnet_serviced_query(), outnet_serviced_query_stop(), comm_timer_disable(), comm_timer_set(), replay_scenario_read(), macro_print_debug(), setup_playback(), main(), testlookup(), testlookup_unlim(), test_long_table(), test_buffers(), alloc_stats(), log_dns_msg(), log_nametypeclass(), comm_point_tcp_accept_callback(), regional_log_stats(), lruhash_status(), slabhash_status(), timehist_log(), autr_debug_print_ta(), autr_debug_print_tp(), sigdate_error(), processFinished(), and waitforubanchor().
| void log_err | ( | const char * | format, |
| ... | |||
| ) |
implementation of log_err
| format,: | format string printf-style. |
References log_vmsg().
Referenced by acl_list_str_cfg(), record_sigh(), signal_handling_record(), daemon_init(), daemon_delete(), daemon_remote_create(), add_open(), accept_open(), daemon_remote_open_accept(), remote_accept_callback(), ssl_read_line(), print_hist(), daemon_remote_exec(), remote_control_callback(), checkrlimits(), readpid(), writepid(), perform_setup(), worker_send_cmd(), worker_handle_control_cmd(), answer_chaos(), worker_sighandler(), worker_create(), worker_init(), donotq_str_cfg(), forwards_insert_data(), read_fwds_name(), read_fwds_host(), read_fwds_addr(), read_forwards(), make_stub_holes(), ah(), hints_insert(), read_stubs_name(), read_stubs_host(), read_stubs_addr(), read_stubs(), read_root_hints(), read_addrs(), read_names(), scrub_normalize(), read_fetch_policy(), iter_apply_cfg(), dns_alloc_msg(), iter_store_parentside_rrset(), iter_store_parentside_neg(), iter_lookup_parent_glue_from_cache(), iter_init(), next_state(), error_supers(), error_response_cache(), generate_sub_request(), prime_root(), prime_stub(), generate_ns_check(), processInitRequest(), processLastResort(), processQueryResponse(), prime_supers(), processTargetResponse(), processClassResponse(), processFinished(), process_response(), iter_operate(), ub_ctx_create(), process_answer_detail(), libworker_do_cmd(), libworker_dobg(), libworker_enter_result(), add_bg_result(), handle_newq(), pythonmod_init(), pythonmod_deinit(), pythonmod_inform_super(), pythonmod_operate(), createResponse(), dns_cache_store_msg(), dns_cache_find_delegation(), infra_set_lame(), create_udp_sock(), create_tcp_accept_sock(), make_sock(), make_sock_port(), set_recvpktinfo(), listen_create(), parse_dname(), lz_enter_zone_dname(), lz_enter_zone(), get_rr_content(), get_rr_nameclass(), new_local_rrset(), insert_rr(), lz_find_create_node(), lz_enter_rr_into_zone(), lz_enter_rr_str(), lz_exists(), lz_enter_defaults(), lz_setup_implicit(), local_zones_add_zone(), mesh_create(), mesh_new_client(), mesh_new_prefetch(), mesh_attach_sub(), mesh_state_attachment(), mesh_continue(), modstack_config(), modstack_setup(), pick_outgoing_tcp(), outnet_tcp_take_into_use(), outside_network_create(), select_id(), select_ifport(), serviced_callbacks(), serviced_tcp_callback(), serviced_tcp_initiate(), serviced_udp_callback(), contact_server(), service_send(), do_proxy(), service_tcp_listen(), tcp_relay_read(), tcp_relay_write(), service(), fill_buffer_with_reply(), autotrust_check(), do_moment_and_advance(), run_scenario(), comm_point_send_reply(), pending_udp_query(), pending_tcp_query(), outnet_serviced_query(), check_order_lock(), perfsend(), perfreply(), perfselect(), replay_range_read(), replay_moment_read(), make_scenario(), do_macro_variable(), do_macro_ctime(), do_macro_arith(), do_macro_range(), check_zone_invariants(), entry_to_buf(), prealloc(), prealloc_blocks(), alloc_special_obtain(), config_read(), cfg_mark_ports(), cfg_parse_memsize(), cfg_parse_local_zone(), cfg_ptr_reverse(), errinf(), errinf_to_str(), errinf_rrset(), dname_pkt_copy(), reply_info_answer_encode(), log_init(), fd_set_nonblock(), fd_set_block(), netblockstrtoaddr(), sock_list_insert(), log_crypto_err(), listen_sslctx_create(), connect_sslctx_create(), comm_base_exit(), comm_point_send_udp_msg(), comm_point_send_udp_msg_if(), comm_point_udp_ancil_callback(), comm_point_udp_callback(), comm_point_perform_accept(), ssl_handshake(), ssl_handle_read(), ssl_handle_write(), comm_point_tcp_handle_read(), comm_point_tcp_handle_write(), comm_point_tcp_handle_callback(), comm_point_local_handle_callback(), comm_point_create_udp(), comm_point_create_udp_ancil(), comm_point_create_tcp_handler(), comm_point_create_tcp(), comm_point_create_tcp_out(), comm_point_create_local(), comm_point_create_raw(), comm_point_close(), comm_point_stop_listening(), comm_point_start_listening(), comm_point_listen_for_rw(), comm_timer_create(), comm_timer_set(), comm_signal_create(), comm_signal_bind(), ub_systemseed(), ub_arc4random_stir(), ub_initstate(), table_grow(), tube_create(), tube_handle_listen(), tube_handle_write(), tube_write_msg(), tube_read_msg(), tube_setup_bg_listen(), tube_setup_bg_write(), tube_queue_item(), parse_comments(), autr_tp_create(), find_add_tp(), add_trustanchor_frm_str(), load_trustanchor(), parse_var_line(), read_multiline(), autr_read_file(), print_id(), autr_write_file(), check_contains_revoked(), autr_process_prime(), probe_anchor(), anchor_store_new_key(), anchor_store_new_rr(), anchor_insert_insecure(), anchor_store_str(), anchor_read_file(), skip_to_special(), process_bind_contents(), anchor_read_bind_file(), anchor_read_bind_file_wild(), anchors_assemble_rrsets(), anchors_apply_cfg(), key_cache_create(), val_neg_create(), neg_insert_data(), val_neg_addreply(), val_neg_addreferral(), nsec3_get_hashed(), nsec3_calc_hash(), nsec3_calc_b32(), find_matching_nsec3(), find_covering_nsec3(), nsec3_ce_wildcard(), rrset_canonical(), log_crypto_error(), setup_key_digest(), dnskey_verify_rrset_sig(), fill_nsec3_iter(), val_apply_cfg(), val_init(), generate_request(), prime_trust_anchor(), validate_any_response(), processFindKey(), processValidate(), val_dlv_init(), processDLVLookup(), val_operate(), primeResponseToKE(), process_ds_response(), process_dnskey_response(), process_dlv_response(), val_inform_super(), hdlr(), waitforubanchor(), call_root_update(), service_init(), service_main(), waitforit(), and win_do_cron().
| void log_warn | ( | const char * | format, |
| ... | |||
| ) |
implementation of log_warn
| format,: | format string printf-style. |
References log_vmsg().
Referenced by load_rr(), move_into_cache(), load_rrset(), load_qinfo(), load_ref(), load_msg(), remote_accept_callback(), checkrlimits(), checkoldpid(), perform_setup(), run_daemon(), delegpt_add_rrset(), read_root_hints(), processQueryResponse(), iter_handle(), rrset_array_unlock_touch(), create_udp_sock(), ports_create_if(), lz_enter_zone_dname(), outnet_udp_cb(), go(), main(), ring_add(), alloc_get_id(), comm_point_tcp_accept_callback(), handle_origin(), autr_read_file(), check_holddown(), anchors_assemble_rrsets(), val_handle(), ds_response_to_ke(), and service_init().
| void fatal_exit | ( | const char * | format, |
| ... | |||
| ) |
implementation of fatal_exit
| format,: | format string printf-style. |
References log_vmsg().
Referenced by daemon_init(), daemon_setup_modules(), daemon_get_shufport(), daemon_create_workers(), thread_start(), daemon_fork(), daemon_apply_cfg(), server_stats_obtain(), server_stats_reply(), checkrlimits(), detach(), perform_setup(), run_daemon(), main(), worker_handle_control_cmd(), fetch_fill(), libworker_bg(), lz_enter_rr_str(), local_zones_apply_cfg(), print_option(), check_mod(), localzonechecks(), interfacechecks(), aclchecks(), basedir(), check_chroot_string(), morechecks(), check_fwd(), checkconf(), setup_ctx(), contact_server(), go(), ring_create(), service_send(), find_create_proxy(), service_recv(), service_tcp_listen(), service_loop(), service(), fill_buffer_with_reply(), answer_callback_from_entry(), answer_check_it(), fake_pending_callback(), moment_assign(), time_passes(), autotrust_check(), do_infra_rtt(), do_moment_and_advance(), run_scenario(), comm_base_create(), comm_base_exit(), comm_point_send_reply(), pending_udp_query(), pending_tcp_query(), outnet_serviced_query(), read_header(), readup_str(), read_create(), insert_lock(), read_lock(), search_cycle(), read_malloc_stat(), read_calloc_stat(), get_file_size(), readfile(), perfsetup(), perfselect(), perfendstats(), qlist_grow_capacity(), qlist_add_line(), hex_to_buf(), replay_range_read(), read_file_content(), read_assign_step(), replay_moment_read(), replay_scenario_read(), do_macro_range(), read_keys(), read_rrs(), signit(), process_nsec3(), write_q(), recv_one(), send_em(), add_opts(), spool_auto_file(), setup_config(), setup_playback(), dname_to_buf(), newkey(), newdata(), perf_encode(), entry_to_buf(), dstest_entry(), verifytest_file(), dstest_file(), nsec3_hash_test(), ub_thread_blocksigs(), ub_thread_sig_unblock(), comm_base_dispatch(), comm_point_udp_ancil_callback(), readkeyword_bindfile(), service_init(), service_start(), wsvc_command_option(), and wsvc_setup_worker().
| void verbose | ( | enum verbosity_value | level, |
| const char * | format, | ||
| ... | |||
| ) |
implementation of verbose
| level,: | verbose level for the message. |
| format,: | format string printf-style. |
References verbosity, VERB_OPS, log_vmsg(), and VERB_DETAIL.
| void log_hex | ( | const char * | msg, |
| void * | data, | ||
| size_t | length | ||
| ) |
Log a hex-string to the log.
Can be any length. performs mallocs to do so, slow. But debug useful.
| msg,: | string desc to accompany the hexdump. |
| data,: | data to dump in hex format. |
| length,: | length of data. |
References log_hex_f(), and verbosity.
Referenced by test_buffers().
| void log_buf | ( | enum verbosity_value | level, |
| const char * | msg, | ||
| ldns_buffer * | buf | ||
| ) |
Easy alternative for log_hex, takes a ldns_buffer.
| level,: | verbosity level for this message, compared to global verbosity setting. |
| msg,: | string desc to print |
| buf,: | the buffer. |
References verbosity, and log_hex_f().
Referenced by worker_handle_request(), outnet_udp_cb(), serviced_callbacks(), recv_one(), and test_buffers().
FILE* logfile = 0 [static] |
the file logged to.
Referenced by config_get_option(), log_init(), log_file(), and log_vmsg().