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 ident, key_created, log_err(), logfile, logging_to_syslog, logkey, VERB_QUERY, and verbose().
Referenced by context_finalize(), do_log_reopen(), main(), perform_setup(), run_daemon(), service_init(), service_start(), and ub_ctx_create().
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 daemon_cleanup(), ext_thread(), libworker_dobg(), test_thr_main(), thread_start(), 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 main(), and ub_ctx_create().
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_delete(), and worker_init().
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 ident, log_now, log_time_asc, logfile, logging_to_syslog, logkey, MSG_GENERIC_ERR, MSG_GENERIC_INFO, MSG_GENERIC_SUCCESS, MSG_GENERIC_WARN, and SERVICE_NAME.
Referenced by fatal_exit(), log_err(), log_info(), log_warn(), and verbose().
void log_info | ( | const char * | format, | |
... | ||||
) |
implementation of log_info
format,: | format string printf-style. |
References log_vmsg().
Referenced by alloc_stats(), answer_check_it(), autotrust_check(), autr_debug_print_ta(), autr_debug_print_tp(), comm_point_drop_reply(), comm_point_send_reply(), comm_point_tcp_accept_callback(), comm_timer_disable(), comm_timer_set(), daemon_fork(), delegpt_log(), do_moment_and_advance(), fake_front_query(), invalidateQueryInCache(), local_zones_print(), log_dns_msg(), log_nametypeclass(), log_pkt(), lruhash_status(), macro_print_debug(), main(), mesh_stats(), moment_assign(), outnet_serviced_query(), outnet_serviced_query_stop(), p_ancil(), pending_find_match(), pending_matches_range(), pending_tcp_query(), pending_udp_query(), processFinished(), regional_log_stats(), replay_scenario_read(), run_scenario(), server_stats_log(), setup_playback(), sigdate_error(), slabhash_status(), test_buffers(), test_long_table(), testlookup(), testlookup_unlim(), time_passes(), timehist_log(), worker_handle_control_cmd(), and worker_mem_report().
void log_err | ( | const char * | format, | |
... | ||||
) |
implementation of log_err
format,: | format string printf-style. |
References log_vmsg().
Referenced by accept_open(), acl_list_str_cfg(), add_bg_result(), add_open(), add_trustanchor_frm_str(), ah(), anchor_insert_insecure(), anchor_read_bind_file(), anchor_read_bind_file_wild(), anchor_read_file(), anchor_store_new_key(), anchor_store_new_rr(), anchor_store_str(), anchors_apply_cfg(), anchors_assemble_rrsets(), answer_chaos(), autotrust_check(), autr_process_prime(), autr_read_file(), autr_tp_create(), autr_write_file(), cfg_mark_ports(), cfg_parse_local_zone(), cfg_parse_memsize(), cfg_ptr_reverse(), check_contains_revoked(), check_order_lock(), check_zone_invariants(), checkrlimits(), comm_base_exit(), comm_base_now(), comm_point_close(), comm_point_create_local(), comm_point_create_raw(), comm_point_create_tcp(), comm_point_create_tcp_handler(), comm_point_create_tcp_out(), comm_point_create_udp(), comm_point_create_udp_ancil(), comm_point_listen_for_rw(), comm_point_local_handle_callback(), comm_point_perform_accept(), comm_point_send_reply(), comm_point_send_udp_msg(), comm_point_send_udp_msg_if(), comm_point_start_listening(), comm_point_stop_listening(), comm_point_tcp_handle_callback(), comm_point_tcp_handle_read(), comm_point_tcp_handle_write(), comm_point_udp_ancil_callback(), comm_point_udp_callback(), comm_signal_bind(), comm_signal_create(), comm_timer_create(), comm_timer_set(), config_read(), contact_server(), create_tcp_accept_sock(), create_udp_sock(), createResponse(), daemon_delete(), daemon_init(), daemon_remote_create(), daemon_remote_exec(), daemon_remote_open_accept(), dname_pkt_copy(), dns_alloc_msg(), dns_cache_find_delegation(), dns_cache_store_msg(), dnskey_verify_rrset_sig(), do_macro_arith(), do_macro_ctime(), do_macro_range(), do_macro_variable(), do_moment_and_advance(), do_proxy(), donotq_str_cfg(), entry_to_buf(), errinf(), errinf_rrset(), errinf_to_str(), error_response_cache(), error_supers(), fd_set_block(), fd_set_nonblock(), fill_buffer_with_reply(), fill_nsec3_iter(), find_add_tp(), find_covering_nsec3(), find_matching_nsec3(), forwards_insert_data(), generate_ns_check(), generate_request(), generate_sub_request(), get_rr_content(), get_rr_nameclass(), handle_newq(), hdlr(), hints_insert(), infra_set_lame(), insert_rr(), iter_apply_cfg(), iter_init(), iter_operate(), iter_store_inzone_glue(), key_cache_create(), libworker_do_cmd(), libworker_dobg(), libworker_enter_result(), listen_create(), load_trustanchor(), local_zones_add_zone(), log_crypto_err(), log_crypto_error(), log_init(), lz_enter_defaults(), lz_enter_rr_into_zone(), lz_enter_rr_str(), lz_enter_zone(), lz_enter_zone_dname(), lz_exists(), lz_find_create_node(), lz_setup_implicit(), make_scenario(), make_sock(), make_sock_port(), make_stub_holes(), mesh_attach_sub(), mesh_continue(), mesh_create(), mesh_new_client(), mesh_new_prefetch(), mesh_state_attachment(), modstack_config(), modstack_setup(), neg_insert_data(), netblockstrtoaddr(), new_local_rrset(), next_state(), nsec3_calc_b32(), nsec3_calc_hash(), nsec3_ce_wildcard(), nsec3_get_hashed(), outnet_serviced_query(), outnet_tcp_take_into_use(), outside_network_create(), parse_comments(), parse_dname(), parse_var_line(), pending_tcp_query(), pending_udp_query(), perform_setup(), perfreply(), perfselect(), perfsend(), prealloc(), prealloc_blocks(), prime_root(), prime_stub(), prime_supers(), prime_trust_anchor(), primeResponseToKE(), print_hist(), print_id(), probe_anchor(), process_answer_detail(), process_bind_contents(), process_dlv_response(), process_dnskey_response(), process_ds_response(), process_response(), processClassResponse(), processDLVLookup(), processFindKey(), processFinished(), processInitRequest(), processQueryResponse(), processTargetResponse(), processValidate(), pythonmod_deinit(), pythonmod_inform_super(), pythonmod_init(), pythonmod_operate(), query_info_allocqname(), read_addrs(), read_fetch_policy(), read_forwards(), read_fwds_addr(), read_fwds_host(), read_fwds_name(), read_multiline(), read_names(), read_root_hints(), read_stubs(), read_stubs_addr(), read_stubs_host(), read_stubs_name(), readpid(), record_sigh(), remote_accept_callback(), remote_control_callback(), replay_moment_read(), replay_range_read(), reply_info_answer_encode(), rrset_canonical(), run_scenario(), scrub_normalize(), select_id(), select_ifport(), service(), service_init(), service_main(), service_send(), service_tcp_listen(), serviced_callbacks(), serviced_tcp_callback(), serviced_tcp_initiate(), serviced_udp_callback(), set_recvpktinfo(), setup_key_digest(), signal_handling_record(), skip_to_special(), sock_list_insert(), ssl_read_line(), table_grow(), tcp_relay_read(), tcp_relay_write(), tube_create(), tube_handle_listen(), tube_handle_write(), tube_queue_item(), tube_read_msg(), tube_setup_bg_listen(), tube_setup_bg_write(), tube_write_msg(), ub_arc4random_stir(), ub_ctx_create(), ub_initstate(), ub_systemseed(), val_apply_cfg(), val_dlv_init(), val_inform_super(), val_init(), val_neg_addreferral(), val_neg_addreply(), val_neg_create(), val_operate(), validate_any_response(), waitforit(), win_do_cron(), worker_handle_control_cmd(), worker_init(), worker_send_cmd(), worker_sighandler(), and writepid().
void log_warn | ( | const char * | format, | |
... | ||||
) |
implementation of log_warn
format,: | format string printf-style. |
References log_vmsg().
Referenced by alloc_get_id(), anchors_assemble_rrsets(), autr_read_file(), check_holddown(), checkoldpid(), checkrlimits(), comm_point_tcp_accept_callback(), create_udp_sock(), delegpt_add_rrset(), ds_response_to_ke(), go(), handle_origin(), iter_handle(), listening_ports_open(), load_msg(), load_qinfo(), load_ref(), load_rr(), load_rrset(), lz_enter_zone_dname(), main(), move_into_cache(), outnet_udp_cb(), perform_setup(), ports_create_if(), processQueryResponse(), read_root_hints(), remote_accept_callback(), ring_add(), rrset_array_unlock_touch(), run_daemon(), service_init(), and val_handle().
void fatal_exit | ( | const char * | format, | |
... | ||||
) |
implementation of fatal_exit
format,: | format string printf-style. |
References log_vmsg().
Referenced by aclchecks(), add_opts(), alloc_special_obtain(), answer_callback_from_entry(), answer_check_it(), autotrust_check(), basedir(), check_chroot_string(), check_fwd(), check_mod(), checkconf(), checkrlimits(), comm_base_create(), comm_base_dispatch(), comm_base_exit(), comm_point_send_reply(), comm_point_udp_ancil_callback(), contact_server(), daemon_apply_cfg(), daemon_create_workers(), daemon_fork(), daemon_get_shufport(), daemon_init(), daemon_setup_modules(), detach(), dname_to_buf(), do_macro_range(), do_moment_and_advance(), dstest_entry(), dstest_file(), entry_to_buf(), fake_pending_callback(), fetch_fill(), fill_buffer_with_reply(), find_create_proxy(), get_file_size(), go(), hex_to_buf(), insert_lock(), interfacechecks(), libworker_bg(), local_zones_apply_cfg(), localzonechecks(), lz_enter_rr_str(), main(), moment_assign(), morechecks(), newdata(), newkey(), nsec3_hash_test(), outnet_serviced_query(), pending_tcp_query(), pending_udp_query(), perf_encode(), perfendstats(), perform_setup(), perfselect(), perfsetup(), print_option(), process_nsec3(), qlist_add_line(), qlist_grow_capacity(), read_assign_step(), read_calloc_stat(), read_create(), read_file_content(), read_header(), read_keys(), read_lock(), read_malloc_stat(), read_rrs(), readfile(), readkeyword_bindfile(), readup_str(), replay_moment_read(), replay_range_read(), replay_scenario_read(), ring_create(), run_daemon(), run_scenario(), search_cycle(), send_em(), server_stats_obtain(), server_stats_reply(), service(), service_init(), service_loop(), service_recv(), service_send(), service_start(), service_tcp_listen(), setup_config(), setup_ctx(), setup_playback(), signit(), spool_auto_file(), thread_start(), time_passes(), ub_thread_blocksigs(), ub_thread_sig_unblock(), verifytest_file(), worker_handle_control_cmd(), write_q(), 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 log_vmsg(), VERB_DETAIL, VERB_OPS, and verbosity.
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 log_hex_f(), and verbosity.
Referenced by outnet_udp_cb(), recv_one(), serviced_callbacks(), test_buffers(), and worker_handle_request().
FILE* logfile = 0 [static] |
the file logged to.
Referenced by config_get_option(), log_file(), log_init(), and log_vmsg().