Implementation of log.h. More...
#include "config.h"
#include "util/log.h"
#include "util/locks.h"
#include "sldns/sbuffer.h"
#include <stdarg.h>
#include <sys/time.h>
Macros | |
#define | LOG_CRIT 2 |
define LOG_ constants | |
#define | LOG_ERR 3 |
#define | LOG_WARNING 4 |
#define | LOG_NOTICE 5 |
#define | LOG_INFO 6 |
#define | LOG_DEBUG 7 |
Functions | |
void | log_init (const char *filename, int use_syslog, const char *chrootdir) |
call this to initialize logging services. More... | |
void | log_file (FILE *f) |
Set logging to go to the specified file *. More... | |
void | log_thread_set (int *num) |
Init a thread (will print this number for the thread log entries). More... | |
int | log_thread_get (void) |
Get the thread id from logging system. More... | |
void | log_ident_set (const char *id) |
Set identity to print, default is 'unbound'. More... | |
void | log_ident_set_default (const char *id) |
Set default identity to print, default is 'unbound'. More... | |
void | log_ident_revert_to_default (void) |
Revert identity to print, back to the recorded default value. | |
void | log_ident_set_or_default (const char *identity) |
Set identity to print if there is an identity, otherwise set the default. More... | |
void | log_set_time_asc (int use_asc) |
Set if the time value is printed ascii or decimal in log entries. More... | |
void | log_set_time_iso (int use_iso) |
Set if the time value is printed in ISO8601 format. More... | |
void * | log_get_lock (void) |
get log lock | |
void | log_vmsg (int pri, const char *type, const char *format, va_list args) |
va_list argument version of log_info. More... | |
void | log_info (const char *format,...) |
implementation of log_info More... | |
void | log_err (const char *format,...) |
implementation of log_err More... | |
void | log_warn (const char *format,...) |
implementation of log_warn More... | |
void | fatal_exit (const char *format,...) |
implementation of fatal_exit More... | |
void | verbose (enum verbosity_value level, const char *format,...) |
implementation of verbose More... | |
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. More... | |
void | log_query (const char *format,...) |
void | log_reply (const char *format,...) |
void | log_buf (enum verbosity_value level, const char *msg, sldns_buffer *buf) |
Easy alternative for log_hex, takes a sldns_buffer. More... | |
Variables | |
enum verbosity_value | verbosity = NO_VERBOSE |
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_type | logkey |
pthread key for thread ids in logfile | |
static lock_basic_type | log_lock |
pthread mutex to protect FILE* | |
static const char * | ident ="unbound" |
the identity of this executable/process | |
static const char * | default_ident ="unbound" |
static int | log_time_asc = 0 |
print time in UTC or in secondsfrom1970 | |
static int | log_time_iso = 0 |
print time in iso format | |
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(), log_lock, logfile, logkey, VERB_QUERY, and verbose().
Referenced by context_finalize(), do_log_reopen(), main(), service_start(), and ub_ctx_create_nopipe().
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 log_lock, and 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(), dnstap_io(), ext_thread(), libworker_dobg(), test_thr_main(), and thread_start().
int log_thread_get | ( | void | ) |
Get the thread id from logging system.
Set after log_init is initialised, or log_thread_set for newly created threads. This initialisation happens in unbound as a daemon, in daemon startup code, when that spawns threads.
References key_created, and logkey.
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 log_ident_set_or_default(), main(), and ub_ctx_create_nopipe().
void log_ident_set_default | ( | const char * | id | ) |
Set default identity to print, default is 'unbound'.
id | string to print. Name of executable. |
Referenced by main().
void log_ident_set_or_default | ( | const char * | identity | ) |
Set identity to print if there is an identity, otherwise set the default.
identity | the identity to set. |
References log_ident_set().
Referenced by apply_settings().
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(), and config_set_option().
void log_set_time_iso | ( | int | use_iso | ) |
Set if the time value is printed in ISO8601 format.
use_iso | if true, ascii timestamps are formatted in iso format. |
References log_time_iso.
Referenced by config_apply(), and config_set_option().
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.
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(), apply_http(), auth_zone_generate_answer(), autr_debug_print_tp(), comm_point_drop_reply(), comm_point_send_reply(), comm_point_tcp_accept_callback(), comm_timer_disable(), comm_timer_set(), delegpt_log(), do_moment_and_advance(), expon_timeout_backoff(), invalidateQueryInCache(), local_zones_print(), lruhash_status(), macro_print_debug(), main(), outnet_serviced_query_stop(), pending_find_match(), receive_bytes(), regional_log_stats(), reply_with_accept(), reply_with_finish(), run_scenario(), server_stats_log(), slabhash_status(), test_buffers(), test_long_table(), testlookup(), testlookup_unlim(), timehist_log(), verbose_print_unbound_socket(), and waitforubanchor().
void log_err | ( | const char * | format, |
... | |||
) |
implementation of log_err
format | format string printf-style. |
References log_vmsg().
Referenced by accept_open(), acl_find_or_create(), acl_interface_str_cfg(), add_bg_result(), add_open(), ah(), alloc_special_obtain(), anchor_read_bind_file(), anchor_read_bind_file_wild(), anchor_read_file(), anchors_add_insecure(), anchors_apply_cfg(), anchors_assemble_rrsets(), answer_chaos(), apply_http(), auth_addr_list_copy(), auth_master_copy(), auth_master_new(), auth_xfer_create(), auth_zone_delegpt(), auth_zone_read_zonefile(), auth_zone_set_fallback(), auth_zone_set_zonefile(), auth_zone_write_chunks(), auth_zone_write_file(), auth_zone_zonemd_fail(), auth_zones_apply_cfg(), auth_zones_create(), auth_zones_find_or_add_zone(), auth_zones_pickup_zonemd_verify(), autr_read_file(), autr_tp_create(), autr_write_file(), az_insert_rr(), az_insert_rr_decompress(), az_remove_rr(), az_remove_rr_decompress(), call_root_update(), caps_white_apply_cfg(), cfg_apply_local_port_policy(), cfg_parse_local_zone(), check_auth_name_for_ssl(), check_data(), check_order_lock(), check_zone_invariants(), checkconnecterr(), comm_base_delete(), comm_base_delete_no_base(), comm_base_exit(), comm_point_close(), comm_point_create_doq(), comm_point_create_http_out(), 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_http_handle_callback(), comm_point_listen_for_rw(), comm_point_local_handle_callback(), comm_point_perform_accept(), 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_udp_callback(), comm_signal_bind(), comm_signal_create(), comm_timer_create(), comm_timer_set(), config_read(), connect_sslctx_create(), cookie_secrets_apply_cfg(), create_local_accept_sock(), create_tcp_accept_sock(), create_udp_sock(), createResponse(), daemon_delete(), daemon_remote_create(), daemon_remote_exec(), daemon_remote_open_accept(), dname_pkt_copy(), dns64_apply_cfg(), dns64_inform_super(), dns64_init(), dns64_operate(), dns_alloc_msg(), dns_cache_find_delegation(), dns_cache_store_msg(), dnsc_load_local_data(), dnstap_io(), do_macro_arith(), do_macro_ctime(), do_macro_range(), do_macro_variable(), do_moment_and_advance(), do_proxy(), domain_limit_findcreate(), dt_io_thread_apply_cfg(), dt_io_thread_start(), dt_io_thread_stop(), dt_msg_queue_submit(), dtio_add_output_event_read(), dtio_add_output_event_write(), dtio_check_nb_connect(), dtio_control_stop_flush(), dtio_open_output(), dtio_open_output_local(), dtio_open_output_tcp(), dtio_read_accept_frame(), dtio_reconnect_enable(), dtio_stop_flush_exit(), dtio_wakeup(), dtio_write_buf(), edns_register_option(), edns_strings_apply_cfg(), errinf_to_str_bogus(), errinf_to_str_misc(), errinf_to_str_servfail(), error_supers(), fd_for_dest(), fd_set_block(), fd_set_nonblock(), fill_nsec3_iter(), find_add_tp(), find_covering_nsec3(), find_matching_nsec3(), forwards_insert_data(), generate_ns_check(), generate_request(), generate_sub_request(), handle_newq(), handle_req(), hdlr(), hints_insert(), http_parse_add_rr(), http_zonefile_syntax_check(), infra_set_lame(), inplace_cb_register(), ipset_init(), ipset_startup(), iter_apply_cfg(), iter_dns_store(), iter_init(), iter_store_parentside_neg(), iter_store_parentside_rrset(), key_cache_create(), libworker_do_cmd(), libworker_dobg(), listen_sslctx_create(), listening_ports_open(), local_zone_enter_defaults(), local_zone_enter_rr(), log_init(), log_py_err(), lz_enter_override(), lz_enter_rr_into_zone(), lz_enter_rr_str(), lz_enter_zone(), lz_enter_zone_dname(), lz_enter_zone_tag(), lz_exists(), lz_find_create_node(), lz_setup_implicit(), make_scenario(), make_sock(), make_sock_port(), make_stub_holes(), make_tcp_accept(), mesh_add_sub(), mesh_continue(), mesh_create(), mesh_new_client(), mesh_serve_expired_callback(), mesh_state_attachment(), modstack_call_init(), modstack_config(), neg_insert_data(), new_cname_override(), new_local_rrset(), new_rrset(), next_state(), nsec3_calc_b32(), nsec3_calc_hash(), nsec3_ce_wildcard(), nsec3_get_hashed(), nth_rtt(), outnet_comm_point_for_http(), outnet_tcp_take_into_use(), outside_network_create(), parse_delegpt(), parse_edns_options_from_query(), parse_var_line(), perfreply(), perfsend(), pick_outgoing_tcp(), prealloc_blocks(), prealloc_setup(), prime_root(), prime_stub(), print_hist(), print_id(), probe_anchor(), process_answer_detail(), process_ds_response(), process_response(), processInitRequest2(), processQueryResponse(), pythonmod_deinit(), pythonmod_inform_super(), pythonmod_init(), read_addrs(), read_fwds_addr(), read_fwds_host(), read_fwds_name(), read_multiline(), read_names(), read_root_hints(), read_stubs_addr(), read_stubs_host(), read_stubs_name(), receive_bytes(), remote_handshake_later(), replay_moment_read(), replay_range_read(), reply_with_accept(), reply_with_finish(), resolve_interface_names(), respip_action_cfg(), respip_enter_rr(), respip_find_or_create(), respip_operate(), respip_sockaddr_find_or_create(), respip_views_apply_cfg(), reuse_tcp_insert(), reuse_tcp_lru_touch(), reuse_tcp_remove_tree_list(), rpz_apply_cfg_elements(), rpz_insert_rr(), rrset_add_rr(), rrset_cache_update_wildcard(), rrset_canonical(), rrset_canonicalize_to_buffer(), rrset_create(), rrset_moveover_rrsigs(), rrset_remove_rr(), select_ifport(), set_auth_name_on_ssl(), set_recvpktinfo(), setup_comm_ssl(), signal_handling_record(), skip_to_special(), sock_list_insert(), ssl_handle_read(), ssl_handle_write(), ssl_http_read_more(), ssl_http_write_more(), table_grow(), tap_socket_list_addevs(), tap_socket_new_local(), tap_socket_new_tcpaccept(), tap_socket_new_tlsaccept(), tap_socket_setup(), tcp_relay_read(), tcp_relay_write(), tcp_req_info_add_result(), tcp_req_info_create(), tube_create(), tube_queue_item(), tube_read_msg(), tube_write_msg(), ub_comm_base_now(), ub_ctx_create_nopipe(), ub_stop_bg(), ub_thr_fork_wait(), val_apply_cfg(), val_init(), val_neg_addreferral(), val_neg_addreply(), val_neg_create(), validate_any_response(), validate_suspend_setup_timer(), views_apply_cfg(), views_enter_view_name(), waitforit(), waitforubanchor(), worker_create(), worker_send_cmd(), xfer_set_masters(), xfr_master_add_addrs(), xfr_probe_lookup_host(), xfr_probe_send_probe(), xfr_transfer_init_fetch(), xfr_transfer_lookup_host(), xfr_write_after_update(), and zonemd_offline_verify().
void log_warn | ( | const char * | format, |
... | |||
) |
implementation of log_warn
format | format string printf-style. |
References log_vmsg().
Referenced by alloc_get_id(), apply_settings(), auth_zone_create(), auth_zone_zonemd_fail(), auth_zones_apply_cfg(), autr_read_file(), az_domain_create(), check_holddown(), checkrlimits(), comm_point_tcp_accept_callback(), create_tcp_accept_sock(), create_udp_sock(), daemon_apply_cfg(), delegpt_add_rrset(), dt_io_thread_apply_cfg(), handle_origin(), iter_handle(), load_msg(), load_ref(), load_rr(), load_rrset(), local_rrset_remove_rr(), move_into_cache(), respip_sockaddr_find_or_create(), ring_add(), rrset_array_unlock_touch(), ub_thr_fork_wait(), val_handle(), val_init(), and views_enter_view_name().
void fatal_exit | ( | const char * | format, |
... | |||
) |
implementation of fatal_exit
format | format string printf-style. |
References LOG_CRIT, and log_vmsg().
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_OPS, and verbosity.
Referenced by log_hex_f(), and log_init().
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 auth_zone_generate_zonemd_check(), and test_buffers().
void log_buf | ( | enum verbosity_value | level, |
const char * | msg, | ||
struct sldns_buffer * | buf | ||
) |
Easy alternative for log_hex, takes a sldns_buffer.
level | verbosity level for this message, compared to global verbosity setting. |
msg | string desc to print |
buf | the buffer. |
References log_hex_f(), sldns_buffer_begin(), sldns_buffer_limit(), and verbosity.
Referenced by test_buffers().