unbound: util/log.h File Reference

unbound 0.1

Macros | Enumerations | Functions | Variables
log.h File Reference

This file contains logging functions. More...

## Macros
#define | log_assert(x)
| an assertion that is thrown to the logfile.

## Enumerations
enum | verbosity_value { NO_VERBOSE = 0 , VERB_OPS , VERB_DETAIL , VERB_QUERY , VERB_ALGO , VERB_CLIENT }
| verbosity value: More...

## Functions
void | verbose (enum verbosity_value level, const char *format,...) ATTR_FORMAT(printf
| log a verbose message, pass the level for this message.
void 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).
int | log_thread_get (void)
| Get the thread id from logging system.
void | log_ident_set (const char *id)
| Set identity to print, default is 'unbound'.
void | log_ident_set_default (const char *id)
| Set default identity to print, default is 'unbound'.
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.
void | log_set_time_asc (int use_asc)
| Set if the time value is printed ascii or decimal in log entries.
void * | log_get_lock (void)
| get log lock
void | log_info (const char *format,...) ATTR_FORMAT(printf
| Log informational message.
void void | log_err (const char *format,...) ATTR_FORMAT(printf
| Log error message.
void void void | log_warn (const char *format,...) ATTR_FORMAT(printf
| Log warning message.
void void void void | log_hex (const char *msg, void *data, size_t length)
| Log a hex-string to the log.
void | log_query (const char *format,...) ATTR_FORMAT(printf
| Log query.
void void | log_reply (const char *format,...) ATTR_FORMAT(printf
| Log reply.
void void void | log_buf (enum verbosity_value level, const char *msg, struct sldns_buffer *buf)
| Easy alternative for log_hex, takes a sldns_buffer.
void | fatal_exit (const char *format,...) ATTR_FORMAT(printf
| Log fatal error message, and exit the current process.
void | log_vmsg (int pri, const char *type, const char *format, va_list args)
| va_list argument version of log_info.

## Variables
enum verbosity_value | verbosity
| The global verbosity setting.
void | ATTR_NORETURN

## Detailed Description

This file contains logging functions.

## Macro Definition Documentation

## ◆ log_assert

#define log_assert | ( |  | x | ) |

Value:
/*nothing*/

an assertion that is thrown to the logfile.

Referenced by add_cookie_secret(), add_open(), addr_in_common(), addr_to_nat64(), addrtree_create(), addrtree_delete(), addrtree_find(), addrtree_insert(), algo_needs_init_ds(), algo_needs_init_list(), alloc_reg_release(), alloc_special_obtain(), alloc_special_release(), anchor_new_ta(), anchor_state_update(), answer_check_it(), auth_xfer_probe_lookup_callback(), auth_xfer_probe_timer_callback(), auth_xfer_probe_udp_callback(), auth_xfer_timer(), auth_xfer_transfer_http_callback(), auth_xfer_transfer_lookup_callback(), auth_xfer_transfer_tcp_callback(), auth_xfer_transfer_timer_callback(), autotrust_check(), autr_process_prime(), autr_write_file(), az_add_negative_soa(), az_generate_dname_answer(), az_generate_referral_answer(), az_nsec3_get_nextcloser(), bits_common(), calc_data_need(), calc_zone_need(), canonical_compare(), canonical_tree_compare(), cfg_condense_ports(), cfg_set_bit(), change_child_ptr(), change_parent_ptr(), change_rrsig_rrset(), change_section(), check_contains_revoked(), comm_point_delete(), comm_point_drop_reply(), comm_point_http2_handle_read(), comm_point_http2_handle_write(), comm_point_http_handle_callback(), comm_point_http_handle_read(), comm_point_http_handle_write(), comm_point_local_handle_callback(), comm_point_send_reply(), comm_point_send_udp_msg(), comm_point_send_udp_msg_if(), comm_point_tcp_accept_callback(), comm_point_tcp_handle_callback(), comm_point_tcp_handle_read(), comm_point_tcp_handle_write(), comm_point_udp_callback(), comm_signal_bind(), comm_timer_set(), compress_tree_store(), context_deserialize_answer(), context_deserialize_cancel(), context_deserialize_new_query(), context_lookup_new_query(), cookie_secret_file_dump(), cookie_secret_file_read(), daemon_cleanup(), daemon_create_workers(), daemon_fork(), daemon_open_shared_ports(), daemon_remote_open_ports(), daemon_start_others(), daemon_stop_others(), delegpt_add_addr(), delegpt_add_addr_mlc(), delegpt_add_ns(), delegpt_add_ns_mlc(), delegpt_add_rrset_A(), delegpt_add_rrset_AAAA(), delegpt_add_target(), delegpt_add_target_mlc(), delegpt_free_mlc(), delegpt_rrset_add_ns(), delegpt_set_name(), delegpt_set_name_mlc(), dname_canon_lab_cmp(), dname_is_root(), dname_lab_cmp(), dname_pkt_compare(), dname_pkt_copy(), dname_pkt_hash(), dname_query_hash(), dname_remove_label(), dns64_adjust_a(), dns64_inform_super(), do_print_cookie_secrets(), do_stats(), dtio_control_ready_send(), dtio_control_start_send(), edge_create(), edns_opt_compare(), edns_strings_apply_cfg(), ext_callback(), extract_ipv4(), fill_any(), fill_buffer_with_reply(), generate_a_aaaa_check(), generate_dnskey_prefetch(), generate_ns_check(), get_max_iter(), get_rdf_size(), getbit(), hex_to_buf(), http_read_more(), http_write_more(), insert_can_owner(), ipv4_to_ptr(), iter_msg_from_zone(), iter_server_selection(), local_data_answer(), local_rrset_remove_rr(), local_zone_enter_rr(), lru_demote(), lru_touch(), lz_enter_rr_into_zone(), lz_find_create_node(), mesh_add_sub(), mesh_attach_sub(), mesh_detach_subs(), mesh_do_callback(), mesh_new_callback(), mesh_new_client(), mesh_query_done(), mesh_send_reply(), mesh_serve_expired_callback(), mesh_state_add_cb(), mesh_state_add_reply(), mesh_state_attachment(), mesh_state_cleanup(), mesh_state_delete(), mesh_state_remove_reply(), msg_add_rrset_an(), msg_add_rrset_ns(), neg_create_zone(), neg_delete_data(), neg_delete_zone(), neg_insert_data(), nsec3_do_prove_nameerror(), nsec3_do_prove_nodata(), nsec3_get_algo(), nsec3_get_iter(), nsec3_get_nextowner(), nsec3_get_salt(), nsec3_has_optout(), nsec3_has_type(), nsec3_hash_name(), nsec3_known_algo(), nsec3_prove_nods(), nsec3_unknown_flags(), nsec_proves_nodata(), nth_rtt(), outnet_send_wait_udp(), outnet_serviced_query_stop(), outnet_tcp_cb(), outnet_tcp_take_into_use(), outnet_udp_cb(), outnet_waiting_tcp_list_add(), outnet_waiting_tcp_list_add_first(), outnet_waiting_tcp_list_pop(), outnet_waiting_tcp_list_remove(), packed_rr_to_string(), packed_rrset_heap_data(), packed_rrset_sizeof(), parse_copy_decompress(), parse_create_msg(), parse_edns_from_query_pkt(), parse_extract_edns_from_response_msg(), parse_query_section(), pending_cmp(), pending_delete(), pending_tcp_query(), pending_udp_query(), pending_udp_query(), perf_sigh(), pick_outgoing_tcp(), portcomm_loweruse(), pr_rrs(), prime_supers(), print_root_fwds(), priv_lookup_name(), probetree_cmp(), process_answer_detail(), processFindKey(), processLastResort(), processTargetResponse(), ptr_to_ipv6(), pushintosuper(), qinfo_query_encode(), query_dname_compare(), query_for_targets(), query_info_compare(), randomize_and_send_udp(), rbtree_delete(), rbtree_delete_fixup(), rbtree_find_less_equal(), rdata_copy(), read_acl_interface_tag_actions(), read_acl_interface_tag_datas(), read_acl_interface_tags(), read_acl_interface_view(), read_acl_list(), read_acl_tag_actions(), read_acl_tag_datas(), read_acl_tags(), read_acl_view(), read_addrs(), read_create(), read_donotq(), read_fwds_addr(), read_fwds_host(), read_names(), read_root_hints_list(), read_stubs_addr(), read_stubs_host(), read_tcl_list(), reclaim_http_handler(), reclaim_space(), reclaim_tcp_handler(), regional_create_custom_large_object(), regional_log_stats(), remove_rrset(), reply_equal(), reply_info_answer_encode(), respip_inform_super(), respip_rewrite_reply(), reuse_tcp_find(), reuse_tcp_insert(), reuse_tcp_lru_snip(), reuse_tcp_lru_touch(), reuse_tcp_remove_tree_list(), reuse_tcp_select_id(), reuse_tree_by_id_delete(), reuse_tree_by_id_insert(), reuse_write_wait_pop(), reuse_write_wait_push_back(), reuse_write_wait_remove(), ring_add(), ring_pop(), rpz_callback_from_worker_request(), rpz_insert_rr(), rpz_rr_to_action(), rrset_cache_update(), rrset_get_rdata(), rrset_get_sig_algo(), rrset_get_sig_keytag(), rrset_has_sigover(), rrset_moveover_rrsigs(), rrsig_num_that_cover(), sanitize_nsec_is_overreach(), select_ifport(), serviced_callbacks(), serviced_check_qname(), serviced_cmp(), serviced_create(), serviced_delete(), serviced_perturb_qname(), serviced_tcp_callback(), serviced_tcp_initiate(), serviced_tcp_send(), serviced_udp_callback(), set_next_probe(), setup_tcp_handler(), slabhash_create(), sock_list_insert(), sockaddr_cmp(), sockaddr_cmp_addr(), ssl_handle_write(), ssl_http_read_more(), ssl_http_write_more(), synth_cname(), synthesize_aaaa(), tap_data_list_try_to_free_tail(), tcl_close_connection(), tcp_callback_reader(), tcp_callback_writer(), tcp_req_info_add_meshstate(), tcp_req_info_pop_done(), tempfile_check(), ub_cancel(), ub_ctx_set_fwd(), update_events(), use_free_buffer(), val_neg_getmsg(), val_new(), val_nsec_proves_no_ds(), val_reply_remove_auth(), worker_init(), xfr_set_timeout(), xfr_start_transfer(), and xfr_transfer_nexttarget_or_end().

## Enumeration Type Documentation

## ◆ verbosity_value

enum verbosity_value

verbosity value:

Enumerator
NO_VERBOSE | 0 - no verbose messages
VERB_OPS | 1 - operational information
VERB_DETAIL | 2 - detailed information
VERB_QUERY | 3 - query level information
VERB_ALGO | 4 - algorithm level information
VERB_CLIENT | 5 - querier client information

## Function Documentation

## ◆ verbose()

void verbose | ( | enum verbosity_value | level,
|  | const char * | format,
|  |  | ... )

log a verbose message, pass the level for this message.

It has printf formatted arguments. No trailing newline is needed.

Parameters

  level | verbosity level for this message, compared to global verbosity setting.
  format | printf-style format string. Arguments follow.

## ◆ log_init()

void void log_init | ( | const char * | filename,
|  | int | use_syslog,
|  | const char * | chrootdir )

call this to initialize logging services.

Parameters

  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(), main(), main(), perform_setup(), run_daemon(), service_init(), service_start(), and ub_ctx_create_nopipe().

## ◆ log_file()

void log_file | ( | FILE * | f | ) |

Set logging to go to the specified file *.

This setting does not affect the use_syslog setting.

Parameters

  f | to that file, or pass NULL to disable logging.

References log_lock, and logfile.

Referenced by context_finalize(), ub_ctx_debugout(), and ub_ctx_delete().

## ◆ log_thread_set()

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.

Parameters

  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(), test_thr_main(), thread_start(), and win_do_cron().

## ◆ log_thread_get()

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.

Returns
  thread number, from 0 and up. Before initialised, returns 0.

References key_created, and logkey.

## ◆ log_ident_set()

void log_ident_set | ( | const char * | id | ) |

Set identity to print, default is 'unbound'.

Parameters

  id | string to print. Name of executable.

References ident.

Referenced by log_ident_set_or_default(), main(), main(), and ub_ctx_create_nopipe().

## ◆ log_ident_set_default()

void log_ident_set_default | ( | const char * | id | ) |

Set default identity to print, default is 'unbound'.

Parameters

  id | string to print. Name of executable.

Referenced by main().

## ◆ log_ident_set_or_default()

void log_ident_set_or_default | ( | const char * | identity | ) |

Set identity to print if there is an identity, otherwise set the default.

Parameters

  identity | the identity to set.

References log_ident_set().

Referenced by apply_settings().

## ◆ log_set_time_asc()

void log_set_time_asc | ( | int | use_asc | ) |

Set if the time value is printed ascii or decimal in log entries.

Parameters

  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().

## ◆ log_info()

void log_info | ( | const char * | format,
|  |  | ... )

Log informational message.

Pass printf formatted arguments. No trailing newline is needed.

Parameters

  format | printf-style format string. Arguments follow.

## ◆ log_err()

void void log_err | ( | const char * | format,
|  |  | ... )

Log error message.

Pass printf formatted arguments. No trailing newline is needed.

Parameters

  format | printf-style format string. Arguments follow.

## ◆ log_warn()

void void void log_warn | ( | const char * | format,
|  |  | ... )

Log warning message.

Pass printf formatted arguments. No trailing newline is needed.

Parameters

  format | printf-style format string. Arguments follow.

## ◆ log_hex()

void void void 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.

Parameters

  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().

## ◆ log_query()

void log_query | ( | const char * | format,
|  |  | ... )

Log query.

Pass printf formatted arguments. No trailing newline is needed.

Parameters

  format | printf-style format string. Arguments follow.

## ◆ log_reply()

void void log_reply | ( | const char * | format,
|  |  | ... )

Log reply.

Pass printf formatted arguments. No trailing newline is needed.

Parameters

  format | printf-style format string. Arguments follow.

## ◆ log_buf()

void void void log_buf | ( | enum verbosity_value | level,
|  | const char * | msg,
|  | struct sldns_buffer * | buf )

Easy alternative for log_hex, takes a sldns_buffer.

Parameters

  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 outnet_udp_cb(), serviced_callbacks(), and test_buffers().

## ◆ fatal_exit()

void fatal_exit | ( | const char * | format,
|  |  | ... )

Log fatal error message, and exit the current process.

Pass printf formatted arguments. No trailing newline is needed.

Parameters

  format | printf-style format string. Arguments follow.

## ◆ log_vmsg()

void log_vmsg | ( | int | pri,
|  | const char * | type,
|  | const char * | format,
|  | va_list | args )

va_list argument version of log_info.

Parameters

  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_lock, log_time_asc, logfile, 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().