Asterisk - The Open Source Telephony Project  21.4.1
Macros | Typedefs | Enumerations | Functions | Variables
include/asterisk/logger.h File Reference

Support for logging to various files, console and syslog Configuration in file logger.conf. More...

#include "asterisk/options.h"

Go to the source code of this file.

Macros

#define __LOG_DEBUG   0
 
#define __LOG_DTMF   6
 
#define __LOG_ERROR   4
 
#define __LOG_NOTICE   2
 
#define __LOG_TRACE   1
 
#define __LOG_VERBOSE   5
 
#define __LOG_WARNING   3
 
#define _A_   __FILE__, __LINE__, __FUNCTION__
 
#define _TRACE_PREFIX_   _TRACE_PREFIX_DEFAULT_
 
#define _TRACE_PREFIX_DEFAULT_   _A_
 
#define AST_CALLID_BUFFER_LENGTH   13
 
#define ast_debug(level, ...)
 Log a DEBUG message. More...
 
#define AST_LOG_DEBUG   __LOG_DEBUG, _A_
 
#define AST_LOG_DTMF   __LOG_DTMF, _A_
 
#define ast_log_dynamic_level(level, ...)   ast_log(level, _A_, __VA_ARGS__)
 Send a log message to a dynamically registered log level. More...
 
#define AST_LOG_ERROR   __LOG_ERROR, _A_
 
#define AST_LOG_NOTICE   __LOG_NOTICE, _A_
 
#define AST_LOG_TRACE   __LOG_TRACE, _A_
 
#define AST_LOG_VERBOSE   __LOG_VERBOSE, _A_
 
#define AST_LOG_WARNING   __LOG_WARNING, _A_
 
#define ast_trace(level, ...)   ast_debug(level < 0 ? __scope_level : level, " " __VA_ARGS__)
 
#define ast_trace_dec_indent()
 
#define ast_trace_get_indent()   (0)
 
#define ast_trace_inc_indent()
 
#define ast_trace_log(__level, __log_level, ...)
 
#define ast_trace_raw(level, indent_type, ...)   ast_debug(level < 0 ? __scope_level : level, " " __VA_ARGS__)
 
#define ast_trace_set_indent(indent)
 
#define ast_verb(level, ...)
 
#define ast_verb_callid(level, callid, ...)
 
#define ast_verbose(...)   __ast_verbose(_A_, -1, __VA_ARGS__)
 
#define ast_verbose_callid(callid, ...)   __ast_verbose_callid(_A_, -1, callid, __VA_ARGS__)
 
#define DEBUG_ATLEAST(level)
 
#define DEBUG_M(a)
 
#define EVENTLOG   "event_log"
 
#define LOG_DEBUG   __LOG_DEBUG, _A_
 
#define LOG_DTMF   __LOG_DTMF, _A_
 
#define LOG_ERROR   __LOG_ERROR, _A_
 
#define LOG_NOTICE   __LOG_NOTICE, _A_
 
#define LOG_TRACE   __LOG_TRACE, _A_
 
#define LOG_VERBOSE   __LOG_VERBOSE, _A_
 
#define LOG_WARNING   __LOG_WARNING, _A_
 
#define NUMLOGLEVELS   32
 
#define QUEUELOG   "queue_log"
 
#define SCOPE_CALL(level, __funcname, ...)   __funcname(__VA_ARGS__)
 
#define SCOPE_CALL_WITH_INT_RESULT(level, __funcname, ...)   __funcname(__VA_ARGS__)
 
#define SCOPE_CALL_WITH_RESULT(level, __var, __funcname, ...)   __var = __funcname(__VA_ARGS__)
 
#define SCOPE_ENTER(level, ...)
 
#define SCOPE_ENTER_TASK(level, indent, ...)
 
#define SCOPE_EXIT(...)   ast_debug(__scope_level, " " __VA_ARGS__)
 
#define SCOPE_EXIT_EXPR(__expr, ...)
 
#define SCOPE_EXIT_LOG(__log_level, ...)
 
#define SCOPE_EXIT_LOG_EXPR(__expr, __log_level, ...)
 
#define SCOPE_EXIT_LOG_RTN(__log_level, ...)
 
#define SCOPE_EXIT_LOG_RTN_VALUE(__value, __log_level, ...)
 
#define SCOPE_EXIT_RTN(...)
 
#define SCOPE_EXIT_RTN_VALUE(__return_value, ...)
 
#define SCOPE_TRACE(__level, ...)
 
#define TRACE_ATLEAST(level)
 
#define VERBOSE_HASMAGIC(x)   (*(signed char *) (x) < 0)
 
#define VERBOSE_MAGIC2LEVEL(x)   (((char) -*(signed char *) (x)) - 1)
 
#define VERBOSE_PREFIX_1   " "
 
#define VERBOSE_PREFIX_10   " > "
 
#define VERBOSE_PREFIX_2   " == "
 
#define VERBOSE_PREFIX_3   " -- "
 
#define VERBOSE_PREFIX_4   " > "
 
#define VERBOSE_PREFIX_5   " > "
 
#define VERBOSE_PREFIX_6   " > "
 
#define VERBOSE_PREFIX_7   " > "
 
#define VERBOSE_PREFIX_8   " > "
 
#define VERBOSE_PREFIX_9   " > "
 
#define VERBOSITY_ATLEAST(level)   ((level) <= ast_verb_sys_level)
 

Typedefs

typedef unsigned int ast_callid
 

Enumerations

enum  ast_logger_results { AST_LOGGER_SUCCESS = 0, AST_LOGGER_FAILURE = 1, AST_LOGGER_DECLINE = -1, AST_LOGGER_ALLOC_ERROR = -2 }
 
enum  ast_trace_indent_type {
  AST_TRACE_INDENT_SAME = 0, AST_TRACE_INDENT_INC_BEFORE, AST_TRACE_INDENT_INC_AFTER, AST_TRACE_INDENT_DEC_BEFORE,
  AST_TRACE_INDENT_DEC_AFTER, AST_TRACE_INDENT_PROVIDED, AST_TRACE_INDENT_NONE
}
 Controls if and when indenting is applied. More...
 

Functions

void __ast_verbose (const char *file, int line, const char *func, int level, const char *fmt,...)
 Send a verbose message (based on verbose level) More...
 
void __ast_verbose_ap (const char *file, int line, const char *func, int level, ast_callid callid, const char *fmt, va_list ap)
 
void __ast_verbose_callid (const char *file, int line, const char *func, int level, ast_callid callid, const char *fmt,...)
 Send a verbose message (based on verbose level) with deliberately specified callid. More...
 
void ast_callid_strnprint (char *buffer, size_t buffer_size, ast_callid callid)
 copy a string representation of the callid into a target string More...
 
int ast_callid_threadassoc_add (ast_callid callid)
 Adds a known callid to thread storage of the calling thread. More...
 
int ast_callid_threadassoc_change (ast_callid callid)
 Sets what is stored in the thread storage to the given callid if it does not match what is already there. More...
 
int ast_callid_threadassoc_remove (void)
 Removes callid from thread storage of the calling thread. More...
 
int ast_callid_threadstorage_auto (ast_callid *callid)
 Checks thread storage for a callid and stores a reference if it exists. If not, then a new one will be created, bound to the thread, and a reference to it will be stored. More...
 
void ast_callid_threadstorage_auto_clean (ast_callid callid, int callid_created)
 Use in conjunction with ast_callid_threadstorage_auto. Cleans up the references and if the callid was created by threadstorage_auto, unbinds the callid from the threadstorage. More...
 
void ast_child_verbose (int level, const char *fmt,...)
 
void ast_console_puts (const char *string)
 write the string to the root console, and all attached network console clients
 
void ast_console_puts_mutable (const char *string, int level)
 log the string to the console, and all attached console clients More...
 
void ast_console_puts_mutable_full (const char *message, int level, int sublevel)
 log the string to the console, and all attached console clients More...
 
void ast_console_toggle_loglevel (int fd, int level, int state)
 enables or disables logging of a specified level to the console fd specifies the index of the console receiving the level change level specifies the index of the logging level being toggled state indicates whether logging will be on or off (0 for off, 1 for on) More...
 
void ast_console_toggle_mute (int fd, int silent)
 mute or unmute a console from logging
 
ast_callid ast_create_callid (void)
 factory function to create a new uniquely identifying callid. More...
 
unsigned int ast_debug_get_by_module (const char *module)
 Get the debug level for a module. More...
 
void ast_init_logger_for_socket_console (void)
 load logger.conf configuration for console socket connections
 
int ast_is_logger_initialized (void)
 Test if logger is initialized. More...
 
void ast_log (int level, const char *file, int line, const char *function, const char *fmt,...)
 Used for sending a log message This is the standard logger function. Probably the only way you will invoke it would be something like this: ast_log(AST_LOG_WHATEVER, "Problem with the %s Captain. We should get some more. Will %d be enough?\n", "flux capacitor", 10); where WHATEVER is one of ERROR, DEBUG, EVENT, NOTICE, or WARNING depending on which log you wish to output to. These are implemented as macros, that will provide the function with the needed arguments. More...
 
void ast_log_ap (int level, const char *file, int line, const char *function, const char *fmt, va_list ap)
 
void ast_log_backtrace (void)
 Log a backtrace of the current thread's execution stack to the Asterisk log.
 
void ast_log_callid (int level, const char *file, int line, const char *function, ast_callid callid, const char *fmt,...)
 Used for sending a log message with a known call_id This is a modified logger function which is functionally identical to the above logger function, it just include a call_id argument as well. If NULL is specified here, no attempt will be made to join the log message with a call_id. More...
 
void ast_log_safe (int level, const char *file, int line, const char *function, const char *fmt,...)
 Used for sending a log message with protection against recursion. More...
 
int ast_logger_create_channel (const char *log_channel, const char *components)
 Create a log channel. More...
 
int ast_logger_get_channels (int(*logentry)(const char *channel, const char *type, const char *status, const char *configuration, void *data), void *data)
 Retrieve the existing log channels. More...
 
const char * ast_logger_get_dateformat (void)
 Get the logger configured date format. More...
 
int ast_logger_get_dynamic_level (const char *name)
 Retrieve dynamic logging level id. More...
 
int ast_logger_get_queue_limit (void)
 Get the maximum number of messages allowed in the processing queue. More...
 
int ast_logger_register_level (const char *name)
 Register a new logger level. More...
 
int ast_logger_remove_channel (const char *log_channel)
 Delete the specified log channel. More...
 
int ast_logger_rotate (void)
 Reload logger while rotating log files.
 
int ast_logger_rotate_channel (const char *log_channel)
 Rotate the specified log channel. More...
 
void ast_logger_set_queue_limit (int queue_limit)
 Set the maximum number of messages allowed in the processing queue. More...
 
void ast_logger_unregister_level (const char *name)
 Unregister a previously registered logger level. More...
 
void ast_queue_log (const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt,...)
 
ast_callid ast_read_threadstorage_callid (void)
 extracts the callerid from the thread More...
 
int ast_register_verbose (void(*verboser)(const char *string)) attribute_warn_unused_result
 
unsigned int ast_trace_get_by_module (const char *module)
 Get the trace level for a module. More...
 
int ast_unregister_verbose (void(*verboser)(const char *string)) attribute_warn_unused_result
 
int ast_verb_console_get (void)
 Get this thread's console verbosity level. More...
 
void ast_verb_console_register (int *level)
 Register this thread's console verbosity level pointer. More...
 
void ast_verb_console_set (int verb_level)
 Set this thread's console verbosity level. More...
 
void ast_verb_console_unregister (void)
 Unregister this thread's console verbosity level.
 
void ast_verb_update (void)
 Re-evaluate the system max verbosity level (ast_verb_sys_level).
 

Variables

int ast_verb_sys_level
 

Detailed Description

Support for logging to various files, console and syslog Configuration in file logger.conf.

Definition in file include/asterisk/logger.h.

Macro Definition Documentation

#define ast_debug (   level,
  ... 
)
Value:
do { \
if (DEBUG_ATLEAST(level)) { \
ast_log(AST_LOG_DEBUG, __VA_ARGS__); \
} \
} while (0)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: ael_main.c:130

Log a DEBUG message.

Parameters
levelThe minimum value of option_debug for this message to get logged
Examples:
app_skel.c.

Definition at line 457 of file include/asterisk/logger.h.

Referenced by __analog_handle_event(), __ast_answer(), __ast_channel_alloc_ap(), __ast_pbx_run(), __ast_play_and_record(), __ast_read(), __ast_sorcery_object_type_insert_wizard(), __find_callno(), _ast_device_state(), _pgsql_exec(), access_counter_file(), acf_faxopt_write(), aco_process_config(), action_bridge(), ademco_detect_format(), alarmreceiver_exec(), app_subscribe_bridge(), app_subscribe_channel(), app_subscribe_endpoint(), append_var_and_value_to_filter(), apply_negotiated_sdp_stream(), ast_add_hint(), ast_apply_ha(), ast_ari_asterisk_update_object(), ast_ari_channels_continue_in_dialplan(), ast_ari_websocket_events_event_websocket_attempted(), ast_ari_websocket_events_event_websocket_established(), ast_ari_websocket_session_read(), ast_audiohook_set_frame_feed_direction(), ast_audiohook_write_frame(), ast_autochan_destroy(), ast_autochan_new_channel(), ast_autochan_setup(), ast_autoservice_start(), ast_autoservice_stop(), ast_bridge_channel_establish_roles(), ast_bridge_channel_feature_digit(), ast_bridge_channel_kick(), ast_bridge_channel_leave_bridge_nolock(), ast_bridge_channel_restore_formats(), ast_bridge_depart(), ast_bridge_destroy(), ast_bridge_features_enable(), ast_bridge_interval_hook(), ast_bridge_remove(), ast_bridge_setup_after_goto(), ast_calendar_clear_events(), ast_carefulwrite(), ast_cdr_backend_suspend(), ast_cdr_backend_unsuspend(), ast_cdr_engine_term(), ast_cdr_fork(), ast_channel_add_bridge_role(), ast_channel_audiohook_count_by_source(), ast_channel_audiohook_count_by_source_running(), ast_channel_callid_set(), ast_channel_clear_bridge_roles(), ast_channel_destructor(), ast_channel_inherit_variables(), ast_channel_register(), ast_channel_remove_bridge_role(), ast_channel_request_stream_topology_change(), ast_channel_softhangup_withcause_locked(), ast_channel_start_silence_generator(), ast_channel_stop_silence_generator(), ast_channel_unregister(), ast_check_hangup(), ast_check_signature_bin(), ast_config_text_file_save2(), ast_connected_line_parse_data(), ast_context_add_include2(), ast_context_find_or_create(), ast_data_buffer_put(), ast_db_del(), ast_dial_run(), ast_dns_get_nameservers(), ast_dns_resolve_ipv6_and_ipv4(), ast_dns_resolver_add_record(), ast_dns_resolver_set_result(), ast_dnsmgr_release(), ast_do_pickup(), ast_dsp_busydetect(), ast_dsp_process(), ast_dsp_set_busy_pattern(), ast_find_ourip(), ast_format_cap_update_by_allow_disallow(), ast_get_encoded_char(), ast_get_enum(), ast_get_srv(), ast_get_txt(), ast_hangup(), ast_http_body_discard(), ast_http_create_response(), ast_http_get_contents(), ast_http_send(), ast_iax2_new(), ast_io_add(), ast_io_dump(), ast_io_wait(), ast_iostream_write(), ast_json_utf8_check_len(), ast_load_resource(), ast_logger_unregister_level(), ast_media_cache_retrieve(), ast_media_index_update_for_file(), ast_msg_has_destination(), ast_odbc_find_table(), ast_odbc_release_obj(), ast_ouraddrfor(), ast_parse_arg(), ast_pbx_h_exten_run(), ast_pickup_call(), ast_prod(), ast_realtime_is_mapping_defined(), ast_redirecting_parse_data(), ast_rtcp_interpret(), ast_rtp_codecs_payloads_set_m_type(), ast_rtp_codecs_payloads_unset(), ast_rtp_codecs_payloads_xover(), ast_rtp_dtmf_begin(), ast_rtp_instance_early_bridge(), ast_rtp_instance_early_bridge_make_compatible(), ast_rtp_instance_new(), ast_rtp_read(), ast_say_date_with_format_da(), ast_say_date_with_format_de(), ast_say_date_with_format_en(), ast_say_date_with_format_es(), ast_say_date_with_format_fr(), ast_say_date_with_format_gr(), ast_say_date_with_format_he(), ast_say_date_with_format_it(), ast_say_date_with_format_nl(), ast_say_date_with_format_pl(), ast_say_date_with_format_pt(), ast_say_date_with_format_th(), ast_say_date_with_format_vi(), ast_say_date_with_format_zh(), ast_say_enumeration_full_da(), ast_say_enumeration_full_de(), ast_say_enumeration_full_en(), ast_say_enumeration_full_is(), ast_say_number_full_da(), ast_say_number_full_de(), ast_say_number_full_en_GB(), ast_say_number_full_es(), ast_say_number_full_fr(), ast_say_number_full_gr(), ast_say_number_full_hu(), ast_say_number_full_is(), ast_say_number_full_it(), ast_say_number_full_nl(), ast_say_number_full_no(), ast_say_number_full_ru(), ast_say_number_full_se(), ast_say_number_full_zh(), ast_sched_add_variable(), ast_sched_del_nonrunning(), ast_sched_runq(), ast_sched_wait(), ast_sched_when(), ast_sdp_srtp_alloc(), ast_search_dns(), ast_search_dns_ex(), ast_senddigit_begin(), ast_sendtext_data(), ast_set_default_eid(), ast_set_read_format_path(), ast_set_write_format_path(), ast_sip_get_distributor_serializer(), ast_sip_transport_monitor_register_replace_key(), ast_sockaddr_pj_sockaddr_cmp(), ast_sockaddr_resolve_first_af(), ast_sockaddr_split_hostport(), ast_softhangup_nolock(), ast_sorcery_is_stale(), ast_sorcery_objectset_json_create(), ast_ssl_init(), ast_str_retrieve_variable(), ast_str_substitute_variables_full2(), ast_stream_rewind(), ast_streamfile(), ast_tcptls_client_create(), ast_tcptls_close_session_file(), ast_tcptls_server_start(), ast_tcptls_server_stop(), ast_translate(), ast_translator_best_choice(), ast_unreal_hangup(), ast_uuid_init(), ast_websocket_write(), ast_write_stream(), ast_writestream(), ast_xml_query(), ast_xml_query_with_namespaces(), attended_transfer_monitor_thread(), attended_transfer_properties_alloc(), attended_transfer_properties_shutdown(), atxfer_abort(), atxfer_complete(), atxfer_swap(), atxfer_threeway(), atxfer_transferer_hangup(), auto_unload_resource(), bridge_agent_hold_push(), bridge_base_init(), calc_metric(), callerid_feed(), callerid_feed_jp(), callerid_get_dtmf(), cdr_object_create_public_records(), cdr_object_finalize(), chan_pjsip_digit_end(), chan_pjsip_read_stream(), chan_pjsip_sendtext_data(), chan_pjsip_set_rtp_peer(), change_outgoing_sdp_stream_media_address(), change_priority_caller_on_queue(), channel_do_masquerade(), check_password(), check_srcaddr(), cleaned_basedn(), conf_change_state(), conf_send_event_to_participants(), conf_update_user_mute(), confbridge_handle_atxfer(), config_ldap(), config_text_file_load(), console_read(), control_silence_stop_now(), control_swap_channel_in_bridge(), coreshowchannelmap_add_connected_channels(), create_followme_number(), create_outgoing_sdp_stream(), create_vmaccount(), crypto_load(), dahdi_answer(), dahdi_setoption(), defer_incoming_sdp_stream(), destroy_conference_bridge(), device_state_cb(), dial_bridge_after_cb(), dial_exec_full(), dns_system_resolver_process_query(), do_register(), do_register_expire(), do_say(), do_state_change(), dtmf_store_framehook(), fax_detect_framehook(), fax_gateway_detect_t38(), fax_gateway_detect_v21(), fax_gateway_framehook(), fax_gateway_request_t38(), fax_session_new(), fax_session_reserve(), feature_attended_transfer(), feature_blind_transfer(), filter(), find_best_technology(), find_load_queue_rt_friendly(), find_queue_by_name_rt(), generic_fax_exec(), generic_http_callback(), get_input(), get_member_status(), getproviderstate(), graceful_unload_possible(), handle_attended_transfer(), handle_blind_transfer(), handle_channel_snapshot_update_message(), handle_cli_agi_add_cmd(), handle_getoption(), handle_jack_audio(), handle_output(), handle_response_brsf(), handle_response_ciev(), handle_response_cind(), handle_response_cmgr(), handle_response_cmti(), handle_response_error(), handle_response_ok(), handle_response_ring(), handle_sms_prompt(), hangup_cause2sip(), hfp_parse_ciev(), hfp_parse_cind_indicator(), hfp_parse_cind_test(), hfp_parse_clip(), hfp_parse_cmti(), hfp_parse_ecav(), iax2_devicestate(), iax2_lock_callno_unless_destroyed(), ilbctolin_framein(), indicate_data_internal(), init_convolve_channel_pair(), io_grow(), is_our_turn(), is_read_allowed(), is_write_allowed(), jingle_action_session_terminate(), jingle_queue_hangup_with_cause(), jingle_read(), join_conference_bridge(), last_message_index(), ldap_loadentry(), ldap_reconnect(), leave_queue(), leave_voicemail(), lintospeex_feedback(), load_config(), load_modules(), load_resource_list(), local_devicestate(), log_events(), lua_find_extension(), lua_pbx_exec(), make_email_file(), make_trunk(), manager_modulecheck(), manager_show_dialplan_helper(), matrix_rebuild(), mbl_load_adapter(), mbl_load_device(), message_template_parse_filebody(), messaging_app_subscribe_endpoint(), messaging_app_unsubscribe_endpoint(), minivm_accmess_exec(), modules_shutdown(), native_rtp_bridge_join(), negotiate_incoming_sdp_stream(), object_type_loaded_observer(), parking_notify_metermaids(), parse_config(), parse_dial_string(), parse_naptr(), pbx_extension_helper(), pbx_substitute_variables_helper_full_location(), peer_set_srcaddr(), pgsql_exec(), pri_queue_for_destruction(), process_events(), process_message(), prometheus_metric_register(), prometheus_metric_unregister(), queue_exec(), queue_set_param(), read_mf_digits(), read_sf_digits(), really_quit(), realtime_ldap_base_ap(), realtime_ldap_entry_to_var(), realtime_ldap_result_to_vars(), realtime_peer(), receive_ademco_event(), receive_dtmf_digits(), receivefax_exec(), reload_followme(), reload_queue_members(), request_withdraw_caller_from_queue(), rfcomm_write_full(), ring_one(), rqm_exec(), rtp_raw_write(), run_agi(), run_externnotify(), save_to_folder(), scan_service(), schedule_delivery(), sco_accept(), semicolon_count_var(), send_cluster_notify(), sendfax_exec(), set_config(), sig_pri_call(), sla_find_trunk_ref_byname(), sla_queue_event_conf(), softmix_bridge_destroy(), softmix_bridge_join(), sorcery_astdb_filter_objectset(), sorcery_realtime_filter_objectset(), sorcery_wizard_create(), sorcery_wizard_delete(), sorcery_wizard_update(), spandsp_fax_read(), stasis_app_control_add_channel_to_bridge(), stasis_app_control_answer(), stasis_app_control_play_uri(), stasis_app_control_record(), stasis_app_control_remove_channel_from_bridge(), stasis_app_device_state_update(), stasis_app_exec(), stasis_app_subscribe_channel(), stasis_message_type_declined(), stasis_state_remove_publish_by_id(), stasis_state_subscribe_pool(), stasis_topic_create_with_detail(), store_next_lin(), store_next_rr(), stream_monitor(), substituted(), t30_phase_e_handler(), t38_automatic_reject(), t38_change_state(), t38_framehook(), t38_initialize_session(), t38_reinvite_response_cb(), trace_cb(), transfer_target_framehook_cb(), transport_state_callback(), try_load_key(), unref_mansession(), update_qe_rule(), user_alloc(), user_dtor(), vm_change_password(), wait_for_answer(), websocket_echo_callback(), wizard_mapped_observer(), write_metadata(), xfer_client_on_evsub_state(), xml_translate(), xmpp_client_receive(), xmpp_client_reconnect(), xmpp_client_requested_tls(), xmpp_client_thread(), xmpp_component_service_discovery_get_hook(), xmpp_pak_message(), xmpp_ping_request(), and xmpp_pubsub_handle_event().

#define ast_log_dynamic_level (   level,
  ... 
)    ast_log(level, _A_, __VA_ARGS__)

Send a log message to a dynamically registered log level.

Parameters
levelThe log level to send the message to

Like ast_log, the log message may include printf-style formats, and the data for these must be provided as additional parameters after the log message.

Since
1.8

Definition at line 444 of file include/asterisk/logger.h.

Referenced by ast_cc_agent_set_interfaces_chanvar(), ast_cc_call_init(), ast_cc_monitor_count(), ast_fax_log(), ast_handle_cc_control_frame(), ast_set_cc_interfaces_chanvar(), history_on_rx_msg(), and history_on_tx_msg().

#define ast_verb (   level,
  ... 
)
Value:
do { \
if (VERBOSITY_ATLEAST(level) ) { \
__ast_verbose(_A_, level, __VA_ARGS__); \
} \
} while (0)
void __ast_verbose(const char *file, int line, const char *func, int level, const char *fmt,...)
Send a verbose message (based on verbose level)
Definition: logger.c:2550

Definition at line 468 of file include/asterisk/logger.h.

#define ast_verb_callid (   level,
  callid,
  ... 
)
Value:
do { \
if (VERBOSITY_ATLEAST(level) ) { \
__ast_verbose_callid(_A_, level, callid, __VA_ARGS__); \
} \
} while (0)
void __ast_verbose_callid(const char *file, int line, const char *func, int level, ast_callid callid, const char *fmt,...)
Send a verbose message (based on verbose level) with deliberately specified callid.
Definition: logger.c:2562

Definition at line 475 of file include/asterisk/logger.h.

#define DEBUG_ATLEAST (   level)
Value:
(option_debug >= (level) \
|| (ast_opt_dbg_module \
&& ((int)ast_debug_get_by_module(AST_MODULE) >= (level) \
|| (int)ast_debug_get_by_module(__FILE__) >= (level))))
int option_debug
Definition: options.c:69
unsigned int ast_debug_get_by_module(const char *module)
Get the debug level for a module.
Definition: main/cli.c:136

Definition at line 446 of file include/asterisk/logger.h.

#define DEBUG_M (   a)
Value:
{ \
a; \
}

Definition at line 38 of file include/asterisk/logger.h.

Enumeration Type Documentation

Enumerator
AST_LOGGER_SUCCESS 

Log channel was created or deleted successfully

AST_LOGGER_FAILURE 

Log channel already exists for create or doesn't exist for deletion of log channel

AST_LOGGER_DECLINE 

Log channel request was not accepted

AST_LOGGER_ALLOC_ERROR 

filename allocation error

Definition at line 57 of file include/asterisk/logger.h.

57  {
58  AST_LOGGER_SUCCESS = 0, /*!< Log channel was created or deleted successfully*/
59  AST_LOGGER_FAILURE = 1, /*!< Log channel already exists for create or doesn't exist for deletion of log channel */
60  AST_LOGGER_DECLINE = -1, /*!< Log channel request was not accepted */
61  AST_LOGGER_ALLOC_ERROR = -2 /*!< filename allocation error */
62 };

Function Documentation

void __ast_verbose ( const char *  file,
int  line,
const char *  func,
int  level,
const char *  fmt,
  ... 
)

Send a verbose message (based on verbose level)

This works like ast_log, but prints verbose messages to the console depending on verbosity level set.

ast_verbose(VERBOSE_PREFIX_3 "Whatever %s is happening\n", "nothing");

This will print the message to the console if the verbose level is set to a level >= 3

Note the absence of a comma after the VERBOSE_PREFIX_3. This is important. VERBOSE_PREFIX_1 through VERBOSE_PREFIX_10 are defined.

Version
11 added level parameter

Definition at line 2550 of file logger.c.

2551 {
2552  ast_callid callid;
2553  va_list ap;
2554 
2555  callid = ast_read_threadstorage_callid();
2556 
2557  va_start(ap, fmt);
2558  __ast_verbose_ap(file, line, func, level, callid, fmt, ap);
2559  va_end(ap);
2560 }
ast_callid ast_read_threadstorage_callid(void)
extracts the callerid from the thread
Definition: logger.c:2298
void __ast_verbose_callid ( const char *  file,
int  line,
const char *  func,
int  level,
ast_callid  callid,
const char *  fmt,
  ... 
)

Send a verbose message (based on verbose level) with deliberately specified callid.

just like __ast_verbose, only __ast_verbose_callid allows you to specify which callid is being used for the log without needing to bind it to a thread. NULL is a valid argument for this function and will allow you to specify that a log will never display a call id even when there is a call id bound to the thread.

Definition at line 2562 of file logger.c.

2563 {
2564  va_list ap;
2565  va_start(ap, fmt);
2566  __ast_verbose_ap(file, line, func, level, callid, fmt, ap);
2567  va_end(ap);
2568 }
void ast_callid_strnprint ( char *  buffer,
size_t  buffer_size,
ast_callid  callid 
)

copy a string representation of the callid into a target string

Parameters
bufferdestination of callid string (should be able to store 13 characters or more)
buffer_sizemaximum writable length of the string (Less than 13 will result in truncation)
callidCallid for which string is being requested

Definition at line 2288 of file logger.c.

Referenced by ast_channel_callid_set(), and handle_showchan().

2289 {
2290  snprintf(buffer, buffer_size, "[C-%08x]", callid);
2291 }
int ast_callid_threadassoc_add ( ast_callid  callid)

Adds a known callid to thread storage of the calling thread.

Return values
0- success
non-zero- failure

Definition at line 2320 of file logger.c.

References ast_log(), and ast_threadstorage_get().

Referenced by __ast_pbx_run(), ast_callid_threadstorage_auto(), async_dial(), attended_transfer_monitor_thread(), bridge_channel_depart_thread(), bridge_channel_ind_thread(), jingle_action_hook(), and jingle_outgoing_hook().

2321 {
2322  ast_callid *pointing;
2323 
2324  pointing = ast_threadstorage_get(&unique_callid, sizeof(*pointing));
2325  if (!pointing) {
2326  return -1;
2327  }
2328 
2329  if (*pointing) {
2330  ast_log(LOG_ERROR, "ast_callid_threadassoc_add(C-%08x) on thread "
2331  "already associated with callid [C-%08x].\n", callid, *pointing);
2332  return 1;
2333  }
2334 
2335  *pointing = callid;
2336  return 0;
2337 }
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:2453
int ast_callid_threadassoc_change ( ast_callid  callid)

Sets what is stored in the thread storage to the given callid if it does not match what is already there.

Return values
0- success
non-zero- failure

Definition at line 2307 of file logger.c.

References ast_threadstorage_get().

2308 {
2309  ast_callid *id = ast_threadstorage_get(&unique_callid, sizeof(*id));
2310 
2311  if (!id) {
2312  return -1;
2313  }
2314 
2315  *id = callid;
2316 
2317  return 0;
2318 }
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
int ast_callid_threadassoc_remove ( void  )

Removes callid from thread storage of the calling thread.

Return values
0- success
non-zero- failure

Definition at line 2339 of file logger.c.

References ast_threadstorage_get().

Referenced by ast_callid_threadstorage_auto_clean(), attended_transfer_monitor_thread(), jingle_action_hook(), and jingle_outgoing_hook().

2340 {
2341  ast_callid *pointing;
2342 
2343  pointing = ast_threadstorage_get(&unique_callid, sizeof(*pointing));
2344  if (!pointing) {
2345  return -1;
2346  }
2347 
2348  if (*pointing) {
2349  *pointing = 0;
2350  return 0;
2351  }
2352 
2353  return -1;
2354 }
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
int ast_callid_threadstorage_auto ( ast_callid *  callid)

Checks thread storage for a callid and stores a reference if it exists. If not, then a new one will be created, bound to the thread, and a reference to it will be stored.

Parameters
callidpointer to store the callid
Return values
0- callid was found
1- callid was created
-1- the function failed somehow (presumably memory problems)

Definition at line 2356 of file logger.c.

References ast_callid_threadassoc_add(), ast_create_callid(), and ast_read_threadstorage_callid().

Referenced by __analog_handle_event().

2357 {
2358  ast_callid tmp;
2359 
2360  /* Start by trying to see if a callid is available from thread storage */
2362  if (tmp) {
2363  *callid = tmp;
2364  return 0;
2365  }
2366 
2367  /* If that failed, try to create a new one and bind it. */
2368  *callid = ast_create_callid();
2369  if (*callid) {
2370  ast_callid_threadassoc_add(*callid);
2371  return 1;
2372  }
2373 
2374  /* If neither worked, then something must have gone wrong. */
2375  return -1;
2376 }
ast_callid ast_read_threadstorage_callid(void)
extracts the callerid from the thread
Definition: logger.c:2298
int ast_callid_threadassoc_add(ast_callid callid)
Adds a known callid to thread storage of the calling thread.
Definition: logger.c:2320
ast_callid ast_create_callid(void)
factory function to create a new uniquely identifying callid.
Definition: logger.c:2293
void ast_callid_threadstorage_auto_clean ( ast_callid  callid,
int  callid_created 
)

Use in conjunction with ast_callid_threadstorage_auto. Cleans up the references and if the callid was created by threadstorage_auto, unbinds the callid from the threadstorage.

Parameters
callidThe callid set by ast_callid_threadstorage_auto
callid_createdThe integer returned through ast_callid_threadstorage_auto

Definition at line 2378 of file logger.c.

References ast_callid_threadassoc_remove().

Referenced by __analog_handle_event().

2379 {
2380  if (callid && callid_created) {
2381  /* If the callid was created rather than simply grabbed from the thread storage, we need to unbind here. */
2383  }
2384 }
int ast_callid_threadassoc_remove(void)
Removes callid from thread storage of the calling thread.
Definition: logger.c:2339
void ast_console_puts_mutable ( const char *  string,
int  level 
)

log the string to the console, and all attached console clients

Parameters
stringThe message to write to the console
levelThe log level of the message
Version
1.6.1 added level parameter

log the string to the console, and all attached console clients

Definition at line 1316 of file asterisk.c.

References ast_console_puts_mutable_full().

Referenced by init_logger_chain().

1317 {
1318  ast_console_puts_mutable_full(string, level, 0);
1319 }
void ast_console_puts_mutable_full(const char *message, int level, int sublevel)
log the string to the console, and all attached console clients
Definition: asterisk.c:1323
void ast_console_puts_mutable_full ( const char *  message,
int  level,
int  sublevel 
)

log the string to the console, and all attached console clients

Since
14.0.0
Parameters
messageThe message to write to the console
sublevelIf the log level supports it, the sub-level of the message
levelThe log level of the message

Definition at line 1323 of file asterisk.c.

References ast_network_puts_mutable().

Referenced by ast_console_puts_mutable(), and logger_print_normal().

1324 {
1325  /* Send to the root console */
1326  console_print(message);
1327 
1328  /* Wake up a poll()ing console */
1329  if (ast_opt_console && consolethread != AST_PTHREADT_NULL) {
1330  pthread_kill(consolethread, SIGURG);
1331  }
1332 
1333  /* Send to any network console clients */
1334  ast_network_puts_mutable(message, level, sublevel);
1335 }
static void ast_network_puts_mutable(const char *string, int level, int sublevel)
log the string to all attached network console clients
Definition: asterisk.c:1297
void ast_console_toggle_loglevel ( int  fd,
int  level,
int  state 
)

enables or disables logging of a specified level to the console fd specifies the index of the console receiving the level change level specifies the index of the logging level being toggled state indicates whether logging will be on or off (0 for off, 1 for on)

enables or disables logging of a specified level to the console fd specifies the index of the console receiving the level change level specifies the index of the logging level being toggled state indicates whether logging will be on or off (0 for off, 1 for on)

Definition at line 1251 of file asterisk.c.

References console::levels.

1252 {
1253  int x;
1254 
1255  if (level >= NUMLOGLEVELS) {
1256  level = NUMLOGLEVELS - 1;
1257  }
1258 
1259  for (x = 0;x < AST_MAX_CONNECTS; x++) {
1260  if (fd == consoles[x].fd) {
1261  /*
1262  * Since the logging occurs when levels are false, set to
1263  * flipped iinput because this function accepts 0 as off and 1 as on
1264  */
1265  consoles[x].levels[level] = state ? 0 : 1;
1266  return;
1267  }
1268  }
1269 }
int levels[NUMLOGLEVELS]
Definition: asterisk.c:326
ast_callid ast_create_callid ( void  )

factory function to create a new uniquely identifying callid.

Returns
The call id

Definition at line 2293 of file logger.c.

References ast_atomic_fetchadd_int().

Referenced by __ast_pbx_run(), ast_callid_threadstorage_auto(), and jingle_alloc().

2294 {
2295  return ast_atomic_fetchadd_int(&next_unique_callid, +1);
2296 }
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
Definition: lock.h:757
unsigned int ast_debug_get_by_module ( const char *  module)

Get the debug level for a module.

Parameters
modulethe name of module
Returns
the debug level

Definition at line 136 of file main/cli.c.

References AST_LIST_TRAVERSE, AST_RWLIST_RDLOCK, and AST_RWLIST_UNLOCK.

137 {
138  struct module_level *ml;
139  unsigned int res = 0;
140 
143  if (!strcasecmp(ml->module, module)) {
144  res = ml->level;
145  break;
146  }
147  }
149 
150  return res;
151 }
static struct module_level_list debug_modules
Definition: main/cli.c:107
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:78
map a debug or verbose level to a module name
Definition: main/cli.c:98
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
Definition: search.h:40
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
int ast_is_logger_initialized ( void  )

Test if logger is initialized.

Return values
trueif the logger is initialized

Definition at line 2175 of file logger.c.

2176 {
2177  return logger_initialized;
2178 }
static void ast_log ( int  level,
const char *  file,
int  line,
const char *  function,
const char *  fmt,
  ... 
)

Used for sending a log message This is the standard logger function. Probably the only way you will invoke it would be something like this: ast_log(AST_LOG_WHATEVER, "Problem with the %s Captain. We should get some more. Will %d be enough?\n", "flux capacitor", 10); where WHATEVER is one of ERROR, DEBUG, EVENT, NOTICE, or WARNING depending on which log you wish to output to. These are implemented as macros, that will provide the function with the needed arguments.

Parameters
levelType of log event
fileWill be provided by the AST_LOG_* macro
lineWill be provided by the AST_LOG_* macro
functionWill be provided by the AST_LOG_* macro
fmtThis is what is important. The format is the same as your favorite breed of printf. You know how that works, right? :-)

Definition at line 130 of file ael_main.c.

Referenced by ast_callid_threadassoc_add(), ast_log_backtrace(), and init_logger().

131 {
132  va_list vars;
133  va_start(vars,fmt);
134 
135  printf("LOG: lev:%d file:%s line:%d func: %s ",
136  level, file, line, function);
137  vprintf(fmt, vars);
138  fflush(stdout);
139  va_end(vars);
140 }
void ast_log_callid ( int  level,
const char *  file,
int  line,
const char *  function,
ast_callid  callid,
const char *  fmt,
  ... 
)

Used for sending a log message with a known call_id This is a modified logger function which is functionally identical to the above logger function, it just include a call_id argument as well. If NULL is specified here, no attempt will be made to join the log message with a call_id.

Parameters
levelType of log event
fileWill be provided by the AST_LOG_* macro
lineWill be provided by the AST_LOG_* macro
functionWill be provided by the AST_LOG_* macro
callidThis is the ast_callid that is associated with the log message. May be NULL.
fmtThis is what is important. The format is the same as your favorite breed of printf. You know how that works, right? :-)

Definition at line 2501 of file logger.c.

References ast_log_full().

Referenced by ast_channel_destructor().

2502 {
2503  va_list ap;
2504  va_start(ap, fmt);
2505  ast_log_full(level, -1, file, line, function, callid, fmt, ap);
2506  va_end(ap);
2507 }
static void ast_log_full(int level, int sublevel, const char *file, int line, const char *function, ast_callid callid, const char *fmt, va_list ap)
send log messages to syslog and/or the console
Definition: logger.c:2389
void ast_log_safe ( int  level,
const char *  file,
int  line,
const char *  function,
const char *  fmt,
  ... 
)

Used for sending a log message with protection against recursion.

Note
This function should be used by all error messages that might be directly or indirectly caused by logging.
See also
ast_log for documentation on the parameters.

Definition at line 2475 of file logger.c.

References ast_log_full(), ast_read_threadstorage_callid(), ast_threadstorage_get_ptr(), and ast_threadstorage_set_ptr().

Referenced by __ast_str_helper(), and ast_log_backtrace().

2476 {
2477  va_list ap;
2478  void *recursed = ast_threadstorage_get_ptr(&in_safe_log);
2479  ast_callid callid;
2480 
2481  if (recursed) {
2482  return;
2483  }
2484 
2485  if (ast_threadstorage_set_ptr(&in_safe_log, &(int) { 1 })) {
2486  /* We've failed to set the flag that protects against
2487  * recursion, so bail. */
2488  return;
2489  }
2490 
2491  callid = ast_read_threadstorage_callid();
2492 
2493  va_start(ap, fmt);
2494  ast_log_full(level, -1, file, line, function, callid, fmt, ap);
2495  va_end(ap);
2496 
2497  /* Clear flag so the next allocation failure can be logged. */
2498  ast_threadstorage_set_ptr(&in_safe_log, NULL);
2499 }
int ast_threadstorage_set_ptr(struct ast_threadstorage *ts, void *ptr)
Set a raw pointer from threadstorage.
ast_callid ast_read_threadstorage_callid(void)
extracts the callerid from the thread
Definition: logger.c:2298
void * ast_threadstorage_get_ptr(struct ast_threadstorage *ts)
Retrieve a raw pointer from threadstorage.
static void ast_log_full(int level, int sublevel, const char *file, int line, const char *function, ast_callid callid, const char *fmt, va_list ap)
send log messages to syslog and/or the console
Definition: logger.c:2389
int ast_logger_create_channel ( const char *  log_channel,
const char *  components 
)

Create a log channel.

Parameters
log_channelLog channel to create
componentsLogging config levels to add to the log channel

Definition at line 1521 of file logger.c.

References AST_LOGGER_ALLOC_ERROR, AST_LOGGER_DECLINE, AST_LOGGER_FAILURE, AST_LOGGER_SUCCESS, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, find_logchannel(), logchannel::list, and logchannel::logmask.

Referenced by ast_ari_asterisk_add_log().

1522 {
1523  struct logchannel *chan;
1524 
1525  if (ast_strlen_zero(components)) {
1526  return AST_LOGGER_DECLINE;
1527  }
1528 
1530 
1531  chan = find_logchannel(log_channel);
1532  if (chan) {
1534  return AST_LOGGER_FAILURE;
1535  }
1536 
1537  chan = make_logchannel(log_channel, components, 0, 1);
1538  if (!chan) {
1540  return AST_LOGGER_ALLOC_ERROR;
1541  }
1542 
1543  AST_RWLIST_INSERT_HEAD(&logchannels, chan, list);
1544  global_logmask |= chan->logmask;
1545 
1547 
1548  return AST_LOGGER_SUCCESS;
1549 }
char components[0]
Definition: logger.c:162
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:52
unsigned int logmask
Definition: logger.c:142
static struct logchannel * find_logchannel(const char *channel)
Find a particular logger channel by name.
Definition: logger.c:630
struct logchannel::@372 list
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
int ast_logger_get_channels ( int(*)(const char *channel, const char *type, const char *status, const char *configuration, void *data)  logentry,
void *  data 
)

Retrieve the existing log channels.

Parameters
logentryA callback to an updater function
dataData passed into the callback for manipulation

For each of the logging channels, logentry will be executed with the channel file name, log type, status of the log, and configuration levels.

Return values
0on success
1on failure
-2on allocation error

Definition at line 1409 of file logger.c.

References AST_LOGGER_ALLOC_ERROR, AST_LOGGER_FAILURE, AST_LOGGER_SUCCESS, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_str_append(), ast_str_buffer(), ast_str_create, ast_str_reset(), logchannel::disabled, logchannel::filename, logchannel::list, logchannel::logmask, and logchannel::type.

Referenced by ast_ari_asterisk_list_log_channels().

1411 {
1412  struct logchannel *chan;
1413  struct ast_str *configs = ast_str_create(64);
1414  int res = AST_LOGGER_SUCCESS;
1415 
1416  if (!configs) {
1417  return AST_LOGGER_ALLOC_ERROR;
1418  }
1419 
1421  AST_RWLIST_TRAVERSE(&logchannels, chan, list) {
1422  unsigned int level;
1423 
1424  ast_str_reset(configs);
1425 
1426  for (level = 0; level < ARRAY_LEN(levels); level++) {
1427  if ((chan->logmask & (1 << level)) && levels[level]) {
1428  ast_str_append(&configs, 0, "%s ", levels[level]);
1429  }
1430  }
1431 
1432  res = logentry(chan->filename, chan->type == LOGTYPE_CONSOLE ? "Console" :
1433  (chan->type == LOGTYPE_SYSLOG ? "Syslog" : "File"), chan->disabled ?
1434  "Disabled" : "Enabled", ast_str_buffer(configs), data);
1435 
1436  if (res) {
1438  ast_free(configs);
1439  configs = NULL;
1440  return AST_LOGGER_FAILURE;
1441  }
1442  }
1444 
1445  ast_free(configs);
1446  configs = NULL;
1447 
1448  return AST_LOGGER_SUCCESS;
1449 }
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:761
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:78
static char * levels[NUMLOGLEVELS]
Logging channels used in the Asterisk logging system.
Definition: logger.c:214
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition: strings.h:1139
unsigned int logmask
Definition: logger.c:142
int disabled
Definition: logger.c:144
Support for dynamic strings.
Definition: strings.h:623
enum logtypes type
Definition: logger.c:150
char filename[PATH_MAX]
Definition: logger.c:154
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
Definition: strings.h:693
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition: strings.h:659
const char* ast_logger_get_dateformat ( void  )

Get the logger configured date format.

Returns
The date format string
Since
13.0.0

Definition at line 2927 of file logger.c.

2928 {
2929  return dateformat;
2930 }
int ast_logger_get_dynamic_level ( const char *  name)

Retrieve dynamic logging level id.

Parameters
nameThe name of the level
Returns
The unique integer id for the given level
Return values
-1if level name not found

Definition at line 2880 of file logger.c.

References AST_RWLIST_RDLOCK, and AST_RWLIST_UNLOCK.

2881 {
2882  int level = -1;
2883 
2885 
2886  level = logger_get_dynamic_level(name);
2887 
2889 
2890  return level;
2891 }
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:78
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
int ast_logger_get_queue_limit ( void  )

Get the maximum number of messages allowed in the processing queue.

Returns
Queue limit

Definition at line 2937 of file logger.c.

2938 {
2939  return logger_queue_limit;
2940 }
int ast_logger_register_level ( const char *  name)

Register a new logger level.

Parameters
nameThe name of the level to be registered
Return values
-1if an error occurs
non-zerolevel to be used with ast_log for sending messages to this level
Since
1.8

Definition at line 2851 of file logger.c.

References AST_RWLIST_UNLOCK, and AST_RWLIST_WRLOCK.

Referenced by load_module().

2852 {
2853  int available = 0;
2854 
2856  available = logger_register_level(name);
2858 
2859  return available;
2860 }
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:52
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
int ast_logger_remove_channel ( const char *  log_channel)

Delete the specified log channel.

Parameters
log_channelThe log channel to delete

Definition at line 1587 of file logger.c.

References AST_LOGGER_FAILURE, AST_LOGGER_SUCCESS, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, logchannel::dynamic, logchannel::fileptr, find_logchannel(), and logchannel::list.

Referenced by ast_ari_asterisk_delete_log().

1588 {
1589  struct logchannel *chan;
1590 
1592 
1593  chan = find_logchannel(log_channel);
1594  if (chan && chan->dynamic) {
1595  AST_RWLIST_REMOVE(&logchannels, chan, list);
1596  } else {
1598  return AST_LOGGER_FAILURE;
1599  }
1601 
1602  if (chan->fileptr) {
1603  fclose(chan->fileptr);
1604  chan->fileptr = NULL;
1605  }
1606  ast_free(chan);
1607  chan = NULL;
1608 
1609  return AST_LOGGER_SUCCESS;
1610 }
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:52
int dynamic
Definition: logger.c:160
static struct logchannel * find_logchannel(const char *channel)
Find a particular logger channel by name.
Definition: logger.c:630
struct logchannel::@372 list
FILE * fileptr
Definition: logger.c:152
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
int ast_logger_rotate_channel ( const char *  log_channel)

Rotate the specified log channel.

Parameters
log_channelThe log channel to rotate

Definition at line 1332 of file logger.c.

References AST_LOGGER_FAILURE, AST_LOGGER_SUCCESS, ast_mkdir(), AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, logchannel::disabled, logchannel::filename, logchannel::fileptr, init_logger_chain(), logchannel::list, make_filename(), and manager_event.

Referenced by ast_ari_asterisk_rotate_log().

1333 {
1334  struct logchannel *f;
1335  int success = AST_LOGGER_FAILURE;
1336  char filename[PATH_MAX];
1337 
1338  make_filename(log_channel, filename, sizeof(filename));
1339 
1341 
1342  ast_mkdir(ast_config_AST_LOG_DIR, 0644);
1343 
1344  AST_RWLIST_TRAVERSE(&logchannels, f, list) {
1345  if (f->disabled) {
1346  f->disabled = 0; /* Re-enable logging at reload */
1347  manager_event(EVENT_FLAG_SYSTEM, "LogChannel", "Channel: %s\r\nEnabled: Yes\r\n",
1348  f->filename);
1349  }
1350  if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) {
1351  fclose(f->fileptr); /* Close file */
1352  f->fileptr = NULL;
1353  if (strcmp(filename, f->filename) == 0) {
1354  rotate_file(f->filename);
1355  success = AST_LOGGER_SUCCESS;
1356  }
1357  }
1358  }
1359 
1360  init_logger_chain(NULL);
1361 
1363 
1364  return success;
1365 }
static int init_logger_chain(const char *altconf)
Read config, setup channels.
Definition: logger.c:759
static void make_filename(const char *channel, char *filename, size_t size)
create the filename that will be used for a logger channel.
Definition: logger.c:589
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:52
int disabled
Definition: logger.c:144
struct logchannel::@372 list
FILE * fileptr
Definition: logger.c:152
char filename[PATH_MAX]
Definition: logger.c:154
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
#define manager_event(category, event, contents,...)
External routines may send asterisk manager events this way.
Definition: manager.h:253
int ast_mkdir(const char *path, int mode)
Recursively create directory path.
Definition: utils.c:2479
void ast_logger_set_queue_limit ( int  queue_limit)

Set the maximum number of messages allowed in the processing queue.

Parameters
queue_limit

Definition at line 2932 of file logger.c.

2933 {
2934  logger_queue_limit = queue_limit;
2935 }
void ast_logger_unregister_level ( const char *  name)

Unregister a previously registered logger level.

Parameters
nameThe name of the level to be unregistered
Since
1.8

Definition at line 2909 of file logger.c.

References ast_debug, AST_RWLIST_UNLOCK, and AST_RWLIST_WRLOCK.

Referenced by unload_module().

2910 {
2911  int x;
2912 
2914  x = logger_unregister_level(name);
2915 
2916  if (x) {
2917  update_logchannels();
2918  }
2919 
2921 
2922  if (x) {
2923  ast_debug(1, "Unregistered dynamic logger level '%s' with index %u.\n", name, x);
2924  }
2925 }
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:52
#define ast_debug(level,...)
Log a DEBUG message.
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
ast_callid ast_read_threadstorage_callid ( void  )

extracts the callerid from the thread

Return values
Non-zeroCall id related to the thread
0if no call_id is present in the thread

Definition at line 2298 of file logger.c.

References ast_threadstorage_get().

Referenced by __ast_pbx_run(), __ast_verbose(), ast_callid_threadstorage_auto(), ast_dial_run(), ast_log_safe(), jingle_alloc(), and local_request_with_stream_topology().

2299 {
2300  ast_callid *callid;
2301 
2302  callid = ast_threadstorage_get(&unique_callid, sizeof(*callid));
2303 
2304  return callid ? *callid : 0;
2305 }
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
int ast_verb_console_get ( void  )

Get this thread's console verbosity level.

Returns
verbosity level of the console.

Definition at line 2673 of file logger.c.

References AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_threadstorage_get(), verb_console::level, and option_verbose.

Referenced by handle_show_settings().

2674 {
2675  struct verb_console *console;
2676  int verb_level;
2677 
2678  console = ast_threadstorage_get(&my_verb_console, sizeof(*console));
2680  if (!console) {
2681  verb_level = 0;
2682  } else if (console->level) {
2683  verb_level = *console->level;
2684  } else {
2685  verb_level = option_verbose;
2686  }
2688  return verb_level;
2689 }
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:78
int option_verbose
Definition: options.c:67
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
int * level
Definition: logger.c:2575
void ast_verb_console_register ( int *  level)

Register this thread's console verbosity level pointer.

Parameters
levelWhere the verbose level value is.

Definition at line 2646 of file logger.c.

References AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_threadstorage_get(), ast_verb_update(), and verb_console::level.

2647 {
2648  struct verb_console *console;
2649 
2650  console = ast_threadstorage_get(&my_verb_console, sizeof(*console));
2651  if (!console || !level) {
2652  return;
2653  }
2654  console->level = level;
2655 
2657  AST_RWLIST_INSERT_HEAD(&verb_consoles, console, node);
2659  ast_verb_update();
2660 }
Definition: test_heap.c:38
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
void ast_verb_update(void)
Re-evaluate the system max verbosity level (ast_verb_sys_level).
Definition: logger.c:2584
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:52
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
int * level
Definition: logger.c:2575
void ast_verb_console_set ( int  verb_level)

Set this thread's console verbosity level.

Parameters
verb_levelNew level to set.

Definition at line 2691 of file logger.c.

References AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_threadstorage_get(), ast_verb_update(), verb_console::level, and option_verbose.

2692 {
2693  struct verb_console *console;
2694 
2695  console = ast_threadstorage_get(&my_verb_console, sizeof(*console));
2696  if (!console) {
2697  return;
2698  }
2699 
2701  if (console->level) {
2702  *console->level = verb_level;
2703  } else {
2704  option_verbose = verb_level;
2705  }
2707  ast_verb_update();
2708 }
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
void ast_verb_update(void)
Re-evaluate the system max verbosity level (ast_verb_sys_level).
Definition: logger.c:2584
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:52
int option_verbose
Definition: options.c:67
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
int * level
Definition: logger.c:2575