FreeSWITCH API Documentation  1.7.0
Data Structures | Macros | Typedefs | Functions
Logger Routines
+ Collaboration diagram for Logger Routines:

Data Structures

struct  switch_log_node_t
 Log Data. More...
 

Macros

#define switch_log_check_mask(_mask, _level)   (_mask & ((size_t)1 << _level))
 

Typedefs

typedef switch_status_t(* switch_log_function_t )(const switch_log_node_t *node, switch_log_level_t level)
 

Functions

switch_status_t switch_log_init (_In_ switch_memory_pool_t *pool, _In_ switch_bool_t colorize)
 Initilize the logging engine. More...
 
switch_status_t switch_log_shutdown (void)
 Shut down the logging engine. More...
 
void switch_log_printf (_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
 Write log data to the logging engine. More...
 
void void switch_log_vprintf (_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, const char *fmt, va_list ap)
 Write log data to the logging engine. More...
 
switch_status_t switch_log_bind_logger (_In_ switch_log_function_t function, _In_ switch_log_level_t level, _In_ switch_bool_t is_console)
 Shut down the logging engine. More...
 
switch_status_t switch_log_unbind_logger (_In_ switch_log_function_t function)
 
_Ret_z_ const char * switch_log_level2str (_In_ switch_log_level_t level)
 Return the name of the specified log level. More...
 
switch_log_level_t switch_log_str2level (_In_z_ const char *str)
 Return the level number of the specified log level name. More...
 
uint32_t switch_log_str2mask (_In_z_ const char *str)
 
switch_log_node_tswitch_log_node_dup (const switch_log_node_t *node)
 
void switch_log_node_free (switch_log_node_t **pnode)
 

Detailed Description

Macro Definition Documentation

#define switch_log_check_mask (   _mask,
  _level 
)    (_mask & ((size_t)1 << _level))

Definition at line 144 of file switch_log.h.

Typedef Documentation

typedef switch_status_t(* switch_log_function_t)(const switch_log_node_t *node, switch_log_level_t level)

Definition at line 70 of file switch_log.h.

Function Documentation

switch_status_t switch_log_bind_logger ( _In_ switch_log_function_t  function,
_In_ switch_log_level_t  level,
_In_ switch_bool_t  is_console 
)

Shut down the logging engine.

Note
to be called at application termination by the core
switch_status_t switch_log_init ( _In_ switch_memory_pool_t pool,
_In_ switch_bool_t  colorize 
)

Initilize the logging engine.

Parameters
poolthe memory pool to use
Note
to be called at application startup by the core

Referenced by switch_core_init().

_Ret_z_ const char* switch_log_level2str ( _In_ switch_log_level_t  level)

Return the name of the specified log level.

Parameters
levelthe level
Returns
the name of the log level
switch_log_node_t* switch_log_node_dup ( const switch_log_node_t node)

Definition at line 106 of file switch_log.c.

References switch_log_node_t::data, switch_assert, switch_log_node_alloc(), switch_log_node_t::userdata, and zstr.

107 {
109 
110  *newnode = *node;
111 
112  if (!zstr(node->data)) {
113  newnode->data = strdup(node->data);
114  switch_assert(node->data);
115  }
116 
117  if (!zstr(node->userdata)) {
118  newnode->userdata = strdup(node->userdata);
119  switch_assert(node->userdata);
120  }
121 
122  return newnode;
123 }
Log Data.
Definition: switch_log.h:49
#define zstr(x)
Definition: switch_utils.h:281
static switch_log_node_t * switch_log_node_alloc()
Definition: switch_log.c:88
#define switch_assert(expr)
void switch_log_node_free ( switch_log_node_t **  pnode)

Definition at line 125 of file switch_log.c.

References switch_log_node_t::data, switch_queue_trypush(), switch_safe_free, SWITCH_STATUS_SUCCESS, and switch_log_node_t::userdata.

Referenced by log_thread(), switch_core_memory_reclaim_logger(), and switch_log_vprintf().

126 {
127  switch_log_node_t *node;
128 
129  if (!pnode) {
130  return;
131  }
132 
133  node = *pnode;
134 
135  if (node) {
136  switch_safe_free(node->userdata);
137  switch_safe_free(node->data);
138 #ifdef SWITCH_LOG_RECYCLE
139  if (switch_queue_trypush(LOG_RECYCLE_QUEUE, node) != SWITCH_STATUS_SUCCESS) {
140  free(node);
141  }
142 #else
143  free(node);
144 #endif
145  }
146  *pnode = NULL;
147 }
Log Data.
Definition: switch_log.h:49
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:789
switch_status_t switch_queue_trypush(switch_queue_t *queue, void *data)
Definition: switch_apr.c:1155
void switch_log_printf ( _In_ switch_text_channel_t  channel,
_In_z_ const char *  file,
_In_z_ const char *  func,
_In_ int  line,
_In_opt_z_ const char *  userdata,
_In_ switch_log_level_t  level,
_In_z_ _Printf_format_string_ const char *  fmt,
  ... 
)

Write log data to the logging engine.

Parameters
channelthe log channel to write to
filethe current file
functhe current function
linethe current line
userdataununsed
levelthe current log level
fmtdesired format
...variable args
Note
there are channel macros to supply the first 4 parameters (SWITCH_CHANNEL_LOG, SWITCH_CHANNEL_LOG_CLEAN, ...)
See also
switch_types.h

Referenced by _switch_cache_db_get_db_handle(), _switch_core_media_pass_zrtp_hash2(), Event::addBody(), Event::addHeader(), api_hook(), audio_bridge_on_consume_media(), audio_bridge_on_routing(), audio_bridge_thread(), EventConsumer::bind(), IVRMenu::bindAction(), bridge(), chat_thread_run(), check_channel_status(), check_dtls_reinvite(), check_ice(), check_jb(), check_jb_sync(), check_jitter(), check_queue(), check_rtcp_and_ice(), collect_thread_run(), console_clean_log(), console_log(), console_log2(), console_xml_config(), CoreSession::consoleLog(), CoreSession::consoleLog2(), core_event_handler(), Event::delHeader(), CoreSession::destroy(), do_2833(), do_api_on(), do_chat_send(), do_dtls(), do_flush(), do_mos(), do_shutdown(), do_trans(), dtls_state_handshake(), dtls_state_setup(), early_thread_run(), eavesdrop_callback(), enable_local_rtcp_socket(), enable_remote_rtcp_socket(), Event::Event(), event_handler(), exec_cb(), API::execute(), CoreSession::execute(), API::executeString(), Event::fire(), freeswitch_kill_background(), fs_consol_clean(), fs_consol_log(), fs_switch_ivr_originate(), generate_m(), get_backend(), get_pmp_pubaddr(), get_upnp_pubaddr(), Event::getBody(), CoreSession::getDigits(), Event::getHeader(), Event::getType(), handle_ice(), handle_nack(), handle_rfc2833(), CoreSession::hangup(), hanguphook(), ice_out(), inband_dtmf_callback(), inband_dtmf_generate_callback(), inherit_codec(), init_nat_monitor(), init_upnp(), ip_choose_family(), is_valid_action(), limit_state_handler(), load_configuration(), meta_on_dtmf(), monitor_callback(), next_cpu(), CoreSession::originate(), play_and_collect(), play_and_detect_input_callback(), pool_thread(), preprocess(), preprocess_exec(), preprocess_exec_set(), preprocess_glob(), process_device_hup(), process_rtcp_packet(), process_rtcp_report(), read_rtcp_packet(), read_rtp_packet(), record_callback(), recording_thread(), recover_callback(), rtcp_generate_report_block(), rtcp_generate_sender_info(), rtcp_stats(), rtcp_stats_init(), rtp_common_read(), rtp_common_write(), rtp_write_ready(), CoreSession::say(), CoreSession::sayPhrase(), set_dtmf_delay(), CoreSession::set_tts_parms(), CoreSession::setHangupHook(), Event::setPriority(), setup_ringback(), CoreSession::setVariable(), signal_bridge_on_hibernate(), CoreSession::speak(), speech_callback(), speech_on_dtmf(), speech_thread(), sql_close(), sql_in_thread(), switch_cache_db_execute_sql2str(), switch_cache_db_execute_sql_callback(), switch_cache_db_execute_sql_callback_err(), switch_cache_db_execute_sql_event_callback(), switch_cache_db_execute_sql_event_callback_err(), switch_cache_db_execute_sql_real(), switch_cache_db_load_extension(), switch_cache_db_persistant_execute(), switch_cache_db_persistant_execute_trans_full(), switch_cache_db_test_reactive(), switch_caller_extension_add_application(), switch_caller_extension_add_application_printf(), switch_channel_add_variable_var_check(), switch_channel_check_device_state(), switch_channel_check_zrtp(), switch_channel_clear_device_record(), switch_channel_dequeue_dtmf(), switch_channel_expand_variables_check(), switch_channel_export_variable_var_check(), switch_channel_flip_cid(), switch_channel_handle_cause(), switch_channel_invert_cid(), switch_channel_perform_answer(), switch_channel_perform_hangup(), switch_channel_perform_mark_answered(), switch_channel_perform_mark_pre_answered(), switch_channel_perform_mark_ring_ready_value(), switch_channel_perform_ring_ready_value(), switch_channel_perform_set_callstate(), switch_channel_perform_set_running_state(), switch_channel_perform_set_state(), switch_channel_process_export(), switch_channel_queue_dtmf(), switch_channel_queue_dtmf_string(), switch_channel_set_device_id(), switch_channel_set_name(), switch_channel_set_variable_var_check(), switch_console_complete(), switch_console_execute(), switch_console_expand_alias(), switch_console_list_uuid(), switch_console_loop(), switch_console_save_history(), switch_console_set_alias(), switch_console_stream_write(), switch_core_asr_feed(), switch_core_asr_open(), switch_core_cert_extract_fingerprint(), switch_core_cert_gen_fingerprint(), switch_core_codec_add_implementation(), switch_core_codec_control(), switch_core_codec_decode(), switch_core_codec_decode_video(), switch_core_codec_destroy(), switch_core_codec_encode(), switch_core_codec_encode_video(), switch_core_codec_init_with_bitrate(), switch_core_db_exec(), switch_core_db_load_extension(), switch_core_db_open_file(), switch_core_db_persistant_execute_trans(), switch_core_db_test_reactive(), switch_core_destroy(), switch_core_directory_open(), switch_core_execute_chat_app(), switch_core_file_close(), switch_core_file_read(), switch_core_file_write(), switch_core_init_and_modload(), switch_core_launch_thread(), switch_core_media_activate_rtp(), switch_core_media_add_crypto(), switch_core_media_bug_add(), switch_core_media_bug_close(), switch_core_media_bug_read(), switch_core_media_bug_remove_all_function(), switch_core_media_bug_transfer_callback(), switch_core_media_bug_transfer_recordings(), switch_core_media_build_crypto(), switch_core_media_choose_port(), switch_core_media_choose_ports(), switch_core_media_ext_address_lookup(), switch_core_media_find_zrtp_hash(), switch_core_media_gen_local_sdp(), switch_core_media_negotiate_sdp(), switch_core_media_pass_zrtp_hash(), switch_core_media_patch_sdp(), switch_core_media_process_sdp_filter(), switch_core_media_process_t38_passthru(), switch_core_media_proxy_remote_addr(), switch_core_media_read_frame(), switch_core_media_read_lock_unlock(), switch_core_media_receive_message(), switch_core_media_set_codec(), switch_core_media_set_r_sdp_codec_string(), switch_core_media_set_udptl_image_sdp(), switch_core_media_set_video_codec(), switch_core_media_set_video_file(), switch_core_media_start_udptl(), switch_core_memory_reclaim(), switch_core_memory_reclaim_events(), switch_core_memory_stop(), switch_core_perform_alloc(), switch_core_perform_destroy_memory_pool(), switch_core_perform_file_open(), switch_core_perform_new_memory_pool(), switch_core_perform_permanent_alloc(), switch_core_perform_permanent_strdup(), switch_core_perform_session_alloc(), switch_core_perform_session_strdup(), switch_core_perform_strdup(), switch_core_port_allocator_new(), switch_core_port_allocator_request_port(), switch_core_recovery_flush(), switch_core_recovery_recover(), switch_core_session_check_incoming_crypto(), switch_core_session_ctl(), switch_core_session_enable_heartbeat(), switch_core_session_exec(), switch_core_session_execute_application_get_flags(), switch_core_session_execute_exten(), switch_core_session_get_app_flags(), switch_core_session_hangup_state(), switch_core_session_launch_thread(), switch_core_session_outgoing_channel(), switch_core_session_parse_crypto_prefs(), switch_core_session_perform_destroy(), switch_core_session_perform_force_locate(), switch_core_session_perform_kill_channel(), switch_core_session_perform_receive_message(), switch_core_session_read_frame(), switch_core_session_read_lock(), switch_core_session_read_lock_hangup(), switch_core_session_read_video_frame(), switch_core_session_recv_dtmf(), switch_core_session_request_by_name(), switch_core_session_request_uuid(), switch_core_session_run(), switch_core_session_send_dtmf(), switch_core_session_send_dtmf_string(), switch_core_session_set_codec_slin(), switch_core_session_set_read_codec(), switch_core_session_set_real_read_codec(), switch_core_session_set_uuid(), switch_core_session_set_video_read_codec(), switch_core_session_set_video_write_codec(), switch_core_session_set_write_codec(), switch_core_session_start_video_thread(), switch_core_session_thread(), switch_core_session_thread_launch(), switch_core_session_thread_pool_launch(), switch_core_session_thread_pool_worker(), switch_core_session_wake_video_thread(), switch_core_session_write_encoded_video_frame(), switch_core_session_write_frame(), switch_core_session_write_video_frame(), switch_core_speech_open(), switch_core_speech_read_tts(), switch_core_sqldb_pause(), switch_core_sqldb_resume(), switch_core_sqldb_start(), switch_core_sqldb_start_thread(), switch_core_sqldb_stop_thread(), switch_core_standard_on_consume_media(), switch_core_standard_on_destroy(), switch_core_standard_on_exchange_media(), switch_core_standard_on_execute(), switch_core_standard_on_hangup(), switch_core_standard_on_hibernate(), switch_core_standard_on_init(), switch_core_standard_on_park(), switch_core_standard_on_reporting(), switch_core_standard_on_reset(), switch_core_standard_on_routing(), switch_core_standard_on_soft_execute(), switch_core_timer_check(), switch_core_timer_destroy(), switch_core_timer_init(), switch_core_timer_next(), switch_core_timer_step(), switch_core_timer_sync(), switch_dow_cmp(), switch_event_bind_removable(), switch_event_channel_broadcast(), switch_event_channel_deliver_thread(), switch_event_channel_unsub_head(), switch_event_create_brackets(), switch_event_destroy(), switch_event_dispatch_thread(), switch_event_expand_headers_check(), switch_event_free_subclass_detailed(), switch_event_init(), switch_event_launch_dispatch_threads(), switch_event_shutdown(), switch_event_unbind(), switch_event_unbind_callback(), switch_fd_read_dline(), switch_fp_read_dline(), switch_img_from_raw(), switch_img_patch(), switch_img_patch_png(), switch_img_read_png(), switch_img_scale(), switch_img_to_raw(), switch_img_txt_handle_create(), switch_img_txt_handle_render(), switch_img_write_png(), switch_ivr_3p_media(), switch_ivr_3p_nomedia(), switch_ivr_activate_unicast(), switch_ivr_bind_dtmf_meta_session(), switch_ivr_check_presence_mapping(), switch_ivr_collect_digits_count(), switch_ivr_deactivate_unicast(), switch_ivr_delay_echo(), switch_ivr_detect_speech(), switch_ivr_detect_speech_disable_all_grammars(), switch_ivr_detect_speech_disable_grammar(), switch_ivr_detect_speech_enable_grammar(), switch_ivr_detect_speech_load_grammar(), switch_ivr_detect_speech_unload_grammar(), switch_ivr_digit_stream_parser_del_event(), switch_ivr_digit_stream_parser_new(), switch_ivr_digit_stream_parser_set_event(), switch_ivr_displace_session(), switch_ivr_dmachine_bind(), switch_ivr_dmachine_clear_realm(), switch_ivr_dmachine_feed(), switch_ivr_dmachine_set_realm(), switch_ivr_dmachine_set_terminators(), switch_ivr_eavesdrop_session(), switch_ivr_enterprise_originate(), switch_ivr_inband_dtmf_generate_session(), switch_ivr_insert_file(), switch_ivr_intercept_session(), switch_ivr_media(), switch_ivr_menu_execute(), switch_ivr_menu_init(), switch_ivr_menu_stack_xml_add(), switch_ivr_menu_stack_xml_build(), switch_ivr_menu_stack_xml_init(), switch_ivr_multi_threaded_bridge(), switch_ivr_nomedia(), switch_ivr_originate(), switch_ivr_park(), switch_ivr_parse_event(), switch_ivr_phrase_macro_event(), switch_ivr_play_and_detect_speech(), switch_ivr_play_file(), switch_ivr_preprocess_session(), switch_ivr_process_fh(), switch_ivr_read(), switch_ivr_record_file(), switch_ivr_record_session(), switch_ivr_say(), switch_ivr_say_string(), switch_ivr_session_transfer(), switch_ivr_set_user(), switch_ivr_sleep(), switch_ivr_soft_hold(), switch_ivr_sound_test(), switch_ivr_speak_text(), switch_ivr_speak_text_handle(), switch_ivr_tone_detect_session(), switch_ivr_unbind_dtmf_meta_session(), switch_ivr_uuid_bridge(), switch_ivr_video_write_overlay_session(), switch_ivr_wait_for_answer(), switch_ivr_wait_for_silence(), switch_jb_put_packet(), switch_limit_incr(), switch_limit_init(), switch_limit_interval_reset(), switch_limit_release(), switch_limit_reset(), switch_limit_status(), switch_limit_usage(), switch_load_core_config(), switch_load_network_lists(), switch_load_timezones(), switch_loadable_module_build_dynamic(), switch_loadable_module_create_interface(), switch_loadable_module_exec(), switch_loadable_module_init(), switch_loadable_module_load_file(), switch_loadable_module_load_module_ex(), switch_loadable_module_process(), switch_loadable_module_runtime(), switch_loadable_module_sort_codecs(), switch_loadable_module_unload_module(), switch_loadable_module_unprocess(), switch_lookup_timezone(), SWITCH_MODULE_LOAD_FUNCTION(), SWITCH_MODULE_RUNTIME_FUNCTION(), switch_nat_add_mapping_internal(), switch_nat_add_mapping_pmp(), switch_nat_add_mapping_upnp(), switch_nat_del_mapping_pmp(), switch_nat_del_mapping_upnp(), switch_nat_init(), switch_nat_multicast_runtime(), switch_nat_republish(), switch_nat_thread_start(), switch_nat_thread_stop(), switch_network_list_perform_add_cidr_token(), switch_odbc_handle_callback_exec_detailed(), switch_odbc_handle_connect(), switch_odbc_handle_disconnect(), switch_odbc_handle_exec(), switch_parse_codec_buf(), switch_pgsql_cancel_real(), switch_pgsql_finish_results_real(), switch_pgsql_flush(), switch_pgsql_handle_callback_exec_detailed(), switch_pgsql_handle_connect(), switch_pgsql_handle_disconnect(), switch_pgsql_handle_exec_base_detailed(), switch_pgsql_next_result_timed(), switch_pgsql_send_query(), switch_pgsql_SQLEndTran(), switch_play_and_get_digits(), switch_regex_match_partial(), switch_regex_perform(), switch_rtp_activate_ice(), switch_rtp_activate_rtcp(), switch_rtp_add_crypto_key(), switch_rtp_add_dtls(), switch_rtp_change_interval(), switch_rtp_create(), switch_rtp_dequeue_dtmf(), switch_rtp_enable_vad(), switch_rtp_init(), switch_rtp_set_max_missed_packets(), switch_rtp_set_video_buffer_size(), switch_rtp_shutdown(), switch_rtp_write_frame(), switch_rtp_write_raw(), switch_scheduler_add_task(), switch_scheduler_del_task_group(), switch_scheduler_del_task_id(), switch_scheduler_task_thread(), switch_scheduler_task_thread_stop(), switch_simple_email(), switch_speex_fmtp_parse(), switch_speex_init(), switch_sql_queue_manager_destroy(), switch_sql_queue_manager_push(), switch_sql_queue_manager_push_confirm(), switch_sql_queue_manager_start(), switch_sql_queue_manager_stop(), SWITCH_STANDARD_SCHED_FUNC(), switch_system_fork(), switch_system_thread(), switch_thread_join(), switch_time_calibrate_clock(), switch_time_sync(), switch_user_sql_thread(), switch_xml_ampencode(), switch_xml_config_item_print_doc(), switch_xml_config_parse_event(), switch_xml_config_parse_module_settings(), switch_xml_free(), switch_xml_locate(), switch_xml_locate_language(), switch_xml_locate_user_cache(), switch_xml_locate_user_merged(), switch_xml_parse_file_simple(), switch_xml_std_datetime_check(), system_thread(), task_thread_loop(), thread_launch_failure(), timer_destroy(), timer_init(), tone_detect_callback(), CoreSession::transfer(), transfer_after_bridge(), uuid_bridge_on_reset(), uuid_bridge_on_soft_execute(), and video_helper_thread().

switch_status_t switch_log_shutdown ( void  )

Shut down the logging engine.

Note
to be called at application termination by the core

Definition at line 560 of file switch_log.c.

References LOG_QUEUE, switch_cond_next(), switch_core_memory_reclaim_logger(), switch_queue_push(), SWITCH_STATUS_SUCCESS, switch_thread_join(), thread, and THREAD_RUNNING.

Referenced by switch_core_destroy().

561 {
562  switch_status_t st;
563 
564 
566  while (THREAD_RUNNING) {
568  }
569 
571 
573 
574  return SWITCH_STATUS_SUCCESS;
575 }
void switch_core_memory_reclaim_logger(void)
Definition: switch_log.c:544
static switch_thread_t * thread
Definition: switch_log.c:279
switch_status_t switch_thread_join(switch_status_t *retval, switch_thread_t *thd)
Definition: switch_apr.c:1255
static switch_queue_t * LOG_QUEUE
Definition: switch_log.c:60
static int8_t THREAD_RUNNING
Definition: switch_log.c:64
void switch_cond_next(void)
Definition: switch_time.c:638
switch_status_t
Common return values.
switch_status_t switch_queue_push(switch_queue_t *queue, void *data)
Definition: switch_apr.c:1129
switch_log_level_t switch_log_str2level ( _In_z_ const char *  str)

Return the level number of the specified log level name.

Parameters
strthe name of the level
Returns
the log level

Referenced by console_log(), console_log2(), CoreSession::consoleLog(), CoreSession::consoleLog2(), fs_consol_log(), and switch_load_core_config().

uint32_t switch_log_str2mask ( _In_z_ const char *  str)
switch_status_t switch_log_unbind_logger ( _In_ switch_log_function_t  function)
void void switch_log_vprintf ( _In_ switch_text_channel_t  channel,
_In_z_ const char *  file,
_In_z_ const char *  func,
_In_ int  line,
_In_opt_z_ const char *  userdata,
_In_ switch_log_level_t  level,
const char *  fmt,
va_list  ap 
)

Write log data to the logging engine.

Parameters
channelthe log channel to write to
filethe current file
functhe current function
linethe current line
userdataununsed
levelthe current log level
fmtdesired format
apvariable args
Note
there are channel macros to supply the first 4 parameters (SWITCH_CHANNEL_LOG, SWITCH_CHANNEL_LOG_CLEAN, ...)
See also
switch_types.h