Asterisk.org: Developer Documentation (28 Oct 2009)

Wed Oct 28 15:49:04 2009

## Asterisk developer's documentation

# logger.c File Reference

Asterisk Logger. More...

`#include <signal.h>`
`#include <stdarg.h>`
`#include <stdio.h>`
`#include <unistd.h>`
`#include <time.h>`
`#include <string.h>`
`#include <stdlib.h>`
`#include <errno.h>`
`#include <sys/stat.h>`
`#include <syslog.h>`
`#include "asterisk.h"`
`#include "asterisk/logger.h"`
`#include "asterisk/lock.h"`
`#include "asterisk/options.h"`
`#include "asterisk/channel.h"`
`#include "asterisk/config.h"`
`#include "asterisk/term.h"`
`#include "asterisk/cli.h"`
`#include "asterisk/utils.h"`
`#include "asterisk/manager.h"`

Include dependency graph for logger.c:

Go to the source code of this file.

## Data Structures

struct | logchannel
struct | msglist
struct | verb

## Defines

#define | FORMATL "%-35.35s %-8.8s %-9.9s "
#define | GETTID() getpid()
#define | MAX_MSG_QUEUE 200
#define | SYSLOG_NAMES
#define | SYSLOG_NLEVELS sizeof(syslog_level_map) / sizeof(int)

## Enumerations

enum | logtypes { LOGTYPE_SYSLOG, LOGTYPE_FILE, LOGTYPE_CONSOLE }

## Functions

void | ast_log (int level, const char *file, int line, const char *function, const char *fmt,...)
static void | ast_log_vsyslog (int level, const char *file, int line, const char *function, const char *fmt, va_list args)
| AST_MUTEX_DEFINE_STATIC (loglock)
| AST_MUTEX_DEFINE_STATIC (msglist_lock)
void | ast_queue_log (const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt,...)
int | ast_register_verbose (void(*v)(const char *string, int opos, int replacelast, int complete))
int | ast_unregister_verbose (void(*v)(const char *string, int opos, int replacelast, int complete))
void | ast_verbose (const char *fmt,...)
int | ast_verbose_dmesg (void(*v)(const char *string, int opos, int replacelast, int complete))
void | close_logger (void)
static int | handle_logger_reload (int fd, int argc, char *argv[])
static int | handle_logger_rotate (int fd, int argc, char *argv[])
static int | handle_logger_show_channels (int fd, int argc, char *argv[])
static int | handle_SIGXFSZ (int sig)
int | init_logger (void)
static void | init_logger_chain (void)
static int | make_components (char *s, int lineno)
static struct logchannel * | make_logchannel (char *channel, char *components, int lineno)
int | reload_logger (int rotate)

## Variables

static int | colors []
static char | dateformat [256] = "%b %e %T"
static FILE * | eventlog = NULL
static int | filesize_reload_needed = 0
static int | global_logmask = -1
static char | hostname [MAXHOSTNAMELEN]
static struct msglist * | last
static char * | levels []
static struct msglist * | list
static struct logchannel * | logchannels = NULL
struct {
unsigned int event_log:1
unsigned int queue_log:1
} | logfiles
static char | logger_reload_help []
static char | logger_rotate_help []
static struct ast_cli_entry | logger_show_channels_cli
static char | logger_show_channels_help []
static int | msgcnt = 0
static FILE * | qlog = NULL
static struct ast_cli_entry | reload_logger_cli
static struct ast_cli_entry | rotate_logger_cli
static int | syslog_level_map []
static struct verb * | verboser

## Detailed Description

Asterisk Logger.

Logging routines

Definition in file logger.c.

## Define Documentation

#define FORMATL "%-35.35s %-8.8s %-9.9s "

Referenced by handle_logger_show_channels().

#define GETTID | ( |  | ) | getpid()

Definition at line 75 of file logger.c.

Referenced by ast_log(), and ast_log_vsyslog().

#define MAX_MSG_QUEUE 200

Definition at line 66 of file logger.c.

Referenced by ast_verbose().

#define SYSLOG_NAMES

Definition at line 36 of file logger.c.

#define SYSLOG_NLEVELS sizeof(syslog_level_map) / sizeof(int)

Definition at line 54 of file logger.c.

Referenced by ast_log_vsyslog().

## Enumeration Type Documentation

enum logtypes

Enumerator:

  LOGTYPE_SYSLOG |
  LOGTYPE_FILE |
  LOGTYPE_CONSOLE |

Definition at line 98 of file logger.c.

    00098               {
    00099    LOGTYPE_SYSLOG,
    00100    LOGTYPE_FILE,
    00101    LOGTYPE_CONSOLE,
    00102 };

## Function Documentation

void ast_log | ( | int | level,
|  | const char * | file,
|  | int | line,
|  | const char * | function,
|  | const char * | fmt,
|  |  | ... |
| ) |  |  |

Definition at line 693 of file logger.c.

References __LOG_DEBUG, __LOG_EVENT, __LOG_VERBOSE, ast_console_puts(), ast_log_vsyslog(), ast_mutex_lock(), ast_mutex_unlock(), ast_strlen_zero(), ast_verbose(), COLOR_BRWHITE, colors, dateformat, debug_filename, logchannel::disabled, EVENT_FLAG_SYSTEM, eventlog, logchannel::filename, logchannel::fileptr, filesize_reload_needed, GETTID, global_logmask, levels, LOG_EVENT, logfiles, logchannel::logmask, LOGTYPE_CONSOLE, LOGTYPE_SYSLOG, manager_event(), logchannel::next, option_debug, option_timestamp, option_verbose, reload_logger(), t, term_color(), term_strip(), and logchannel::type.

Referenced by __adsi_transmit_messages(), __agent_start_monitoring(), __ast_check_signature(), __ast_check_signature_bin(), __ast_context_destroy(), __ast_decrypt_bin(), __ast_dsp_call_progress(), __ast_encrypt_bin(), __ast_pbx_run(), __ast_request_and_dial(), __ast_sign_bin(), __ast_smoother_feed(), __build_step(), __grab_token(), __load_resource(), __login_exec(), __mgcp_xmit(), __oh323_destroy(), __oh323_new(), __oh323_update_info(), __sip_ack(), __sip_autodestruct(), __sip_destroy(), __sip_pretend_ack(), __sip_reliable_xmit(), __sip_semi_ack(), __sip_xmit(), __transmit_response(), __unload_module(), __zt_exception(), _while_exec(), accept_thread(), acf_curl_exec(), acf_cut_exec(), acf_sort_exec(), acf_strftime(), acf_vmcount_exec(), ack_trans(), add_agent(), add_blank_header(), add_calltoken_ignore(), add_header(), add_identifier(), add_line(), add_realm_authentication(), add_sdp(), add_sip_domain(), add_to_interfaces(), admin_exec(), adpcmtolin_framein(), adsi_begin(), adsi_begin_download(), adsi_careful_send(), adsi_get_cpeid(), adsi_get_cpeinfo(), adsi_load_session(), adsi_load_vmail(), adsi_process(), adsi_prog(), adsi_transmit_message_full(), advanced_options(), agent_answer(), agent_bridgedchannel(), agent_call(), agent_cont_sleep(), agent_fixup(), agent_hangup(), agent_new(), agent_read(), agent_request(), agent_write(), agentmonitoroutgoing_exec(), agi_debug_cli(), agi_exec(), agi_exec_full(), agi_register(), alarmreceiver_exec(), alawtolin_framein(), alawtoulaw_framein(), alloc_sub(), alsa_card_init(), alsa_indicate(), alsa_new(), alsa_read(), alsa_request(), alsa_write(), answer_call(), anti_injection(), ao2_callback(), ao2_ref(), aopen_answer(), aopen_break(), aopen_dial(), aopen_dialdigit(), aopen_handle_escape(), aopen_hangup(), aopen_init(), aopen_read(), aopen_setdev(), aopen_startrec(), aopen_write(), aPGSQL_clear(), aPGSQL_connect(), aPGSQL_debug(), aPGSQL_disconnect(), aPGSQL_fetch(), aPGSQL_query(), aPGSQL_reset(), app_exec(), append_history(), append_transaction(), apply_option(), apply_outgoing(), aqm_exec(), ast_add_extension2(), ast_add_hint(), ast_ael_compile(), ast_app_dtget(), ast_app_getvoice(), ast_app_parse_options(), ast_append_ha(), ast_apply_ha(), ast_async_goto(), ast_autoservice_start(), ast_best_codec(), ast_bridge_call(), ast_cdr_answer(), ast_cdr_busy(), ast_cdr_detach(), ast_cdr_disposition(), ast_cdr_dup(), ast_cdr_end(), ast_cdr_engine_init(), ast_cdr_failed(), ast_cdr_free(), ast_cdr_init(), ast_cdr_noanswer(), ast_cdr_register(), ast_cdr_serialize_variables(), ast_cdr_setapp(), ast_cdr_setdestchan(), ast_cdr_setvar(), ast_cdr_start(), ast_cdr_submit_batch(), ast_channel_alloc(), ast_channel_bridge(), ast_channel_free(), ast_channel_inherit_variables(), ast_channel_make_compatible(), ast_channel_masquerade(), ast_channel_register(), ast_channel_setoption(), ast_channel_spy_add(), ast_channel_start_silence_generator(), ast_channel_stop_silence_generator(), ast_channel_unregister(), ast_check_timing(), ast_cli(), ast_cli_command(), ast_cli_register(), ast_cli_unregister(), ast_codec_get_len(), ast_codec_get_samples(), ast_config_engine_register(), ast_config_internal_load(), ast_context_add_ignorepat2(), ast_context_add_include2(), ast_context_add_switch2(), ast_context_create(), ast_context_verify_includes(), ast_control_streamfile(), ast_custom_function_find(), ast_custom_function_register(), ast_custom_function_unregister(), ast_db_del(), ast_db_get(), ast_db_gettree(), ast_db_put(), ast_device_state_engine_init(), ast_do_masquerade(), ast_dsp_busydetect(), ast_dsp_call_progress(), ast_dsp_digitdetect(), ast_dsp_process(), ast_dsp_set_busy_pattern(), ast_dsp_silence(), ast_dtmf_stream(), ast_el_read_char(), ast_enable_packet_fragmentation(), ast_feature_interpret(), ast_feature_request_and_dial(), ast_filehelper(), ast_find_ourip(), ast_format_register(), ast_format_unregister(), ast_frisolate(), ast_func_read(), ast_func_write(), ast_generic_bridge(), ast_get_channel_tech(), ast_get_enum(), ast_get_group(), ast_get_indication_tone(), ast_get_indication_zone(), ast_get_ip_or_srv(), ast_get_txt(), ast_hangup(), ast_hint_extension(), ast_iax2_new(), ast_indicate(), ast_io_add(), ast_io_dump(), ast_io_remove(), ast_io_wait(), ast_ivr_menu_run_internal(), ast_linear_stream(), ast_loader_register(), ast_loader_unregister(), ast_lock_path(), ast_lookup_iface(), ast_makesocket(), ast_manager_register2(), ast_manager_register_struct(), ast_masq_park_call(), ast_merge_contexts_and_delete(), ast_modem_new(), ast_moh_destroy(), ast_moh_files_next(), ast_monitor_change_fname(), ast_monitor_start(), ast_monitor_stop(), ast_netsock_bind(), ast_netsock_bindaddr(), ast_openstream_full(), ast_openvstream(), ast_osp_lookup(), ast_osp_next(), ast_osp_terminate(), ast_osp_validate(), ast_ouraddrfor(), ast_park_call(), ast_parse_allow_disallow(), ast_parseable_goto(), ast_pbx_outgoing_app(), ast_pbx_outgoing_cdr_failed(), ast_pbx_outgoing_exten(), ast_pbx_run_app(), ast_pbx_start(), ast_pickup_call(), ast_play_and_prepend(), ast_play_and_record_full(), ast_playtones_start(), ast_prod(), ast_pthread_create_stack(), ast_queue_frame(), ast_read(), ast_read_image(), ast_read_textfile(), ast_readaudio_callback(), ast_readconfig(), ast_readfile(), ast_readvideo_callback(), ast_record_review(), ast_register_application(), ast_register_feature(), ast_register_indication(), ast_register_indication_country(), ast_register_switch(), ast_register_translator(), ast_remotecontrol(), ast_request(), ast_resource_exists(), ast_rtcp_new(), ast_rtcp_read(), ast_rtp_bridge(), ast_rtp_new_with_bindaddr(), ast_rtp_offered_from_local(), ast_rtp_proto_register(), ast_rtp_raw_write(), ast_rtp_read(), ast_rtp_reload(), ast_rtp_sendcng(), ast_rtp_senddigit(), ast_rtp_settos(), ast_rtp_write(), ast_safe_system(), 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_pt(), ast_say_date_with_format_tw(), ast_say_enumeration_full_da(), ast_say_enumeration_full_de(), ast_say_enumeration_full_en(), ast_say_number_full_da(), ast_say_number_full_de(), ast_say_number_full_en(), 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_he(), 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_tw(), ast_sched_add_variable(), ast_sched_del(), ast_sched_dump(), ast_sched_runq(), ast_sched_wait(), ast_sched_when(), ast_search_dns(), ast_set_priority(), ast_settimeout(), ast_sip_ouraddrfor(), ast_slinfactory_feed(), ast_smoother_read(), ast_softhangup_nolock(), ast_stopstream(), ast_streamfile(), ast_translate(), ast_translator_build_path(), ast_tryconnect(), ast_unload_resource(), ast_unlock_path(), ast_unregister_application(), ast_unregister_indication(), ast_unregister_indication_country(), ast_unregister_switch(), ast_update_use_count(), ast_var_assign(), ast_verbose(), ast_waitfor_n_fd(), ast_waitfor_nandfds(), ast_waitfordigit_full(), ast_waitstream(), ast_waitstream_exten(), ast_waitstream_fr(), ast_waitstream_full(), ast_write(), ast_writefile(), ast_writestream(), ast_yyerror(), async_wait(), attempt_reconnect(), attempt_thread(), attempt_transfer(), attempt_transmit(), au_close(), au_open(), au_read(), au_rewrite(), au_write(), auth_exec(), authenticate(), authenticate_verify(), auto_congest(), autoservice_run(), available(), background_detect_exec(), base_encode(), bestdata_answer(), bestdata_break(), bestdata_dial(), bestdata_dialdigit(), bestdata_handle_escape(), bestdata_hangup(), bestdata_init(), bestdata_read(), bestdata_startplay(), bestdata_startrec(), bestdata_write(), build_alias(), build_callno_limits(), build_conf(), build_device(), build_gateway(), build_mapping(), build_peer(), build_reply_digest(), build_route(), build_rpid(), build_transactions(), build_user(), builtin_atxfer(), builtin_automonitor(), builtin_blindtransfer(), builtin_function_checkmd5(), builtin_function_if(), builtin_function_iftime(), builtin_function_math(), builtin_function_md5(), builtin_function_regex(), builtin_function_set(), builtin_function_timeout_read(), builtin_function_timeout_write(), builtin_function_uridecode(), builtin_function_uriencode(), bump_gains(), cache_get_callno_locked(), cache_lookup_internal(), cache_save_hint(), calc_cost(), calc_metric(), calc_rxstamp(), calc_timestamp(), callerid_feed(), callerid_get_dtmf(), callerid_new(), callerid_read(), callerid_write(), calltoken_required(), careful_write(), cb_events(), chan_misdn_log(), chan_ringing(), chanavail_exec(), chandup(), changethread(), channel_find_locked(), chanspy_exec(), check_access(), check_auth(), check_availability(), check_beep(), check_for_conference(), check_header(), check_key(), check_pendings(), check_provisioning(), check_srcaddr(), check_user_full(), check_via(), cleanup_connection(), clearcbone(), cleardisplay(), clearflag(), cleartimer(), compare_weight(), compile_script(), complete_context_add_extension(), complete_context_add_ignorepat(), complete_context_add_include(), complete_context_dont_include(), complete_context_remove_extension(), complete_context_remove_ignorepat(), complete_dpreply(), complete_show_application(), complete_show_dialplan_context(), complete_show_function(), complete_transfer(), compress_subclass(), conf_add(), conf_cmd(), conf_del(), conf_exec(), conf_flush(), conf_free(), conf_run(), config_load(), config_odbc(), config_text_file_load(), config_text_file_save(), connection_made(), console_autoanswer(), controlplayback_exec(), convertcap(), copy(), copy_data_from_queue(), copy_header(), copy_message(), copy_via_headers(), count_exec(), create_addr(), create_addr_from_peer(), create_dirpath(), create_queue_member(), crypto_load(), csv_log(), curl_exec(), custom_log(), cut_exec(), cut_internal(), dbinit(), decode_frame(), del_exec(), del_identifier(), deltree_exec(), destroy_session(), destroy_trans(), dial_exec_full(), dictate_exec(), digitcollect(), digitdirect(), directory_exec(), disa_exec(), dns_parse_answer(), dnsmgr_init(), do_autokill(), do_cdr(), do_chanreads(), do_directory(), do_monitor(), do_parking_thread(), do_proxy_auth(), do_register(), do_register_expire(), do_reload(), do_senddigit(), do_state_change(), do_waiting(), dump_agents(), dump_queue(), dump_queue_members(), dundi_answer_entity(), dundi_answer_query(), dundi_decrypt(), dundi_discover(), dundi_encrypt(), dundi_error_output(), dundi_exec(), dundi_helper(), dundi_lookup_exec(), dundi_lookup_internal(), dundi_lookup_thread(), dundi_precache_full(), dundi_precache_internal(), dundi_precache_thread(), dundi_prop_precache(), dundi_query(), dundi_query_thread(), dundi_rexmit(), dundi_send(), dundi_xmit(), dundifunc_read(), eagi_exec(), encrypt_frame(), enum_callback(), enumlookup_exec(), eval_exec(), exec_exec(), execif_exec(), expire_registry(), external_rtp_create(), feature_exec_app(), features_alloc(), features_call(), features_new(), festival_exec(), fillin_process(), find_cache(), find_call(), find_call_locked(), find_callno(), find_conf(), find_desc(), find_engine(), find_identifier(), find_matching_endwhile(), find_peer(), find_queue_by_name_rt(), find_subchannel_and_lock(), find_subchannel_by_name(), find_tpeer(), find_transaction(), find_transcoders(), flash_exec(), forkcdr_exec(), forward_message(), func_check_sipdomain(), func_header_read(), function_db_exists(), function_db_read(), function_db_write(), function_enum(), function_eval(), function_fieldqty(), function_iaxpeer(), function_ilink(), function_sipchaninfo_read(), function_sippeer(), function_txtcidname(), g723_close(), g723_len(), g723_open(), g723_read(), g723_rewrite(), g723_write(), g723tolin_framein(), g726_16_open(), g726_16_rewrite(), g726_24_open(), g726_24_rewrite(), g726_32_open(), g726_32_rewrite(), g726_40_open(), g726_40_rewrite(), g726_close(), g726_read(), g726_write(), g726tolin_framein(), g729_close(), g729_open(), g729_read(), g729_rewrite(), g729_write(), generator_force(), get_alarms(), get_also_info(), get_callerid(), get_callerid_ast(), get_day(), get_destination(), get_dow(), get_exec(), get_group(), get_in_brackets(), get_input(), get_mohbyname(), get_month(), get_rdnis(), get_refer_info(), get_timerange(), get_token(), get_unused_callno(), get_wait_interval(), getdisplaybyname(), getflagbyname(), getkeybyname(), getstatebyname(), getsubbyname(), gosub_exec(), gosubif_exec(), goto_line(), goto_line_rel(), group_check_exec(), group_count_exec(), group_count_function_read(), group_function_write(), group_match_count_exec(), group_set_exec(), gsm_close(), gsm_open(), gsm_read(), gsm_rewrite(), gsm_write(), gsmtolin_framein(), h263_close(), h263_open(), h263_read(), h263_rewrite(), h263_write(), h323_gk_cycle(), handle_add_indication(), handle_call_token(), handle_command_response(), handle_common_options(), handle_context(), handle_error(), handle_exec(), handle_frame(), handle_getoption(), handle_hd_hf(), handle_init_event(), handle_link_data(), handle_macro(), handle_message(), handle_playtones(), handle_recordfile(), handle_remote_data(), handle_remove_indication(), handle_request(), handle_request_bye(), handle_request_info(), handle_request_invite(), handle_request_refer(), handle_request_register(), handle_request_subscribe(), handle_response(), handle_response_invite(), handle_response_peerpoke(), handle_response_register(), handle_root_token(), handle_show_application(), handle_show_applications(), handle_show_hints(), handle_show_indications(), handle_show_switches(), hangup_cause2sip(), hangup_connection(), hasvoicemail_exec(), i4l_answer(), i4l_break(), i4l_dial(), i4l_dialdigit(), i4l_handle_escape(), i4l_hangup(), i4l_init(), i4l_read(), i4l_setdev(), i4l_startrec(), i4l_write(), iax2_ack_registry(), iax2_answer(), iax2_bridge(), iax2_call(), iax2_canmatch(), iax2_destroy(), iax2_devicestate(), iax2_do_register(), iax2_exec(), iax2_exists(), iax2_fixup(), iax2_hangup(), iax2_indicate(), iax2_matchmore(), iax2_poke_noanswer(), iax2_poke_peer(), iax2_predestroy(), iax2_prov_app(), iax2_provision(), iax2_read(), iax2_register(), iax2_request(), iax2_send(), iax2_setoption(), iax2_transfer(), iax2_trunk_queue(), iax2_write(), iax_error_output(), iax_frame_wrap(), iax_park(), iax_park_thread(), iax_process_template(), iax_provision_reload(), iax_provision_version(), iax_template_parse(), ices_exec(), icesencode(), ilbc_close(), ilbc_open(), ilbc_read(), ilbc_rewrite(), ilbc_write(), ilbctolin_framein(), increase_call_count(), ind_load_module(), indexof(), init_batch(), init_logger(), init_logger_chain(), init_manager(), init_req(), init_resp(), INTERNAL_OBJ(), invent_message(), io_grow(), is_our_turn(), ivr_dispatch(), jb_error_output(), jb_warning_output(), join_queue(), jpeg_read_image(), jpeg_write_image(), launch_monitor_thread(), launch_netscript(), launch_page(), launch_script(), launch_service(), leave_queue(), leave_voicemail(), linear_alloc(), linear_generator(), linear_release(), lintoadpcm_framein(), lintoalaw_framein(), lintog723_framein(), lintog723_frameout(), lintog726_framein(), lintogsm_framein(), lintogsm_frameout(), lintoilbc_framein(), lintoilbc_frameout(), lintolpc10_framein(), lintolpc10_frameout(), lintospeex_framein(), lintoulaw_framein(), listener(), load_config(), load_module(), load_modules(), load_moh_classes(), load_odbc_config(), load_pbx(), load_realtime_queue(), loadPemCert(), loadPemPrivateKey(), local_alloc(), local_answer(), local_call(), local_fixup(), local_new(), local_queue_frame(), local_write(), log_events(), lookupblacklist_exec(), lpc10tolin_framein(), macro_exec(), macroif_exec(), main(), make_integer(), make_str(), make_trunk(), manager_event(), math_exec(), md5_exec(), md5check_exec(), measurenoise(), memcpy_decrypt(), memcpy_encrypt(), mgcp_answer(), mgcp_call(), mgcp_fixup(), mgcp_hangup(), mgcp_indicate(), mgcp_new(), mgcp_postrequest(), mgcp_request(), mgcp_rtp_read(), mgcp_ss(), mgcp_write(), mgcpsock_read(), milliwatt_exec(), milliwatt_generate(), misdn_answer(), misdn_bridge(), misdn_call(), misdn_cfg_get(), misdn_cfg_get_config_string(), misdn_cfg_init(), misdn_cfg_is_msn_valid(), misdn_cfg_update_ptp(), misdn_check_l2l1(), misdn_digit(), misdn_facility_exec(), misdn_hangup(), misdn_indication(), misdn_request(), misdn_send_text(), misdn_set_opt_exec(), misdn_write(), mixmonitor_exec(), mixmonitor_thread(), mkbrd(), mkif(), mkintf(), modem_answer(), modem_call(), modem_digit(), modem_fixup(), modem_hangup(), modem_request(), modem_setup(), moh0_exec(), moh1_exec(), moh2_exec(), moh3_exec(), moh_alloc(), moh_files_generator(), moh_files_release(), moh_generate(), moh_register(), moh_release(), moh_scan_files(), mohalloc(), monitor_handle_notowned(), monitor_handle_owned(), monmp3thread(), mp3_exec(), mp3play(), mssql_connect(), my_load_module(), my_zt_write(), nbs_alloc(), nbs_call(), nbs_hangup(), nbs_new(), nbs_request(), nbs_xread(), nbs_xwrite(), NBScat_exec(), NBScatplay(), netconsole(), network_thread(), network_verboser(), notify_new_message(), odbc_load_module(), odbc_obj_connect(), odbc_obj_disconnect(), odbc_prepare_and_execute(), odbc_sanity_check(), odbc_smart_direct_execute(), odbc_smart_execute(), ogg_vorbis_close(), ogg_vorbis_getcomment(), ogg_vorbis_open(), ogg_vorbis_read(), ogg_vorbis_rewrite(), ogg_vorbis_seek(), ogg_vorbis_tell(), ogg_vorbis_trunc(), ogg_vorbis_write(), oh323_alloc(), oh323_answer(), oh323_call(), oh323_digit(), oh323_fixup(), oh323_hangup(), oh323_indicate(), oh323_request(), oh323_rtp_read(), oh323_set_rtp_peer(), oh323_write(), onevent(), op_colon(), op_div(), op_eq(), op_eqtilde(), op_minus(), op_negate(), op_plus(), op_rem(), op_times(), open_mailbox(), osp_build(), ospfinished_exec(), osplookup_exec(), ospnext_exec(), oss_indicate(), oss_new(), oss_read(), oss_request(), oss_write(), page_exec(), param_parse(), park_exec(), parkandannounce_exec(), parse(), parse_args(), parse_config(), parse_gain_value(), parse_ie(), parse_moved_contact(), parse_naptr(), parse_ok_contact(), parse_register_contact(), parse_request(), parse_sip_options(), parse_srv(), pbx_builtin_atimeout(), pbx_builtin_background(), pbx_builtin_dtimeout(), pbx_builtin_execiftime(), pbx_builtin_gotoif(), pbx_builtin_gotoiftime(), pbx_builtin_importvar(), pbx_builtin_pushvar_helper(), pbx_builtin_resetcdr(), pbx_builtin_rtimeout(), pbx_builtin_saynumber(), pbx_builtin_serialize_variables(), pbx_builtin_setglobalvar(), pbx_builtin_setlanguage(), pbx_builtin_setvar(), pbx_builtin_setvar_old(), pbx_builtin_waitexten(), pbx_exec(), pbx_extension_helper(), pbx_find_extension(), pbx_findapp(), pbx_findswitch(), pbx_load_module(), pbx_retrieve_variable(), pbx_substitute_variables_helper_full(), pcm_close(), pcm_open(), pcm_read(), pcm_rewrite(), pcm_write(), peer_set_srcaddr(), peercnt_add(), peercnt_modify(), peercnt_remove(), PGSQL_exec(), pgsql_log(), phone_answer(), phone_call(), phone_check_exception(), phone_digit(), phone_exception(), phone_hangup(), phone_mini_packet(), phone_new(), phone_read(), phone_request(), phone_setup(), phone_write(), phone_write_buf(), pickup_exec(), pl_odtworz_plik(), play_mailbox_owner(), play_message(), play_message_callerid(), play_message_category(), play_message_datetime(), play_message_duration(), play_record_review(), playback_exec(), playtones_alloc(), playtones_generator(), post_cdr(), powerof(), pqm_exec(), precache_trans(), precache_transactions(), printdigest(), privacy_exec(), process_ast_dsp(), process_message(), process_my_load_module(), process_opcode(), process_returncode(), process_rfc2833(), process_rfc3389(), process_sdp(), process_text_line(), progress(), put_exec(), queue_exec(), queue_frame_to_spies(), queue_function_qac(), queue_set_param(), quit_handler(), random_exec(), raw_hangup(), rbi_out(), read_agent_config(), read_config(), read_config_maps(), read_exec(), read_samples(), readfile_exec(), realtime_directory(), realtime_exec(), realtime_multi_odbc(), realtime_odbc(), realtime_peer(), realtime_update_exec(), rebuild_matrix(), receive_ademco_contact_id(), receive_dtmf_digits(), receive_message(), record_exec(), refresh_list(), register_request(), register_translator(), register_verify(), registry_authrequest(), registry_rerequest(), reload(), reload_agents(), reload_config(), reload_firmware(), reload_logger(), reload_queue_members(), reload_queues(), remap_feature(), remove_by_peercallno(), remove_from_interfaces(), replace_callno(), reply_digest(), reset_conf(), reset_global_eid(), restart_monitor(), restore_conference(), restore_gains(), retrans_pkt(), retrydial_exec(), return_exec(), ring_entry(), ring_one(), rpt(), rpt_call(), rpt_exec(), rpt_master(), rpt_tele_thread(), rpt_telemetry(), rqm_exec(), run_agi(), run_externnotify(), run_ras(), safe_append(), save_conference(), saycharstr(), sayfile(), saynum(), sayunixtime_exec(), scan_service(), scan_thread(), sched_delay_remove(), sched_settime(), schedule_delivery(), send_callerid(), send_delay(), send_digit(), send_digit_to_chan(), send_dtmf(), send_packet(), send_request(), send_sound(), send_tone_burst(), send_trunk(), send_waveform_to_channel(), send_waveform_to_fd(), senddtmf_exec(), sendimage_exec(), sendmail(), sendpage(), sendtext_exec(), sendurl_exec(), session_do(), set_actual_rxgain(), set_actual_txgain(), set_config(), set_destination(), set_dtmf_payload(), set_format(), set_local_capabilities(), set_member_paused(), set_peercnt_limit(), set_peercnt_limit_all_cb(), set_state(), set_timing(), setcallerid_exec(), setcallerid_pres_exec(), setflag(), setformat(), setrdnis_exec(), settransfercapability_exec(), setup_incoming_call(), setup_rtp_connection(), setup_zap(), show_channeltypes(), show_dialplan_helper(), show_file_formats(), showdisplay(), showkeys(), sip_addheader(), sip_alloc(), sip_answer(), sip_call(), sip_devicestate(), sip_do_reload(), sip_dtmfmode(), sip_dump_history(), sip_fixup(), sip_getheader(), sip_hangup(), sip_indicate(), sip_new(), sip_notify(), sip_park(), sip_park_thread(), sip_poke_noanswer(), sip_poke_peer(), sip_reg_timeout(), sip_register(), sip_request_call(), sip_reregister(), sip_rtp_read(), sip_send_mwi_to_peer(), sip_set_rtp_peer(), sip_sipredirect(), sip_write(), sipsock_read(), skel_exec(), skinny_call(), skinny_fixup(), skinny_hangup(), skinny_indicate(), skinny_new(), skinny_req_parse(), skinny_request(), skinny_rtp_read(), skinny_session(), skinny_ss(), skinny_write(), slinear_close(), slinear_open(), slinear_read(), slinear_rewrite(), slinear_write(), sms_exec(), sms_generate(), sms_handleincoming(), sms_process(), sms_readfile(), sms_writefile(), socket_read(), softhangup_exec(), sort_exec(), sound_thread(), soundcard_init(), soundcard_setinput(), soundcard_setoutput(), soundcard_writeframe(), spawn_dp_lookup(), spawn_mp3(), speex_get_wb_sz_at(), speex_samples(), speextolin_framein(), spy_detach(), sqlite_log(), srv_callback(), ss_thread(), start_spying(), starttimer(), statechange_queue(), store_by_peercallno(), store_config(), store_mixer(), store_next(), str2cause(), strcasestr(), stty(), stub_ast_check_signature(), stub_ast_check_signature_bin(), stub_ast_encdec_bin(), stub_ast_key_get(), stub_ast_sign(), stub_ast_sign_bin(), subscript(), swap_subs(), system_exec_helper(), tdd_feed(), tdd_new(), tds_load_module(), tds_log(), telem_lookup(), testclient_exec(), testserver_exec(), timed_read(), timing_read(), to_integer(), to_string(), tonepair_alloc(), tonepair_generator(), transfer_exec(), transmit_callinfo(), transmit_callstate(), transmit_connect(), transmit_diallednumber(), transmit_displaymessage(), transmit_displaynotify(), transmit_displaypromptstatus(), transmit_invite(), transmit_lamp_indication(), transmit_notify_with_mwi(), transmit_refer(), transmit_register(), transmit_request_with_auth(), transmit_response(), transmit_response_with_auth(), transmit_response_with_sdp(), transmit_ringer_mode(), transmit_speaker_mode(), transmit_state_notify(), transmit_tone(), transmit_trunk(), try_calling(), try_firmware(), try_load_key(), try_suggested_sip_codec(), try_transfer(), tvfix(), txtcidname_exec(), ulawtoalaw_framein(), ulawtolin_framein(), unalloc_sub(), unload_module(), unwrap_timestamp(), update_call_counter(), update_common_options(), update_conf(), update_config(), update_header(), update_key(), update_max_nontrunk(), update_max_trunk(), update_odbc(), update_registry(), upqm_exec(), used_blocks(), userevent_exec(), verbose_exec(), vm_authenticate(), vm_box_exists(), vm_change_password(), vm_exec(), vm_execmain(), vm_newuser(), vm_options(), vm_tempgreeting(), vmauthenticate(), vox_close(), vox_open(), vox_read(), vox_rewrite(), vox_write(), vpb_bridge(), vpb_call(), vpb_fixup(), vpb_hangup(), vpb_new(), vpb_request(), vpb_write(), wait_file(), wait_file2(), wait_for_answer(), waitforring_exec(), waitforsilence_exec(), wav_close(), wav_open(), wav_read(), wav_rewrite(), wav_write(), write_header(), write_metadata(), writefile(), zap_destroy(), zap_fake_event(), zap_framein(), zap_frameout(), zap_new_alawtog723(), zap_new_alawtog729(), zap_new_g723toalaw(), zap_new_g723toulaw(), zap_new_g729toalaw(), zap_new_g729toulaw(), zap_new_ulawtog723(), zap_new_ulawtog729(), zap_show_channel(), zap_show_status(), zapras_exec(), zt_answer(), zt_bridge(), zt_call(), zt_callwait(), zt_confmute(), zt_digit(), zt_disable_ec(), zt_enable_ec(), zt_fixup(), zt_get_index(), zt_handle_dtmfup(), zt_handle_event(), zt_hangup(), zt_indicate(), zt_link(), zt_new(), zt_open(), zt_read(), zt_request(), zt_ring_phone(), zt_sendtext(), zt_set_hook(), zt_setoption(), zt_train_ec(), zt_unlink(), and zt_write().

    00694 {
    00695    struct logchannel *chan;
    00696    char buf[BUFSIZ];
    00697    time_t t;
    00698    struct tm tm;
    00699    char date[256];
    00700
    00701    va_list ap;
    00702
    00703    if (!logchannels)
    00704    {
    00705       /*
    00706        * we don't have the logger chain configured yet,
    00707        * so just log to stdout
    00708       */
    00709       if (level != __LOG_VERBOSE) {
    00710          va_start(ap, fmt);
    00711          vsnprintf(buf, sizeof(buf), fmt, ap);
    00712          va_end(ap);
    00713          fputs(buf, stdout);
    00714       }
    00715       return;
    00716    }
    00717
    00718    /* don't display LOG_DEBUG messages unless option_verbose _or_ option_debug
    00719       are non-zero; LOG_DEBUG messages can still be displayed if option_debug
    00720       is zero, if option_verbose is non-zero (this allows for 'level zero'
    00721       LOG_DEBUG messages to be displayed, if the logmask on any channel
    00722       allows it)
    00723    */
    00724    if (!option_verbose && !option_debug && (level == __LOG_DEBUG)) {
    00725       return;
    00726    }
    00727
    00728    /* Ignore anything that never gets logged anywhere */
    00729    if (!(global_logmask & (1 << level)))
    00730       return;
    00731
    00732    /* Ignore anything other than the currently debugged file if there is one */
    00733    if ((level == __LOG_DEBUG) && !ast_strlen_zero(debug_filename) && strcasecmp(debug_filename, file))
    00734       return;
    00735
    00736    /* begin critical section */
    00737    ast_mutex_lock(&loglock);
    00738
    00739    time(&t);
    00740    localtime_r(&t, &tm);
    00741    strftime(date, sizeof(date), dateformat, &tm);
    00742
    00743    if (logfiles.event_log && level == __LOG_EVENT) {
    00744       va_start(ap, fmt);
    00745
    00746       fprintf(eventlog, "%s asterisk[%d]: ", date, getpid());
    00747       vfprintf(eventlog, fmt, ap);
    00748       fflush(eventlog);
    00749
    00750       va_end(ap);
    00751       ast_mutex_unlock(&loglock);
    00752       return;
    00753    }
    00754
    00755    chan = logchannels;
    00756    while(chan && !chan->disabled) {
    00757       /* Check syslog channels */
    00758       if (chan->type == LOGTYPE_SYSLOG && (chan->logmask & (1 << level))) {
    00759          va_start(ap, fmt);
    00760          ast_log_vsyslog(level, file, line, function, fmt, ap);
    00761          va_end(ap);
    00762       /* Console channels */
    00763       } else if ((chan->logmask & (1 << level)) && (chan->type == LOGTYPE_CONSOLE)) {
    00764          char linestr[128];
    00765          char tmp1[80], tmp2[80], tmp3[80], tmp4[80];
    00766
    00767          if (level != __LOG_VERBOSE) {
    00768             sprintf(linestr, "%d", line);
    00769             snprintf(buf, sizeof(buf), option_timestamp ? "[%s] %s[%ld]: %s:%s %s: " : "%s %s[%ld]: %s:%s %s: ",
    00770                date,
    00771                term_color(tmp1, levels[level], colors[level], 0, sizeof(tmp1)),
    00772                (long)GETTID(),
    00773                term_color(tmp2, file, COLOR_BRWHITE, 0, sizeof(tmp2)),
    00774                term_color(tmp3, linestr, COLOR_BRWHITE, 0, sizeof(tmp3)),
    00775                term_color(tmp4, function, COLOR_BRWHITE, 0, sizeof(tmp4)));
    00776
    00777             ast_console_puts(buf);
    00778             va_start(ap, fmt);
    00779             vsnprintf(buf, sizeof(buf), fmt, ap);
    00780             va_end(ap);
    00781             ast_console_puts(buf);
    00782          }
    00783       /* File channels */
    00784       } else if ((chan->logmask & (1 << level)) && (chan->fileptr)) {
    00785          int res;
    00786          snprintf(buf, sizeof(buf), option_timestamp ? "[%s] %s[%ld]: " : "%s %s[%ld] %s: ", date,
    00787             levels[level], (long)GETTID(), file);
    00788          res = fprintf(chan->fileptr, buf);
    00789          if (res <= 0 && buf[0] != '\0') {   /* Error, no characters printed */
    00790             fprintf(stderr,"**** Asterisk Logging Error: ***********\n");
    00791             if (errno == ENOMEM || errno == ENOSPC) {
    00792                fprintf(stderr, "Asterisk logging error: Out of disk space, can't log to log file %s\n", chan->filename);
    00793             } else
    00794                fprintf(stderr, "Logger Warning: Unable to write to log file '%s': %s (disabled)\n", chan->filename, strerror(errno));
    00795             manager_event(EVENT_FLAG_SYSTEM, "LogChannel", "Channel: %s\r\nEnabled: No\r\nReason: %d - %s\r\n", chan->filename, errno, strerror(errno));
    00796             chan->disabled = 1;
    00797          } else {
    00798             /* No error message, continue printing */
    00799             va_start(ap, fmt);
    00800             vsnprintf(buf, sizeof(buf), fmt, ap);
    00801             va_end(ap);
    00802             term_strip(buf, buf, sizeof(buf));
    00803             fputs(buf, chan->fileptr);
    00804             fflush(chan->fileptr);
    00805          }
    00806       }
    00807       chan = chan->next;
    00808    }
    00809
    00810    ast_mutex_unlock(&loglock);
    00811    /* end critical section */
    00812    if (filesize_reload_needed) {
    00813       reload_logger(1);
    00814       ast_log(LOG_EVENT,"Rotated Logs Per SIGXFSZ (Exceeded file size limit)\n");
    00815       if (option_verbose)
    00816          ast_verbose("Rotated Logs Per SIGXFSZ (Exceeded file size limit)\n");
    00817    }
    00818 }

static void ast_log_vsyslog | ( | int | level,
|  | const char * | file,
|  | int | line,
|  | const char * | function,
|  | const char * | fmt,
|  | va_list | args |
| ) |  |  | `[static]`

Definition at line 664 of file logger.c.

References __LOG_DEBUG, __LOG_DTMF, __LOG_VERBOSE, GETTID, levels, s, syslog_level_map, SYSLOG_NLEVELS, and term_strip().

Referenced by ast_log().

    00665 {
    00666    char buf[BUFSIZ];
    00667    char *s;
    00668
    00669    if (level >= SYSLOG_NLEVELS) {
    00670       /* we are locked here, so cannot ast_log() */
    00671       fprintf(stderr, "ast_log_vsyslog called with bogus level: %d\n", level);
    00672       return;
    00673    }
    00674    if (level == __LOG_VERBOSE) {
    00675       snprintf(buf, sizeof(buf), "VERBOSE[%ld]: ", (long)GETTID());
    00676       level = __LOG_DEBUG;
    00677    } else if (level == __LOG_DTMF) {
    00678       snprintf(buf, sizeof(buf), "DTMF[%ld]: ", (long)GETTID());
    00679       level = __LOG_DEBUG;
    00680    } else {
    00681       snprintf(buf, sizeof(buf), "%s[%ld]: %s:%d in %s: ",
    00682           levels[level], (long)GETTID(), file, line, function);
    00683    }
    00684    s = buf + strlen(buf);
    00685    vsnprintf(s, sizeof(buf) - strlen(buf), fmt, args);
    00686    term_strip(s, s, strlen(s) + 1);
    00687    syslog(syslog_level_map[level], "%s", buf);
    00688 }

AST_MUTEX_DEFINE_STATIC | ( | loglock |  | ) |

AST_MUTEX_DEFINE_STATIC | ( | msglist_lock |  | ) |

void ast_queue_log | ( | const char * | queuename,
|  | const char * | callid,
|  | const char * | agent,
|  | const char * | event,
|  | const char * | fmt,
|  |  | ... |
| ) |  |  |

Definition at line 367 of file logger.c.

References ast_mutex_lock(), ast_mutex_unlock(), and qlog.

Referenced by __login_exec(), action_agent_callback_login(), agent_hangup(), agent_logoff(), init_logger(), queue_exec(), reload_logger(), set_member_paused(), try_calling(), and wait_our_turn().

    00368 {
    00369    va_list ap;
    00370    ast_mutex_lock(&loglock);
    00371    if (qlog) {
    00372       va_start(ap, fmt);
    00373       fprintf(qlog, "%ld|%s|%s|%s|%s|", (long)time(NULL), callid, queuename, agent, event);
    00374       vfprintf(qlog, fmt, ap);
    00375       fprintf(qlog, "\n");
    00376       va_end(ap);
    00377       fflush(qlog);
    00378    }
    00379    ast_mutex_unlock(&loglock);
    00380 }

int ast_register_verbose | ( | void(*)(const char *string, int opos, int replacelast, int complete) | v | ) |

Definition at line 933 of file logger.c.

References ast_mutex_lock(), ast_mutex_unlock(), list, malloc, msglist::msg, msglist::next, verb::next, verboser, and verb::verboser.

Referenced by ast_makesocket(), main(), and show_console().

    00934 {
    00935    struct msglist *m;
    00936    struct verb *tmp;
    00937    /* XXX Should be more flexible here, taking > 1 verboser XXX */
    00938    if ((tmp = malloc(sizeof (struct verb)))) {
    00939       tmp->verboser = v;
    00940       ast_mutex_lock(&msglist_lock);
    00941       tmp->next = verboser;
    00942       verboser = tmp;
    00943       m = list;
    00944       while(m) {
    00945          /* Send all the existing entries that we have queued (i.e. they're likely to have missed) */
    00946          v(m->msg, 0, 0, 1);
    00947          m = m->next;
    00948       }
    00949       ast_mutex_unlock(&msglist_lock);
    00950       return 0;
    00951    }
    00952    return -1;
    00953 }

int ast_unregister_verbose | ( | void(*)(const char *string, int opos, int replacelast, int complete) | v | ) |

Definition at line 955 of file logger.c.

References ast_mutex_lock(), ast_mutex_unlock(), free, verb::next, verb::verboser, and verboser.

Referenced by exit_now().

    00956 {
    00957    int res = -1;
    00958    struct verb *tmp, *tmpl=NULL;
    00959    ast_mutex_lock(&msglist_lock);
    00960    tmp = verboser;
    00961    while(tmp) {
    00962       if (tmp->verboser == v) {
    00963          if (tmpl)
    00964             tmpl->next = tmp->next;
    00965          else
    00966             verboser = tmp->next;
    00967          free(tmp);
    00968          break;
    00969       }
    00970       tmpl = tmp;
    00971       tmp = tmp->next;
    00972    }
    00973    if (tmp)
    00974       res = 0;
    00975    ast_mutex_unlock(&msglist_lock);
    00976    return res;
    00977 }

void ast_verbose | ( | const char * | fmt,
|  |  | ... |
| ) |  |  |

Definition at line 820 of file logger.c.

References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), calloc, dateformat, free, last, list, LOG_ERROR, LOG_VERBOSE, MAX_MSG_QUEUE, msglist::msg, msgcnt, verb::next, msglist::next, ast_imager::next, option_timestamp, strdup, t, verb::verboser, and verboser.

Referenced by __agent_start_monitoring(), __ast_pbx_run(), __build_step(), __grab_token(), __load_resource(), __login_exec(), __sip_destroy(), __unload_module(), __zt_exception(), _while_exec(), accept_thread(), action_agent_callback_login(), add_codec_to_sdp(), add_noncodec_to_sdp(), add_realm_authentication(), add_sdp(), adsi_exec(), adsi_prog(), advanced_options(), agent_call(), agent_read(), agentmonitoroutgoing_exec(), agi_debug_cli(), alarmreceiver_exec(), alsa_answer(), alsa_call(), alsa_digit(), alsa_hangup(), alsa_text(), append_mapping(), arg_parse(), ast_ael_compile(), ast_app_has_voicemail(), ast_app_messagecount(), ast_cdr_unregister(), ast_channel_bridge(), ast_channel_register(), ast_channel_unregister(), ast_context_add_include2(), ast_context_add_switch2(), ast_context_create(), ast_custom_function_register(), ast_custom_function_unregister(), ast_dnsmgr_lookup(), ast_feature_interpret(), ast_feature_request_and_dial(), ast_format_register(), ast_format_unregister(), ast_frame_dump(), ast_image_register(), ast_image_unregister(), ast_log(), ast_manager_register_struct(), ast_manager_unregister(), ast_module_reload(), ast_moh_destroy(), ast_moh_start(), ast_netsock_bindaddr(), ast_park_call(), ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_pbx_run_app(), ast_play_and_prepend(), ast_play_and_record_full(), ast_record_review(), ast_register_application(), ast_register_feature(), ast_register_indication_country(), ast_register_translator(), ast_remotecontrol(), ast_rtp_raw_write(), ast_rtp_read(), ast_rtp_reload(), ast_rtp_sendcng(), ast_rtp_senddigit(), ast_say_number_full_he(), ast_set_indication_country(), ast_set_priority(), ast_streamfile(), ast_unregister_application(), ast_unregister_indication_country(), ast_unregister_translator(), async_wait(), attempt_reconnect(), attempt_thread(), attempt_transfer(), build_conf(), build_device(), build_gateway(), builtin_automonitor(), builtin_blindtransfer(), builtin_disconnect(), builtin_function_timeout_write(), cb_extensionstate(), channel_spy(), check_for_conference(), check_user_full(), check_via(), conf_exec(), conf_run(), config_text_file_load(), config_text_file_save(), cpeid_exec(), database_increment(), del_exec(), deltree_exec(), dial_exec_full(), dialout(), do_chanreads(), do_housekeeping(), do_monitor(), do_parking_thread(), do_register_auth(), do_waiting(), dumpchan_exec(), dundi_debug_output(), exit_now(), find_command(), find_subchannel_and_lock(), find_subchannel_by_name(), find_transcoders(), flash_exec(), function_ilink(), get_also_info(), get_callerid(), get_callerid_ast(), get_case(), get_destination(), get_exec(), get_rdnis(), get_refer_info(), grab_else(), h323_ep_hangup(), h323_reload(), handle_command_response(), handle_context(), handle_exec(), handle_getoption(), handle_init_event(), handle_macro(), handle_message(), handle_request(), handle_request_info(), handle_request_invite(), handle_request_message(), handle_request_register(), handle_request_subscribe(), handle_response(), handle_root_token(), handle_verbose(), i4l_read(), iax2_ack_registry(), iax2_bridge(), iax2_exec(), iax2_hangup(), iax2_prov_app(), iax_debug_output(), iax_provision_reload(), init_logger(), init_manager(), ivr_demo_func(), jb_debug_output(), launch_script(), leave_voicemail(), list_route(), listener(), load_config(), load_module(), load_modules(), load_pbx(), log_events(), lookupcidname_exec(), macro_exec(), main(), mgcp_answer(), mgcp_call(), mgcp_hangup(), mgcp_indicate(), mgcp_new(), mgcp_reload(), mgcp_request(), mgcp_ss(), mgcpsock_read(), misdn_call(), mixmonitor_thread(), modem_hangup(), modem_setup(), moh_alloc(), moh_files_alloc(), moh_files_release(), moh_release(), monitor_handle_notowned(), monitor_handle_owned(), netconsole(), odbc_do_query(), odbc_init(), odbc_load_module(), odbc_log(), odbc_unload_module(), oss_answer(), oss_call(), oss_digit(), oss_hangup(), oss_text(), park_exec(), parkandannounce_exec(), parse(), parse_config(), parse_register_contact(), parse_srv(), pbx_builtin_atimeout(), pbx_builtin_dtimeout(), pbx_builtin_goto(), pbx_builtin_pushvar_helper(), pbx_builtin_rtimeout(), pbx_builtin_setvar_helper(), pbx_builtin_waitexten(), pbx_extension_helper(), phone_check_exception(), phone_exception(), phone_hangup(), play_message_callerid(), play_record_review(), playtone(), privacy_exec(), process_ast_dsp(), process_message(), process_sdp(), put_exec(), queue_exec(), quit_handler(), random_exec(), read_exec(), realtime_exec(), receive_ademco_contact_id(), receive_dtmf_digits(), receive_message(), refresh_list(), reg_source_db(), reload_config(), reload_firmware(), reload_logger(), remap_feature(), resend_response(), restart_monitor(), retrans_pkt(), ring_entry(), rpt(), rpt_exec(), run_agi(), run_ras(), say_periodic_announcement(), say_position(), send_cwcidspill(), send_request(), send_response(), send_tone_burst(), session_do(), set_config(), set_destination(), setformat(), settransfercapability_exec(), setup_incoming_call(), setup_zap(), sip_getheader(), sip_reload(), sip_scheddestroy(), sip_sendtext(), sipsock_read(), skinny_answer(), skinny_call(), skinny_hangup(), skinny_indicate(), skinny_new(), skinny_request(), skinny_session(), skinny_ss(), sms_debug(), socket_read(), ss_thread(), stoptone(), store_config(), timing_read(), transmit_connect_with_sdp(), transmit_connection_del(), transmit_connection_del_w_params(), transmit_displaymessage(), transmit_displaynotify(), transmit_displaypromptstatus(), transmit_invite(), transmit_modify_request(), transmit_notify_request(), transmit_notify_request_with_callerid(), transmit_notify_with_mwi(), transmit_notify_with_sipfrag(), transmit_register(), transmit_reinvite_with_sdp(), transmit_response(), transmit_sip_request(), try_load_key(), unload_module(), update_registry(), verbose_exec(), vm_authenticate(), vm_execmain(), vpb_answer(), vpb_bridge(), vpb_call(), vpb_digit(), vpb_fixup(), vpb_hangup(), vpb_indicate(), vpb_new(), vpb_request(), vpb_write(), wait_for_answer(), waitforring_exec(), waitforsilence_exec(), write_metadata(), zap_frameout(), zapras_exec(), zt_call(), zt_handle_dtmfup(), zt_handle_event(), zt_hangup(), zt_read(), and zt_request().

    00821 {
    00822    static char stuff[4096];
    00823    static int len = 0;
    00824    static int replacelast = 0;
    00825
    00826    int complete;
    00827    int olen;
    00828    struct msglist *m;
    00829    struct verb *v;
    00830
    00831    va_list ap;
    00832    va_start(ap, fmt);
    00833
    00834    if (option_timestamp) {
    00835       time_t t;
    00836       struct tm tm;
    00837       char date[40];
    00838       char *datefmt;
    00839
    00840       time(&t);
    00841       localtime_r(&t, &tm);
    00842       strftime(date, sizeof(date), dateformat, &tm);
    00843       datefmt = alloca(strlen(date) + 3 + strlen(fmt) + 1);
    00844       if (datefmt) {
    00845          sprintf(datefmt, "[%s] %s", date, fmt);
    00846          fmt = datefmt;
    00847       }
    00848    }
    00849
    00850    /* this lock is also protecting against multiple threads
    00851       being in this function at the same time, so it must be
    00852       held before any of the static variables are accessed
    00853    */
    00854    ast_mutex_lock(&msglist_lock);
    00855
    00856    /* there is a potential security problem here: if formatting
    00857       the current date using 'dateformat' results in a string
    00858       containing '%', then the vsnprintf() call below will
    00859       probably try to access random memory
    00860    */
    00861    vsnprintf(stuff + len, sizeof(stuff) - len, fmt, ap);
    00862    va_end(ap);
    00863
    00864    olen = len;
    00865    len = strlen(stuff);
    00866
    00867    complete = (stuff[len - 1] == '\n') ? 1 : 0;
    00868
    00869    /* If we filled up the stuff completely, then log it even without the '\n' */
    00870    if (len >= sizeof(stuff) - 1) {
    00871       complete = 1;
    00872       len = 0;
    00873    }
    00874
    00875    if (complete) {
    00876       if (msgcnt < MAX_MSG_QUEUE) {
    00877          /* Allocate new structure */
    00878          if ((m = calloc(1, sizeof(*m))))
    00879             msgcnt++;
    00880       } else {
    00881          /* Recycle the oldest entry */
    00882          m = list;
    00883          list = list->next;
    00884          if (m->msg)
    00885             free(m->msg);
    00886       }
    00887       if (m) {
    00888          m->msg = strdup(stuff);
    00889          if (m->msg) {
    00890             if (last)
    00891                last->next = m;
    00892             else
    00893                list = m;
    00894             m->next = NULL;
    00895             last = m;
    00896          } else {
    00897             msgcnt--;
    00898             ast_log(LOG_ERROR, "Out of memory\n");
    00899             free(m);
    00900          }
    00901       }
    00902    }
    00903
    00904    for (v = verboser; v; v = v->next)
    00905       v->verboser(stuff, olen, replacelast, complete);
    00906
    00907    ast_log(LOG_VERBOSE, "%s", stuff);
    00908
    00909    if (len) {
    00910       if (!complete)
    00911          replacelast = 1;
    00912       else
    00913          replacelast = len = 0;
    00914    }
    00915
    00916    ast_mutex_unlock(&msglist_lock);
    00917 }

int ast_verbose_dmesg | ( | void(*)(const char *string, int opos, int replacelast, int complete) | v | ) |

Definition at line 919 of file logger.c.

References ast_mutex_lock(), ast_mutex_unlock(), list, msglist::msg, and msglist::next.

    00920 {
    00921    struct msglist *m;
    00922    ast_mutex_lock(&msglist_lock);
    00923    m = list;
    00924    while(m) {
    00925       /* Send all the existing entries that we have queued (i.e. they're likely to have missed) */
    00926       v(m->msg, 0, 0, 1);
    00927       m = m->next;
    00928    }
    00929    ast_mutex_unlock(&msglist_lock);
    00930    return 0;
    00931 }

void close_logger | ( | void |  | ) |

Definition at line 644 of file logger.c.

References ast_mutex_lock(), ast_mutex_unlock(), free, last, list, msglist::msg, msgcnt, and msglist::next.

Referenced by quit_handler().

    00645 {
    00646    struct msglist *m, *tmp;
    00647
    00648    ast_mutex_lock(&msglist_lock);
    00649    m = list;
    00650    while(m) {
    00651       if (m->msg) {
    00652          free(m->msg);
    00653       }
    00654       tmp = m->next;
    00655       free(m);
    00656       m = tmp;
    00657    }
    00658    list = last = NULL;
    00659    msgcnt = 0;
    00660    ast_mutex_unlock(&msglist_lock);
    00661    return;
    00662 }

static int handle_logger_reload | ( | int | fd,
|  | int | argc,
|  | char * | argv[] |
| ) |  |  | `[static]`

Definition at line 503 of file logger.c.

References ast_cli(), reload_logger(), RESULT_FAILURE, and RESULT_SUCCESS.

    00504 {
    00505    if(reload_logger(0)) {
    00506       ast_cli(fd, "Failed to reload the logger\n");
    00507       return RESULT_FAILURE;
    00508    } else
    00509       return RESULT_SUCCESS;
    00510 }

static int handle_logger_rotate | ( | int | fd,
|  | int | argc,
|  | char * | argv[] |
| ) |  |  | `[static]`

Definition at line 512 of file logger.c.

References ast_cli(), reload_logger(), RESULT_FAILURE, and RESULT_SUCCESS.

    00513 {
    00514    if(reload_logger(1)) {
    00515       ast_cli(fd, "Failed to reload the logger and rotate log files\n");
    00516       return RESULT_FAILURE;
    00517    } else
    00518       return RESULT_SUCCESS;
    00519 }

static int handle_logger_show_channels | ( | int | fd,
|  | int | argc,
|  | char * | argv[] |
| ) |  |  | `[static]`

Definition at line 523 of file logger.c.

References __LOG_DEBUG, __LOG_DTMF, __LOG_ERROR, __LOG_EVENT, __LOG_NOTICE, __LOG_VERBOSE, __LOG_WARNING, ast_cli(), ast_mutex_lock(), ast_mutex_unlock(), logchannel::disabled, logchannel::filename, FORMATL, logchannel::logmask, LOGTYPE_CONSOLE, LOGTYPE_SYSLOG, logchannel::next, RESULT_SUCCESS, and logchannel::type.

    00524 {
    00525 #define FORMATL   "%-35.35s %-8.8s %-9.9s "
    00526    struct logchannel *chan;
    00527
    00528    ast_mutex_lock(&loglock);
    00529
    00530    chan = logchannels;
    00531    ast_cli(fd,FORMATL, "Channel", "Type", "Status");
    00532    ast_cli(fd, "Configuration\n");
    00533    ast_cli(fd,FORMATL, "-------", "----", "------");
    00534    ast_cli(fd, "-------------\n");
    00535    while (chan) {
    00536       ast_cli(fd, FORMATL, chan->filename, chan->type==LOGTYPE_CONSOLE ? "Console" : (chan->type==LOGTYPE_SYSLOG ? "Syslog" : "File"),
    00537          chan->disabled ? "Disabled" : "Enabled");
    00538       ast_cli(fd, " - ");
    00539       if (chan->logmask & (1 << __LOG_DEBUG))
    00540          ast_cli(fd, "Debug ");
    00541       if (chan->logmask & (1 << __LOG_DTMF))
    00542          ast_cli(fd, "DTMF ");
    00543       if (chan->logmask & (1 << __LOG_VERBOSE))
    00544          ast_cli(fd, "Verbose ");
    00545       if (chan->logmask & (1 << __LOG_WARNING))
    00546          ast_cli(fd, "Warning ");
    00547       if (chan->logmask & (1 << __LOG_NOTICE))
    00548          ast_cli(fd, "Notice ");
    00549       if (chan->logmask & (1 << __LOG_ERROR))
    00550          ast_cli(fd, "Error ");
    00551       if (chan->logmask & (1 << __LOG_EVENT))
    00552          ast_cli(fd, "Event ");
    00553       ast_cli(fd, "\n");
    00554       chan = chan->next;
    00555    }
    00556    ast_cli(fd, "\n");
    00557
    00558    ast_mutex_unlock(&loglock);
    00559
    00560    return RESULT_SUCCESS;
    00561 }

static int handle_SIGXFSZ | ( | int | sig | ) | `[static]`

Definition at line 596 of file logger.c.

References filesize_reload_needed.

Referenced by init_logger().

    00597 {
    00598    /* Indicate need to reload */
    00599    filesize_reload_needed = 1;
    00600    return 0;
    00601 }

int init_logger | ( | void |  | ) |

Definition at line 603 of file logger.c.

References ast_cli_register(), ast_config_AST_LOG_DIR, ast_log(), ast_queue_log(), ast_verbose(), eventlog, EVENTLOG, handle_SIGXFSZ(), init_logger_chain(), LOG_ERROR, LOG_EVENT, logfiles, option_verbose, qlog, and QUEUELOG.

Referenced by main().

    00604 {
    00605    char tmp[256];
    00606    int res = 0;
    00607
    00608    /* auto rotate if sig SIGXFSZ comes a-knockin */
    00609    (void) signal(SIGXFSZ,(void *) handle_SIGXFSZ);
    00610
    00611    /* register the relaod logger cli command */
    00612    ast_cli_register(&reload_logger_cli);
    00613    ast_cli_register(&rotate_logger_cli);
    00614    ast_cli_register(&logger_show_channels_cli);
    00615
    00616    mkdir((char *)ast_config_AST_LOG_DIR, 0755);
    00617
    00618    /* create log channels */
    00619    init_logger_chain();
    00620
    00621    /* create the eventlog */
    00622    if (logfiles.event_log) {
    00623       mkdir((char *)ast_config_AST_LOG_DIR, 0755);
    00624       snprintf(tmp, sizeof(tmp), "%s/%s", (char *)ast_config_AST_LOG_DIR, EVENTLOG);
    00625       eventlog = fopen((char *)tmp, "a");
    00626       if (eventlog) {
    00627          ast_log(LOG_EVENT, "Started Asterisk Event Logger\n");
    00628          if (option_verbose)
    00629             ast_verbose("Asterisk Event Logger Started %s\n",(char *)tmp);
    00630       } else {
    00631          ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno));
    00632          res = -1;
    00633       }
    00634    }
    00635
    00636    if (logfiles.queue_log) {
    00637       snprintf(tmp, sizeof(tmp), "%s/%s", (char *)ast_config_AST_LOG_DIR, QUEUELOG);
    00638       qlog = fopen(tmp, "a");
    00639       ast_queue_log("NONE", "NONE", "NONE", "QUEUESTART", "%s", "");
    00640    }
    00641    return res;
    00642 }

static void init_logger_chain | ( | void |  | ) | `[static]`

Definition at line 289 of file logger.c.

References ast_config_destroy(), ast_config_load(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_true(), ast_variable_browse(), ast_variable_retrieve(), cfg, dateformat, free, global_logmask, hostname, ast_variable::lineno, LOG_WARNING, logfiles, logchannel::logmask, LOGTYPE_CONSOLE, make_logchannel(), malloc, ast_variable::name, ast_variable::next, logchannel::next, s, logchannel::type, ast_variable::value, and var.

Referenced by init_logger(), and reload_logger().

    00290 {
    00291    struct logchannel *chan, *cur;
    00292    struct ast_config *cfg;
    00293    struct ast_variable *var;
    00294    char *s;
    00295
    00296    /* delete our list of log channels */
    00297    ast_mutex_lock(&loglock);
    00298    chan = logchannels;
    00299    while (chan) {
    00300       cur = chan->next;
    00301       free(chan);
    00302       chan = cur;
    00303    }
    00304    logchannels = NULL;
    00305    ast_mutex_unlock(&loglock);
    00306
    00307    global_logmask = 0;
    00308    errno = 0;
    00309    /* close syslog */
    00310    closelog();
    00311
    00312    cfg = ast_config_load("logger.conf");
    00313
    00314    /* If no config file, we're fine, set default options. */
    00315    if (!cfg) {
    00316       if (errno)
    00317          fprintf(stderr, "Unable to open logger.conf: %s; default settings will be used.\n", strerror(errno));
    00318       else
    00319          fprintf(stderr, "Errors detected in logger.conf: see above; default settings will be used.\n");
    00320       chan = malloc(sizeof(struct logchannel));
    00321       memset(chan, 0, sizeof(struct logchannel));
    00322       chan->type = LOGTYPE_CONSOLE;
    00323       chan->logmask = 28; /*warning,notice,error */
    00324       chan->next = logchannels;
    00325       logchannels = chan;
    00326       global_logmask |= chan->logmask;
    00327       return;
    00328    }
    00329
    00330    ast_mutex_lock(&loglock);
    00331    if ((s = ast_variable_retrieve(cfg, "general", "appendhostname"))) {
    00332       if(ast_true(s)) {
    00333          if(gethostname(hostname, sizeof(hostname)-1)) {
    00334             ast_copy_string(hostname, "unknown", sizeof(hostname));
    00335             ast_log(LOG_WARNING, "What box has no hostname???\n");
    00336          }
    00337       } else
    00338          hostname[0] = '\0';
    00339    } else
    00340       hostname[0] = '\0';
    00341    if ((s = ast_variable_retrieve(cfg, "general", "dateformat"))) {
    00342       ast_copy_string(dateformat, s, sizeof(dateformat));
    00343    } else
    00344       ast_copy_string(dateformat, "%b %e %T", sizeof(dateformat));
    00345    if ((s = ast_variable_retrieve(cfg, "general", "queue_log"))) {
    00346       logfiles.queue_log = ast_true(s);
    00347    }
    00348    if ((s = ast_variable_retrieve(cfg, "general", "event_log"))) {
    00349       logfiles.event_log = ast_true(s);
    00350    }
    00351
    00352    var = ast_variable_browse(cfg, "logfiles");
    00353    while(var) {
    00354       chan = make_logchannel(var->name, var->value, var->lineno);
    00355       if (chan) {
    00356          chan->next = logchannels;
    00357          logchannels = chan;
    00358          global_logmask |= chan->logmask;
    00359       }
    00360       var = var->next;
    00361    }
    00362
    00363    ast_config_destroy(cfg);
    00364    ast_mutex_unlock(&loglock);
    00365 }

static int make_components | ( | char * | s,
|  | int | lineno |
| ) |  |  | `[static]`

Definition at line 141 of file logger.c.

References __LOG_DEBUG, __LOG_DTMF, __LOG_ERROR, __LOG_EVENT, __LOG_NOTICE, __LOG_VERBOSE, __LOG_WARNING, and strsep().

Referenced by make_logchannel().

    00142 {
    00143    char *w;
    00144    int res = 0;
    00145    char *stringp=NULL;
    00146    stringp=s;
    00147    w = strsep(&stringp, ",");
    00148    while(w) {
    00149       while(*w && (*w < 33))
    00150          w++;
    00151       if (!strcasecmp(w, "error"))
    00152          res |= (1 << __LOG_ERROR);
    00153       else if (!strcasecmp(w, "warning"))
    00154          res |= (1 << __LOG_WARNING);
    00155       else if (!strcasecmp(w, "notice"))
    00156          res |= (1 << __LOG_NOTICE);
    00157       else if (!strcasecmp(w, "event"))
    00158          res |= (1 << __LOG_EVENT);
    00159       else if (!strcasecmp(w, "debug"))
    00160          res |= (1 << __LOG_DEBUG);
    00161       else if (!strcasecmp(w, "verbose"))
    00162          res |= (1 << __LOG_VERBOSE);
    00163       else if (!strcasecmp(w, "dtmf"))
    00164          res |= (1 << __LOG_DTMF);
    00165       else {
    00166          fprintf(stderr, "Logfile Warning: Unknown keyword '%s' at line %d of logger.conf\n", w, lineno);
    00167       }
    00168       w = strsep(&stringp, ",");
    00169    }
    00170    return res;
    00171 }

static struct logchannel* make_logchannel | ( | char * | channel,
|  | char * | components,
|  | int | lineno |
| ) |  |  | `[static, read]`

Definition at line 173 of file logger.c.

References ast_config_AST_LOG_DIR, ast_strlen_zero(), logchannel::facility, logchannel::filename, logchannel::fileptr, free, hostname, logchannel::logmask, LOGTYPE_CONSOLE, LOGTYPE_FILE, LOGTYPE_SYSLOG, make_components(), malloc, and logchannel::type.

Referenced by init_logger_chain().

    00174 {
    00175    struct logchannel *chan;
    00176    char *facility;
    00177 #ifndef SOLARIS
    00178    CODE *cptr;
    00179 #endif
    00180
    00181    if (ast_strlen_zero(channel))
    00182       return NULL;
    00183    chan = malloc(sizeof(struct logchannel));
    00184
    00185    if (!chan)  /* Can't allocate memory */
    00186       return NULL;
    00187
    00188    memset(chan, 0, sizeof(struct logchannel));
    00189    if (!strcasecmp(channel, "console")) {
    00190       chan->type = LOGTYPE_CONSOLE;
    00191    } else if (!strncasecmp(channel, "syslog", 6)) {
    00192       /*
    00193       * syntax is:
    00194       *  syslog.facility => level,level,level
    00195       */
    00196       facility = strchr(channel, '.');
    00197       if(!facility++ || !facility) {
    00198          facility = "local0";
    00199       }
    00200
    00201 #ifndef SOLARIS
    00202       /*
    00203       * Walk through the list of facilitynames (defined in sys/syslog.h)
    00204       * to see if we can find the one we have been given
    00205       */
    00206       chan->facility = -1;
    00207       cptr = facilitynames;
    00208       while (cptr->c_name) {
    00209          if (!strcasecmp(facility, cptr->c_name)) {
    00210             chan->facility = cptr->c_val;
    00211             break;
    00212          }
    00213          cptr++;
    00214       }
    00215 #else
    00216       chan->facility = -1;
    00217       if (!strcasecmp(facility, "kern"))
    00218          chan->facility = LOG_KERN;
    00219       else if (!strcasecmp(facility, "USER"))
    00220          chan->facility = LOG_USER;
    00221       else if (!strcasecmp(facility, "MAIL"))
    00222          chan->facility = LOG_MAIL;
    00223       else if (!strcasecmp(facility, "DAEMON"))
    00224          chan->facility = LOG_DAEMON;
    00225       else if (!strcasecmp(facility, "AUTH"))
    00226          chan->facility = LOG_AUTH;
    00227       else if (!strcasecmp(facility, "SYSLOG"))
    00228          chan->facility = LOG_SYSLOG;
    00229       else if (!strcasecmp(facility, "LPR"))
    00230          chan->facility = LOG_LPR;
    00231       else if (!strcasecmp(facility, "NEWS"))
    00232          chan->facility = LOG_NEWS;
    00233       else if (!strcasecmp(facility, "UUCP"))
    00234          chan->facility = LOG_UUCP;
    00235       else if (!strcasecmp(facility, "CRON"))
    00236          chan->facility = LOG_CRON;
    00237       else if (!strcasecmp(facility, "LOCAL0"))
    00238          chan->facility = LOG_LOCAL0;
    00239       else if (!strcasecmp(facility, "LOCAL1"))
    00240          chan->facility = LOG_LOCAL1;
    00241       else if (!strcasecmp(facility, "LOCAL2"))
    00242          chan->facility = LOG_LOCAL2;
    00243       else if (!strcasecmp(facility, "LOCAL3"))
    00244          chan->facility = LOG_LOCAL3;
    00245       else if (!strcasecmp(facility, "LOCAL4"))
    00246          chan->facility = LOG_LOCAL4;
    00247       else if (!strcasecmp(facility, "LOCAL5"))
    00248          chan->facility = LOG_LOCAL5;
    00249       else if (!strcasecmp(facility, "LOCAL6"))
    00250          chan->facility = LOG_LOCAL6;
    00251       else if (!strcasecmp(facility, "LOCAL7"))
    00252          chan->facility = LOG_LOCAL7;
    00253 #endif /* Solaris */
    00254
    00255       if (0 > chan->facility) {
    00256          fprintf(stderr, "Logger Warning: bad syslog facility in logger.conf\n");
    00257          free(chan);
    00258          return NULL;
    00259       }
    00260
    00261       chan->type = LOGTYPE_SYSLOG;
    00262       snprintf(chan->filename, sizeof(chan->filename), "%s", channel);
    00263       openlog("asterisk", LOG_PID, chan->facility);
    00264    } else {
    00265       if (channel[0] == '/') {
    00266          if(!ast_strlen_zero(hostname)) {
    00267             snprintf(chan->filename, sizeof(chan->filename) - 1,"%s.%s", channel, hostname);
    00268          } else {
    00269             ast_copy_string(chan->filename, channel, sizeof(chan->filename));
    00270          }
    00271       }
    00272
    00273       if(!ast_strlen_zero(hostname)) {
    00274          snprintf(chan->filename, sizeof(chan->filename), "%s/%s.%s",(char *)ast_config_AST_LOG_DIR, channel, hostname);
    00275       } else {
    00276          snprintf(chan->filename, sizeof(chan->filename), "%s/%s", (char *)ast_config_AST_LOG_DIR, channel);
    00277       }
    00278       chan->fileptr = fopen(chan->filename, "a");
    00279       if (!chan->fileptr) {
    00280          /* Can't log here, since we're called with a lock */
    00281          fprintf(stderr, "Logger Warning: Unable to open log file '%s': %s\n", chan->filename, strerror(errno));
    00282       }
    00283       chan->type = LOGTYPE_FILE;
    00284    }
    00285    chan->logmask = make_components(components, lineno);
    00286    return chan;
    00287 }

int reload_logger | ( | int | rotate | ) |

Definition at line 382 of file logger.c.

References ast_config_AST_LOG_DIR, AST_CONFIG_MAX_PATH, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_queue_log(), ast_verbose(), logchannel::disabled, EVENT_FLAG_SYSTEM, EVENTLOG, eventlog, logchannel::filename, logchannel::fileptr, filesize_reload_needed, init_logger_chain(), LOG_ERROR, LOG_EVENT, logfiles, manager_event(), logchannel::next, option_verbose, qlog, and QUEUELOG.

Referenced by ast_log(), handle_logger_reload(), handle_logger_rotate(), and main().

    00383 {
    00384    char old[AST_CONFIG_MAX_PATH] = "";
    00385    char new[AST_CONFIG_MAX_PATH];
    00386    int event_rotate = rotate, queue_rotate = rotate;
    00387    struct logchannel *f;
    00388    FILE *myf;
    00389    int x, res = 0;
    00390
    00391    ast_mutex_lock(&msglist_lock);   /* to avoid deadlock */
    00392    ast_mutex_lock(&loglock);
    00393    if (eventlog)
    00394       fclose(eventlog);
    00395    else
    00396       event_rotate = 0;
    00397    eventlog = NULL;
    00398
    00399    if (qlog)
    00400       fclose(qlog);
    00401    else
    00402       queue_rotate = 0;
    00403    qlog = NULL;
    00404
    00405    mkdir((char *)ast_config_AST_LOG_DIR, 0755);
    00406
    00407    f = logchannels;
    00408    while(f) {
    00409       if (f->disabled) {
    00410          f->disabled = 0;  /* Re-enable logging at reload */
    00411          manager_event(EVENT_FLAG_SYSTEM, "LogChannel", "Channel: %s\r\nEnabled: Yes\r\n", f->filename);
    00412       }
    00413       if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) {
    00414          fclose(f->fileptr);  /* Close file */
    00415          f->fileptr = NULL;
    00416          if(rotate) {
    00417             ast_copy_string(old, f->filename, sizeof(old));
    00418
    00419             for(x=0;;x++) {
    00420                snprintf(new, sizeof(new), "%s.%d", f->filename, x);
    00421                myf = fopen((char *)new, "r");
    00422                if (myf) {
    00423                   fclose(myf);
    00424                } else {
    00425                   break;
    00426                }
    00427             }
    00428
    00429             /* do it */
    00430             if (rename(old,new))
    00431                fprintf(stderr, "Unable to rename file '%s' to '%s'\n", old, new);
    00432          }
    00433       }
    00434       f = f->next;
    00435    }
    00436
    00437    filesize_reload_needed = 0;
    00438
    00439    init_logger_chain();
    00440
    00441    if (logfiles.event_log) {
    00442       snprintf(old, sizeof(old), "%s/%s", (char *)ast_config_AST_LOG_DIR, EVENTLOG);
    00443       if (event_rotate) {
    00444          for (x=0;;x++) {
    00445             snprintf(new, sizeof(new), "%s/%s.%d", (char *)ast_config_AST_LOG_DIR, EVENTLOG,x);
    00446             myf = fopen((char *)new, "r");
    00447             if (myf)    /* File exists */
    00448                fclose(myf);
    00449             else
    00450                break;
    00451          }
    00452
    00453          /* do it */
    00454          if (rename(old,new))
    00455             ast_log(LOG_ERROR, "Unable to rename file '%s' to '%s'\n", old, new);
    00456       }
    00457
    00458       eventlog = fopen(old, "a");
    00459       if (eventlog) {
    00460          ast_log(LOG_EVENT, "Restarted Asterisk Event Logger\n");
    00461          if (option_verbose)
    00462             ast_verbose("Asterisk Event Logger restarted\n");
    00463       } else {
    00464          ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno));
    00465          res = -1;
    00466       }
    00467    }
    00468
    00469    if (logfiles.queue_log) {
    00470       snprintf(old, sizeof(old), "%s/%s", (char *)ast_config_AST_LOG_DIR, QUEUELOG);
    00471       if (queue_rotate) {
    00472          for (x = 0; ; x++) {
    00473             snprintf(new, sizeof(new), "%s/%s.%d", (char *)ast_config_AST_LOG_DIR, QUEUELOG, x);
    00474             myf = fopen((char *)new, "r");
    00475             if (myf)    /* File exists */
    00476                fclose(myf);
    00477             else
    00478                break;
    00479          }
    00480
    00481          /* do it */
    00482          if (rename(old, new))
    00483             ast_log(LOG_ERROR, "Unable to rename file '%s' to '%s'\n", old, new);
    00484       }
    00485
    00486       qlog = fopen(old, "a");
    00487       if (qlog) {
    00488          ast_queue_log("NONE", "NONE", "NONE", "CONFIGRELOAD", "%s", "");
    00489          ast_log(LOG_EVENT, "Restarted Asterisk Queue Logger\n");
    00490          if (option_verbose)
    00491             ast_verbose("Asterisk Queue Logger restarted\n");
    00492       } else {
    00493          ast_log(LOG_ERROR, "Unable to create queue log: %s\n", strerror(errno));
    00494          res = -1;
    00495       }
    00496    }
    00497    ast_mutex_unlock(&loglock);
    00498    ast_mutex_unlock(&msglist_lock);
    00499
    00500    return res;
    00501 }

## Variable Documentation

int colors[]`[static]`

Definition at line 131 of file logger.c.

Referenced by ast_log().

char dateformat[256] = "%b %e %T"`[static]`

Definition at line 79 of file logger.c.

Referenced by ast_log(), ast_verbose(), and init_logger_chain().

unsigned int event_log

Definition at line 88 of file logger.c.

FILE* eventlog = NULL`[static]`

Definition at line 118 of file logger.c.

Referenced by ast_log(), init_logger(), and reload_logger().

int filesize_reload_needed = 0`[static]`

Definition at line 83 of file logger.c.

Referenced by ast_log(), handle_SIGXFSZ(), and reload_logger().

int global_logmask = -1`[static]`

Definition at line 84 of file logger.c.

Referenced by ast_log(), and init_logger_chain().

char hostname[MAXHOSTNAMELEN]`[static]`

Definition at line 96 of file logger.c.

Referenced by ast_remotecontrol(), cli_prompt(), iax2_register(), init_logger_chain(), main(), make_logchannel(), netconsole(), set_destination(), and sip_register().

struct msglist * last`[static]`

Referenced by __verboser(), ao2_callback(), arg_free(), ast_channel_free(), ast_channel_unregister(), ast_config_engine_deregister(), ast_db_freetree(), ast_db_gettree(), ast_generic_bridge(), ast_sched_del(), ast_unregister_modem_driver(), ast_verbose(), close_logger(), config_odbc(), crypto_load(), directory_exec(), do_monitor(), iax2_bridge(), load_password(), matches_label(), queue_frame_to_spies(), scan_thread(), schedule(), and try_firmware().

char* levels[]`[static]`

Definition at line 121 of file logger.c.

Referenced by ast_log(), and ast_log_vsyslog().

struct msglist * list`[static]`

struct logchannel* logchannels = NULL`[static]`

Definition at line 114 of file logger.c.

struct { ... } logfiles`[static]`

Referenced by ast_log(), init_logger(), init_logger_chain(), and reload_logger().

char logger_reload_help[]`[static]`

Initial value:

    "Usage: logger reload\n"
    "       Reloads the logger subsystem state.  Use after restarting syslogd(8) if you are using syslog logging.\n"

Definition at line 569 of file logger.c.

char logger_rotate_help[]`[static]`

Initial value:

    "Usage: logger rotate\n"
    "       Rotates and Reopens the log files.\n"

Definition at line 573 of file logger.c.

struct ast_cli_entry logger_show_channels_cli`[static]`

Initial value:

       { { "logger", "show", "channels", NULL },
       handle_logger_show_channels, "List configured log channels",
       logger_show_channels_help }

Definition at line 581 of file logger.c.

char logger_show_channels_help[]`[static]`

Initial value:

    "Usage: logger show channels\n"
    "       Show configured logger channels.\n"

Definition at line 577 of file logger.c.

int msgcnt = 0`[static]`

Definition at line 116 of file logger.c.

Referenced by ast_verbose(), and close_logger().

FILE* qlog = NULL`[static]`

Definition at line 119 of file logger.c.

Referenced by ast_queue_log(), init_logger(), and reload_logger().

unsigned int queue_log

Definition at line 87 of file logger.c.

struct ast_cli_entry reload_logger_cli`[static]`

Initial value:

       { { "logger", "reload", NULL },
       handle_logger_reload, "Reopens the log files",
       logger_reload_help }

Definition at line 586 of file logger.c.

struct ast_cli_entry rotate_logger_cli`[static]`

Initial value:

       { { "logger", "rotate", NULL },
       handle_logger_rotate, "Rotates and reopens the log files",
       logger_rotate_help }

Definition at line 591 of file logger.c.

int syslog_level_map[]`[static]`

Definition at line 44 of file logger.c.

Referenced by ast_log_vsyslog().

struct verb * verboser`[static]`

Referenced by ast_register_verbose(), ast_unregister_verbose(), ast_verbose(), exit_now(), and show_console().