Codename Pineapple

Home page | Mailing list | Docs

Last updated: Sat Feb 3 05:01:36 2007

Asterisk developer's documentation :: Codename Pineapple


logger.c File Reference


Detailed Description

Asterisk Logger.

Logging routines

Author:
Mark Spencer <markster@digium.com>

Definition in file logger.c.

#include "asterisk.h"
#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/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 "asterisk/threadstorage.h"
#include "asterisk/strings.h"

Include dependency graph for logger.c:

Go to the source code of this file.

Data Structures

struct  logchannel
struct  logmsg
struct  verb

Defines

#define FORMATL   "%-35.35s %-8.8s %-9.9s "
#define GETTID()   getpid()
#define LOG_BUF_INIT_SIZE   256
#define SYSLOG_NAMES
#define SYSLOG_NLEVELS   sizeof(syslog_level_map) / sizeof(int)
#define VERBOSE_BUF_INIT_SIZE   256

Enumerations

enum  logmsgtypes { LOGMSG_NORMAL = 0, LOGMSG_VERBOSE }
enum  logtypes { LOGTYPE_SYSLOG, LOGTYPE_FILE, LOGTYPE_CONSOLE }

Functions

void ast_backtrace (void)
static AST_LIST_HEAD_STATIC (verbosers, verb)
static AST_LIST_HEAD_STATIC (logmsgs, logmsg)
static AST_LIST_HEAD_STATIC (logchannels, logchannel)
void ast_log (int level, const char *file, int line, const char *function, const char *fmt,...)
 send log messages to syslog and/or the console
static void ast_log_vsyslog (int level, const char *file, int line, const char *function, char *str)
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))
 AST_THREADSTORAGE (log_buf)
 AST_THREADSTORAGE (verbose_buf)
int ast_unregister_verbose (void(*v)(const char *string))
void ast_verbose (const char *fmt,...)
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[])
 CLI command to show logging system configuration.
static int handle_SIGXFSZ (int sig)
int init_logger (void)
static void init_logger_chain (void)
static void logger_print_normal (struct logmsg *logmsg)
static void logger_print_verbose (struct logmsg *logmsg)
static void * logger_thread (void *data)
static int make_components (char *s, int lineno)
static struct logchannelmake_logchannel (char *channel, char *components, int lineno)
int reload_logger (int rotate)

Variables

static struct ast_cli_entry cli_logger []
static int close_logger_thread
static int colors []
static char dateformat [256] = "%b %e %T"
static FILE * eventlog
static int filesize_reload_needed
static int global_logmask = -1
static char hostname [MAXHOSTNAMELEN]
static char * levels []
static ast_cond_t logcond
struct {
   int   alarm
   const char *   description
   unsigned int   event_log:1
   char *   ext
   char *   mtype
   char *   name
   const char *   name
   rtpPayloadType   payloadType
   unsigned int   queue_log:1
   char *   subtype
   char *   type
   int   val
logfiles
static char logger_reload_help []
static char logger_rotate_help []
static char logger_show_channels_help []
static pthread_t logthread = AST_PTHREADT_NULL
static FILE * qlog
static char queue_log_name [256] = QUEUELOG
static int rotatetimestamp
static int syslog_level_map []


Define Documentation

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

Referenced by handle_logger_show_channels().

 
#define GETTID  )     getpid()
 

Definition at line 81 of file logger.c.

Referenced by ast_log_vsyslog(), and logger_print_normal().

#define LOG_BUF_INIT_SIZE   256
 

Definition at line 166 of file logger.c.

Referenced by ast_log().

#define SYSLOG_NAMES
 

Definition at line 46 of file logger.c.

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

Definition at line 60 of file logger.c.

Referenced by ast_log_vsyslog().

#define VERBOSE_BUF_INIT_SIZE   256
 

Definition at line 163 of file logger.c.

Referenced by ast_verbose().


Enumeration Type Documentation

enum logmsgtypes
 

Enumerator:
LOGMSG_NORMAL 
LOGMSG_VERBOSE 

Definition at line 118 of file logger.c.

00118                  {
00119    LOGMSG_NORMAL = 0,
00120    LOGMSG_VERBOSE,
00121 };

enum logtypes
 

Enumerator:
LOGTYPE_SYSLOG 
LOGTYPE_FILE 
LOGTYPE_CONSOLE 

Definition at line 100 of file logger.c.

00100               {
00101    LOGTYPE_SYSLOG,
00102    LOGTYPE_FILE,
00103    LOGTYPE_CONSOLE,
00104 };


Function Documentation

void ast_backtrace void   ) 
 

Definition at line 955 of file logger.c.

References ast_calloc, ast_log(), free, and option_debug.

00956 {
00957 #ifdef STACK_BACKTRACES
00958    int count=0, i=0;
00959    void **addresses;
00960    char **strings;
00961 
00962    if ((addresses = ast_calloc(MAX_BACKTRACE_FRAMES, sizeof(*addresses)))) {
00963       count = backtrace(addresses, MAX_BACKTRACE_FRAMES);
00964       if ((strings = backtrace_symbols(addresses, count))) {
00965          if (option_debug)
00966             ast_log(LOG_DEBUG, "Got %d backtrace record%c\n", count, count != 1 ? 's' : ' ');
00967          for (i=0; i < count ; i++) {
00968             if (option_debug)
00969                ast_log(LOG_DEBUG, "#%d: [%08X] %s\n", i, (unsigned int)addresses[i], strings[i]);
00970          }
00971          free(strings);
00972       } else {
00973          if (option_debug)
00974             ast_log(LOG_DEBUG, "Could not allocate memory for backtrace\n");
00975       }
00976       free(addresses);
00977    }
00978 #else
00979 #ifdef Linux
00980    ast_log(LOG_WARNING, "Must compile with 'make dont-optimize' for stack backtraces\n");
00981 #else
00982    ast_log(LOG_WARNING, "Inline stack backtraces are only available on the Linux platform.\n");
00983 #endif
00984 #endif
00985 }

static AST_LIST_HEAD_STATIC verbosers  ,
verb 
[static]
 

static AST_LIST_HEAD_STATIC logmsgs  ,
logmsg 
[static]
 

static AST_LIST_HEAD_STATIC logchannels  ,
logchannel 
[static]
 

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

send log messages to syslog and/or the console

Definition at line 864 of file logger.c.

References __LOG_DEBUG, __LOG_VERBOSE, ast_calloc, ast_cond_signal(), AST_LIST_EMPTY, AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_UNLOCK, AST_PTHREADT_NULL, ast_str_set_va, ast_strlen_zero(), debug_filename, free, LOG_BUF_INIT_SIZE, logcond, logger_print_normal(), LOGMSG_NORMAL, logthread, option_debug, option_verbose, ast_str::str, and term_filter_escapes().

Referenced by __adsi_transmit_messages(), __agent_start_monitoring(), __ast_check_signature(), __ast_check_signature_bin(), __ast_cli_unregister(), __ast_context_create(), __ast_context_destroy(), __ast_decrypt_bin(), __ast_device_state_changed_literal(), __ast_dsp_call_progress(), __ast_encrypt_bin(), __ast_format_register(), __ast_pbx_run(), __ast_play_and_record(), __ast_read(), __ast_register_translator(), __ast_request_and_dial(), __ast_sign_bin(), __ast_smoother_feed(), __attempt_transmit(), __auto_congest(), __expire_registry(), __get_header(), __iax2_poke_noanswer(), __login_exec(), __mgcp_xmit(), __oh323_destroy(), __oh323_new(), __oh323_rtp_create(), __oh323_update_info(), __schedule_action(), __sip_ack(), __sip_autodestruct(), __sip_destroy(), __sip_pretend_ack(), __sip_reliable_xmit(), __sip_semi_ack(), __sip_xmit(), __transmit_response(), __unload_module(), __zt_exception(), _extension_match_core(), accept_thread(), ack_trans(), action_login(), action_waitevent(), add_agent(), add_codec_to_answer(), add_extensions(), add_header(), add_in_calls(), add_line(), add_out_calls(), add_realm_authentication(), add_redirect(), add_sdp(), add_sip_domain(), add_t38_sdp(), adsi_careful_send(), 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(), aji_act_hook(), aji_client_connect(), aji_client_info_handler(), aji_client_initialize(), aji_component_initialize(), aji_create_buddy(), aji_create_client(), aji_dinfo_handler(), aji_ditems_handler(), aji_find_version(), aji_handle_presence(), aji_handle_subscribe(), aji_load_config(), aji_recv_loop(), aji_register_approve_handler(), aji_register_query_handler(), aji_reload(), aji_send_exec(), aji_set_presence(), aji_status_exec(), alloc_sub(), alsa_card_init(), alsa_indicate(), alsa_new(), alsa_read(), alsa_request(), alsa_write(), answer_call(), append_transaction(), apply_outgoing(), ast_add_extension2(), ast_add_hint(), ast_adsi_begin_download(), ast_adsi_get_cpeid(), ast_adsi_get_cpeinfo(), ast_adsi_load_session(), ast_adsi_transmit_message_full(), ast_agi_register(), ast_aji_create_chat(), ast_aji_invite_chat(), ast_aji_join_chat(), ast_aji_send(), ast_app_dtget(), ast_app_parse_options(), ast_append_ha(), ast_apply_ha(), ast_async_goto(), ast_autoservice_start(), ast_backtrace(), ast_best_codec(), ast_bridge_call(), ast_cdr_detach(), ast_cdr_disposition(), ast_cdr_end(), ast_cdr_engine_init(), ast_cdr_free(), ast_cdr_init(), ast_cdr_register(), ast_cdr_serialize_variables(), ast_cdr_setvar(), ast_cdr_submit_batch(), ast_channel_alloc(), ast_channel_bridge(), ast_channel_free(), ast_channel_inherit_variables(), ast_channel_make_compatible_helper(), 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_codec_get_len(), ast_codec_get_samples(), ast_compile_ael2(), ast_config_engine_register(), ast_config_internal_load(), ast_context_verify_includes(), ast_control_streamfile(), ast_custom_function_register(), ast_db_del(), ast_db_get(), ast_db_gettree(), ast_db_put(), ast_device_state(), 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_enable_packet_fragmentation(), ast_extension_close(), ast_feature_interpret(), ast_feature_request_and_dial(), ast_filehelper(), ast_find_ourip(), ast_format_unregister(), ast_func_read(), ast_func_write(), ast_get_channel_tech(), ast_get_enum(), ast_get_group(), ast_get_indication_zone(), ast_get_ip_or_srv(), ast_hangup(), ast_iax2_new(), ast_indicate_data(), ast_internal_timing_enabled(), ast_io_add(), ast_io_dump(), ast_io_remove(), ast_io_wait(), ast_ivr_menu_run_internal(), ast_jb_put(), ast_linear_stream(), ast_lock_path(), ast_makesocket(), ast_manager_register_struct(), ast_masq_park_call(), ast_merge_contexts_and_delete(), ast_moh_destroy(), ast_monitor_change_fname(), ast_monitor_start(), ast_monitor_stop(), ast_netsock_bindaddr(), ast_odbc_prepare_and_execute(), ast_odbc_request_obj(), ast_odbc_sanity_check(), ast_odbc_smart_execute(), ast_openstream_full(), ast_openvstream(), ast_ouraddrfor(), ast_park_call(), ast_parse_allow_disallow(), ast_parseable_goto(), ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_pbx_run_app(), ast_pbx_start(), ast_pickup_call(), ast_playtones_start(), ast_prod(), ast_pthread_create_stack(), ast_queue_frame(), 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_switch(), ast_remotecontrol(), ast_request(), ast_rtcp_new(), ast_rtcp_read(), ast_rtcp_write_rr(), ast_rtcp_write_sr(), ast_rtp_bridge(), ast_rtp_early_bridge(), ast_rtp_make_compatible(), ast_rtp_new_with_bindaddr(), ast_rtp_proto_register(), ast_rtp_raw_write(), ast_rtp_read(), ast_rtp_reload(), ast_rtp_sendcng(), ast_rtp_senddigit_begin(), ast_rtp_senddigit_continuation(), ast_rtp_senddigit_end(), ast_rtp_settos(), ast_rtp_write(), ast_say_date_with_format_da(), ast_say_date_with_format_de(), ast_say_date_with_format_en(), ast_say_date_with_format_es(), ast_say_date_with_format_fr(), ast_say_date_with_format_gr(), ast_say_date_with_format_he(), ast_say_date_with_format_it(), ast_say_date_with_format_nl(), ast_say_date_with_format_pl(), ast_say_date_with_format_pt(), ast_say_date_with_format_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_pt(), 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_senddigit_begin(), ast_set_priority(), ast_settimeout(), ast_sip_ouraddrfor(), ast_slinfactory_feed(), ast_smdi_md_message_pop(), ast_smdi_mwi_message_pop(), ast_smdi_mwi_set(), ast_smdi_mwi_unset(), ast_smoother_read(), ast_softhangup_nolock(), ast_stopstream(), ast_streamfile(), ast_translator_build_path(), ast_tryconnect(), ast_udptl_bridge(), ast_udptl_get_error_correction_scheme(), ast_udptl_get_far_max_datagram(), ast_udptl_get_local_max_datagram(), ast_udptl_offered_from_local(), ast_udptl_proto_register(), ast_udptl_read(), ast_udptl_reload(), ast_udptl_set_error_correction_scheme(), ast_udptl_set_far_max_datagram(), ast_udptl_set_local_max_datagram(), ast_udptl_settos(), ast_udptl_write(), ast_unload_resource(), ast_unlock_path(), ast_unregister_indication_country(), ast_waitfor_nandfds(), ast_waitfordigit_full(), ast_write(), ast_writefile(), ast_writestream(), ast_yyerror(), async_wait(), attempt_thread(), attempt_transfer(), authenticate(), authenticate_verify(), auto_congest(), autoservice_run(), available(), bridge_native_loop(), bridge_p2p_loop(), bridge_p2p_rtp_write(), build_alias(), build_channels(), 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(), bump_gains(), cache_lookup_internal(), cache_save_hint(), calc_cost(), calc_rxstamp(), calc_timestamp(), callerid_feed(), callerid_feed_jp(), callerid_get_dtmf(), cb_events(), chan_misdn_log(), chan_ringing(), chandup(), channel_find_locked(), check_access(), check_app_args(), check_availability(), check_beep(), check_break(), check_compat(), check_context_names(), check_continue(), check_day(), check_dow(), check_expr2_input(), check_for_conference(), check_goto(), check_includes(), check_key(), check_label(), check_macro_returns(), check_month(), check_pendings(), check_post(), check_provisioning(), check_pval_item(), check_rtp_timeout(), check_srcaddr(), check_start(), check_timerange(), check_user_full(), check_via(), cleanup_connection(), complete_context_add_extension(), complete_context_add_ignorepat(), complete_context_add_include(), complete_context_remove_extension(), complete_context_remove_ignorepat(), complete_context_remove_include(), complete_transfer(), compress_subclass(), conf_add(), conf_del(), config_odbc(), config_pgsql(), config_text_file_load(), config_text_file_save(), connection_made(), console_autoanswer(), convertcap(), copy(), copy_data_from_queue(), copy_header(), copy_request(), create_addr(), create_addr_from_peer(), create_jb(), crypto_load(), dbinit(), decode_frame(), destroy_pval_item(), destroy_session(), destroy_trans(), determine_firstline_parts(), device_ref(), device_unref(), dialog_activate_media(), dialog_lock(), dialoglist_lock(), dialoglist_unlock(), dialogstatechange(), dns_parse_answer(), dnsmgr_init(), dnsmgr_refresh(), do_autokill(), do_cdr(), do_monitor(), do_parking_thread(), do_proxy_auth(), do_register(), do_register_expire(), do_reload(), do_setnat(), do_state_change(), dump_agents(), dump_queue(), dundi_answer_entity(), dundi_answer_query(), dundi_decrypt(), dundi_discover(), dundi_encrypt(), dundi_error_output(), dundi_exec(), dundi_helper(), dundi_lookup_internal(), dundi_lookup_thread(), dundi_precache_full(), dundi_precache_internal(), dundi_precache_thread(), dundi_query(), dundi_query_thread(), dundi_rexmit(), dundi_send(), dundi_xmit(), dundifunc_read(), eagi_exec(), encrypt_frame(), enum_callback(), expire_register(), ext_cmp1(), extension_matches(), external_rtp_create(), feature_exec_app(), features_alloc(), features_call(), features_new(), fileexists_core(), find_cache(), find_call(), find_call_locked(), find_desc(), find_line_by_instance(), find_line_by_name(), find_peer(), find_pval_goto_item(), find_speeddial_by_instance(), find_subchannel_and_lock(), find_subchannel_by_instance_reference(), find_subchannel_by_reference(), find_tpeer(), find_user(), find_via_branch(), fn_wrapper(), framein(), func_args(), func_check_sipdomain(), func_header_read(), function_agent(), function_sipchaninfo_read(), g723_len(), generator_force(), get_alarms(), get_also_info(), get_button_template(), get_destination(), get_in_brackets(), get_input(), get_range(), get_rdnis(), get_refer_info(), get_sip_dialog_byid_locked(), get_sip_pvt_byid_locked(), get_timerange(), getproviderstate(), gtalk_alloc(), gtalk_answer(), gtalk_call(), gtalk_create_candidates(), gtalk_create_member(), gtalk_digit(), gtalk_free_pvt(), gtalk_handle_dtmf(), gtalk_hangup_farend(), gtalk_indicate(), gtalk_invite(), gtalk_invite_response(), gtalk_is_answered(), gtalk_load_config(), gtalk_new(), gtalk_newcall(), gtalk_parser(), gtalk_request(), gtalk_rtp_read(), gtalk_sendhtml(), gtalk_write(), h323_gk_cycle(), handle_add_indication(), handle_command_response(), handle_common_options(), handle_error(), handle_exec(), handle_frame(), handle_getoption(), handle_hd_hf(), handle_init_event(), handle_invite_replaces(), handle_keypad_button_message(), handle_message(), handle_offhook_message(), handle_onhook_message(), handle_open_receive_channel_ack_message(), handle_playtones(), handle_recordfile(), handle_register_message(), handle_remove_indication(), handle_request(), handle_request_bye(), handle_request_cancel(), handle_request_info(), handle_request_invite(), handle_request_notify(), handle_request_refer(), handle_request_register(), handle_request_subscribe(), handle_response(), handle_response_answer(), handle_response_bye(), handle_response_invite(), handle_response_message(), handle_response_notify(), handle_response_peerpoke(), handle_response_refer(), handle_response_register(), handle_soft_key_event_message(), handle_stimulus_message(), handle_streamfile(), hangup_cause2sip(), hangup_connection(), iax2_ack_registry(), iax2_answer(), 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_peer(), iax2_prov_app(), iax2_provision(), iax2_read(), iax2_register(), iax2_request(), iax2_send(), iax2_transfer(), iax2_trunk_queue(), iax2_write(), iax_error_output(), iax_park(), iax_park_thread(), iax_process_template(), iax_provision_reload(), iax_provision_version(), iax_template_parse(), increase_call_count(), ind_load_module(), indexof(), init_logger(), init_logger_chain(), init_manager(), init_req(), init_resp(), initialize_initreq(), inspect_module(), io_grow(), ivr_dispatch(), jb_error_output(), jb_get_and_deliver(), jb_put(), jb_warning_output(), jingle_alloc(), jingle_answer(), jingle_call(), jingle_create_candidates(), jingle_create_member(), jingle_digit(), jingle_free_pvt(), jingle_handle_dtmf(), jingle_hangup_farend(), jingle_indicate(), jingle_is_answered(), jingle_new(), jingle_newcall(), jingle_parser(), jingle_request(), jingle_rtp_read(), jingle_sendhtml(), jingle_write(), launch_netscript(), launch_script(), launch_service(), linear_alloc(), linear_generator(), linear_release(), listener(), load_config(), load_module(), load_modules(), load_moh_classes(), load_odbc_config(), load_pbx(), load_resource(), local_alloc(), local_answer(), local_ast_moh_start(), local_attended_transfer(), local_devicestate(), local_fixup(), local_new(), local_queue_frame(), local_write(), logdebug_va(), logger_print_normal(), make_file_from_fd(), make_integer(), make_str(), make_trunk(), manager_show_dialplan_helper(), match_or_create_dialog(), memcpy_decrypt(), memcpy_encrypt(), metermaidstate(), mgcp_answer(), mgcp_call(), mgcp_fixup(), mgcp_hangup(), mgcp_indicate(), mgcp_new(), mgcp_postrequest(), mgcp_reload(), mgcp_request(), mgcp_rtp_read(), mgcp_ss(), mgcp_write(), mgcpsock_read(), 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_digit_end(), misdn_facility_exec(), misdn_hangup(), misdn_indication(), misdn_request(), misdn_send_text(), misdn_set_opt_exec(), misdn_write(), mkif(), mkintf(), 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(), monmp3thread(), my_zt_write(), nbs_alloc(), nbs_call(), nbs_hangup(), nbs_new(), nbs_request(), nbs_xread(), nbs_xwrite(), netconsole(), network_thread(), notify_metermaids(), odbc_obj_connect(), odbc_obj_disconnect(), odbc_register_class(), oh323_alloc(), oh323_answer(), oh323_call(), oh323_destroy(), oh323_destroy_alias(), oh323_destroy_peer(), oh323_destroy_user(), oh323_digit_begin(), oh323_digit_end(), oh323_fixup(), oh323_hangup(), oh323_indicate(), oh323_read(), oh323_request(), oh323_rtp_read(), oh323_set_rtp_peer(), oh323_write(), op_colon(), op_div(), op_eq(), op_eqtilde(), op_minus(), op_negate(), op_plus(), op_rem(), op_times(), oss_indicate(), oss_new(), oss_request(), park_exec(), parse(), parse_args(), parse_config(), parse_gain_value(), parse_ie(), parse_moved_contact(), parse_naptr(), parse_register_contact(), parse_request(), parse_sip_options(), parse_srv(), parse_uri(), pbx_builtin_background(), pbx_builtin_execiftime(), pbx_builtin_gotoif(), pbx_builtin_gotoiftime(), pbx_builtin_hangup(), pbx_builtin_importvar(), pbx_builtin_pushvar_helper(), pbx_builtin_saynumber(), pbx_builtin_serialize_variables(), pbx_builtin_setvar(), pbx_builtin_waitexten(), pbx_extension_helper(), pbx_find_extension(), pbx_load_module(), pbx_substitute_variables_helper_full(), peer_set_srcaddr(), pgsql_reconnect(), phone_answer(), phone_call(), phone_check_exception(), phone_digit_end(), phone_exception(), phone_hangup(), phone_indicate(), phone_mini_packet(), phone_new(), phone_read(), phone_request(), phone_setup(), phone_write(), phone_write_buf(), pl_odtworz_plik(), playtones_alloc(), playtones_generator(), post_cdr(), powerof(), precache_trans(), precache_transactions(), printdigest(), process_ast_dsp(), process_cisco_dtmf(), process_message(), process_rfc2833(), process_rfc3389(), process_sdp(), process_sip_queue(), process_text_line(), progress(), queue_frame_to_spies(), raw_hangup(), read_agent_config(), read_config(), realtime_exec(), realtime_multi_odbc(), realtime_multi_pgsql(), realtime_odbc(), realtime_pgsql(), rebuild_matrix(), receive_digit(), receive_message(), refresh_list(), register_peer_exten(), register_request(), register_verify(), registry_addref(), registry_authrequest(), registry_rerequest(), registry_unref(), reload(), reload_agents(), reload_config(), reload_firmware(), remote_hold(), remove_from_queue(), reply_digest(), reqprep(), reset_conf(), reset_global_eid(), restart_monitor(), restore_conference(), restore_gains(), retrans_pkt(), run_agi(), safe_append(), save_conference(), scan_service(), scan_thread(), sched_settime(), sched_thread(), schedule_delivery(), send_callerid(), send_digit_to_chan(), send_dtmf(), send_packet(), send_request(), send_sound(), send_trunk(), server_root(), server_start(), set_actual_rxgain(), set_actual_txgain(), set_address_from_contact(), set_config(), set_destination(), set_device_host(), set_dtmf_payload(), set_format(), set_full_cmd(), set_local_capabilities(), set_peer_capabilities(), set_timing(), set_ulimit(), setformat(), setup_incoming_call(), setup_rtp_connection(), setup_zap(), show_channeltype(), show_channeltypes(), show_dialplan_helper(), sip_addheader(), sip_alloc(), sip_alreadygone(), sip_answer(), sip_call(), sip_config_parse(), sip_destroy(), sip_destroy_peer(), sip_destroy_user(), sip_devicestate(), sip_do_reload(), sip_dtmfmode(), sip_dump_history(), sip_fixup(), sip_handle_t38_reinvite(), sip_hangup(), sip_indicate(), sip_method2txt(), sip_new(), sip_notify(), sip_option_lookup(), sip_ouraddrfor(), sip_park(), sip_park_thread(), sip_poke_noanswer(), sip_poke_peer(), sip_read(), sip_reg_timeout(), sip_register(), sip_registry_destroy(), sip_request_call(), sip_reregister(), sip_rtp_read(), sip_set_rtp_peer(), sip_set_udptl_peer(), sip_sipredirect(), sip_write(), sipnet_lock(), sipnet_unlock(), siprequest_alloc(), siprequest_free(), sipsock_init(), sipsock_read(), sipsocket_open(), skinny_call(), skinny_fixup(), skinny_hangup(), skinny_indicate(), skinny_new(), skinny_newcall(), skinny_req_parse(), skinny_request(), skinny_rtp_read(), skinny_ss(), skinny_write(), smdi_load(), socket_process(), socket_process_meta(), socket_read(), sound_thread(), soundcard_init(), soundcard_writeframe(), spawn_dp_lookup(), spawn_mp3(), speex_get_wb_sz_at(), speex_samples(), spy_detach(), srv_callback(), ss_thread(), start_network_thread(), stop_media_flows(), store_boost(), store_mixer(), stub_ast_check_signature(), stub_ast_check_signature_bin(), stub_ast_encdec_bin(), stub_ast_key_get(), stub_ast_sign(), stub_ast_sign_bin(), stun_handle_packet(), swap_subs(), t38_get_rate(), tdd_feed(), tdd_new(), timing_read(), to_integer(), to_string(), tonepair_alloc(), tonepair_generator(), transmit_final_response(), transmit_invite(), transmit_notify_with_mwi(), transmit_refer(), transmit_register(), transmit_request_with_auth(), transmit_response(), transmit_response_using_temp(), transmit_response_with_attachment(), transmit_response_with_auth(), transmit_response_with_sdp(), transmit_response_with_t38_sdp(), transmit_state_notify(), transmit_trunk(), try_firmware(), try_load_key(), try_suggested_sip_codec(), try_transfer(), tvfix(), unalloc_sub(), unload_module(), unwrap_timestamp(), update_call_counter(), update_common_options(), update_config(), update_key(), update_odbc(), update_pgsql(), update_registry(), used_blocks(), wait_file(), waitstream_core(), zap_fake_event(), zap_restart(), zap_show_status(), zt_answer(), zt_bridge(), zt_call(), zt_callwait(), zt_confmute(), zt_digit_begin(), zt_digit_end(), zt_disable_ec(), zt_enable_ec(), zt_fixup(), zt_get_index(), zt_handle_event(), zt_hangup(), zt_indicate(), zt_link(), zt_new(), zt_read(), zt_request(), zt_ring_phone(), zt_sendtext(), zt_set_hook(), zt_setoption(), zt_train_ec(), zt_unlink(), and zt_write().

00865 {
00866    struct logmsg *logmsg = NULL;
00867    struct ast_str *buf = NULL;
00868    struct tm tm;
00869    time_t t;
00870    int res = 0;
00871    va_list ap;
00872 
00873    if (!(buf = ast_str_thread_get(&log_buf, LOG_BUF_INIT_SIZE)))
00874       return;
00875 
00876    if (AST_LIST_EMPTY(&logchannels)) {
00877       /*
00878        * we don't have the logger chain configured yet,
00879        * so just log to stdout
00880        */
00881       if (level != __LOG_VERBOSE) {
00882          int res;
00883          va_start(ap, fmt);
00884          res = ast_str_set_va(&buf, BUFSIZ, fmt, ap); /* XXX BUFSIZ ? */
00885          va_end(ap);
00886          if (res != AST_DYNSTR_BUILD_FAILED) {
00887             term_filter_escapes(buf->str);
00888             fputs(buf->str, stdout);
00889          }
00890       }
00891       return;
00892    }
00893    
00894    /* don't display LOG_DEBUG messages unless option_verbose _or_ option_debug
00895       are non-zero; LOG_DEBUG messages can still be displayed if option_debug
00896       is zero, if option_verbose is non-zero (this allows for 'level zero'
00897       LOG_DEBUG messages to be displayed, if the logmask on any channel
00898       allows it)
00899    */
00900    if (!option_verbose && !option_debug && (level == __LOG_DEBUG))
00901       return;
00902 
00903    /* Ignore anything that never gets logged anywhere */
00904    if (!(global_logmask & (1 << level)))
00905       return;
00906    
00907    /* Ignore anything other than the currently debugged file if there is one */
00908    if ((level == __LOG_DEBUG) && !ast_strlen_zero(debug_filename) && strcasecmp(debug_filename, file))
00909       return;
00910 
00911    /* Build string */
00912    va_start(ap, fmt);
00913    res = ast_str_set_va(&buf, BUFSIZ, fmt, ap);
00914    va_end(ap);
00915 
00916    /* If the build failed, then abort and free this structure */
00917    if (res == AST_DYNSTR_BUILD_FAILED)
00918       return;
00919 
00920    /* Create a new logging message */
00921    if (!(logmsg = ast_calloc(1, sizeof(*logmsg) + res + 1)))
00922       return;
00923    
00924    /* Copy string over */
00925    strcpy(logmsg->str, buf->str);
00926 
00927    /* Set type to be normal */
00928    logmsg->type = LOGMSG_NORMAL;
00929 
00930    /* Create our date/time */
00931    time(&t);
00932    localtime_r(&t, &tm);
00933    strftime(logmsg->date, sizeof(logmsg->date), dateformat, &tm);
00934 
00935    /* Copy over data */
00936    logmsg->level = level;
00937    logmsg->file = file;
00938    logmsg->line = line;
00939    logmsg->function = function;
00940 
00941    /* If the logger thread is active, append it to the tail end of the list - otherwise skip that step */
00942    if (logthread != AST_PTHREADT_NULL) {
00943       AST_LIST_LOCK(&logmsgs);
00944       AST_LIST_INSERT_TAIL(&logmsgs, logmsg, list);
00945       ast_cond_signal(&logcond);
00946       AST_LIST_UNLOCK(&logmsgs);
00947    } else {
00948       logger_print_normal(logmsg);
00949       free(logmsg);
00950    }
00951 
00952    return;
00953 }

static void ast_log_vsyslog int  level,
const char *  file,
int  line,
const char *  function,
char *  str
[static]
 

Definition at line 619 of file logger.c.

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

Referenced by logger_print_normal().

00620 {
00621    char buf[BUFSIZ];
00622 
00623    if (level >= SYSLOG_NLEVELS) {
00624       /* we are locked here, so cannot ast_log() */
00625       fprintf(stderr, "ast_log_vsyslog called with bogus level: %d\n", level);
00626       return;
00627    }
00628 
00629    if (level == __LOG_VERBOSE) {
00630       snprintf(buf, sizeof(buf), "VERBOSE[%ld]: %s", (long)GETTID(), str);
00631       level = __LOG_DEBUG;
00632    } else if (level == __LOG_DTMF) {
00633       snprintf(buf, sizeof(buf), "DTMF[%ld]: %s", (long)GETTID(), str);
00634       level = __LOG_DEBUG;
00635    } else {
00636       snprintf(buf, sizeof(buf), "%s[%ld]: %s:%d in %s: %s",
00637           levels[level], (long)GETTID(), file, line, function, str);
00638         }
00639 
00640         term_strip(buf, buf, strlen(buf) + 1);
00641         syslog(syslog_level_map[level], "%s", buf);
00642 }

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

Definition at line 382 of file logger.c.

References AST_LIST_LOCK, AST_LIST_UNLOCK, and qlog.

Referenced by __login_exec(), agent_logoff_maintenance(), and init_logger().

00383 {
00384    va_list ap;
00385    AST_LIST_LOCK(&logchannels);
00386    if (qlog) {
00387       va_start(ap, fmt);
00388       fprintf(qlog, "%ld|%s|%s|%s|%s|", (long)time(NULL), callid, queuename, agent, event);
00389       vfprintf(qlog, fmt, ap);
00390       fprintf(qlog, "\n");
00391       va_end(ap);
00392       fflush(qlog);
00393    }
00394    AST_LIST_UNLOCK(&logchannels);
00395 }

int ast_register_verbose void(*)(const char *string)  v  ) 
 

Definition at line 1040 of file logger.c.

References AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_malloc, and verb.

Referenced by ast_makesocket(), and show_console().

01041 {
01042    struct verb *verb;
01043 
01044    if (!(verb = ast_malloc(sizeof(*verb))))
01045       return -1;
01046 
01047    verb->verboser = v;
01048 
01049    AST_LIST_LOCK(&verbosers);
01050    AST_LIST_INSERT_HEAD(&verbosers, verb, list);
01051    AST_LIST_UNLOCK(&verbosers);
01052    
01053    return 0;
01054 }

AST_THREADSTORAGE log_buf   ) 
 

AST_THREADSTORAGE verbose_buf   ) 
 

int ast_unregister_verbose void(*)(const char *string)  v  ) 
 

Definition at line 1056 of file logger.c.

References AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, free, and verb::verboser.

Referenced by exit_now().

01057 {
01058    struct verb *cur;
01059 
01060    AST_LIST_LOCK(&verbosers);
01061    AST_LIST_TRAVERSE_SAFE_BEGIN(&verbosers, cur, list) {
01062       if (cur->verboser == v) {
01063          AST_LIST_REMOVE_CURRENT(&verbosers, list);
01064          free(cur);
01065          break;
01066       }
01067    }
01068    AST_LIST_TRAVERSE_SAFE_END
01069    AST_LIST_UNLOCK(&verbosers);
01070    
01071    return cur ? 0 : -1;
01072 }

void ast_verbose const char *  fmt,
  ...
 

Definition at line 987 of file logger.c.

References ast_calloc, ast_cond_signal(), AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_opt_timestamp, AST_PTHREADT_NULL, ast_str_set_va, free, logcond, logger_print_verbose(), LOGMSG_VERBOSE, logthread, ast_str::str, and VERBOSE_BUF_INIT_SIZE.

Referenced by __agent_start_monitoring(), __ast_format_register(), __ast_pbx_run(), __ast_play_and_record(), __ast_register_translator(), __ast_str_helper(), __login_exec(), __sip_destroy(), __zt_exception(), action_login(), add_codec_to_sdp(), add_noncodec_to_sdp(), add_realm_authentication(), add_sdp(), agent_call(), agent_read(), agentmonitoroutgoing_exec(), agi_debug_cli(), aji_handle_presence(), aji_handle_subscribe(), aji_log_hook(), aji_recv_loop(), aji_register_query_handler(), aji_test(), alsa_answer(), alsa_call(), alsa_digit(), alsa_hangup(), alsa_indicate(), alsa_text(), append_mapping(), ast_add_extension2(), ast_aji_disconnect(), ast_app_has_voicemail(), ast_app_inboxcount(), ast_app_messagecount(), ast_cdr_unregister(), ast_channel_register(), ast_channel_unregister(), ast_context_add_include2(), ast_context_add_switch2(), ast_custom_function_register(), ast_custom_function_unregister(), ast_dnsmgr_lookup(), ast_dnsmgr_release(), ast_feature_request_and_dial(), ast_format_unregister(), ast_frame_dump(), ast_image_register(), ast_image_unregister(), ast_jb_destroy(), ast_manager_unregister(), ast_module_reload(), ast_moh_destroy(), ast_moh_start(), ast_netsock_bindaddr(), ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_pbx_run_app(), ast_record_review(), ast_register_application(), ast_register_feature(), ast_register_indication_country(), ast_remotecontrol(), ast_rtcp_read(), ast_rtcp_write_rr(), ast_rtcp_write_sr(), ast_rtp_bridge(), ast_rtp_destroy(), ast_rtp_raw_write(), ast_rtp_read(), ast_rtp_reload(), ast_rtp_sendcng(), ast_rtp_senddigit_begin(), ast_rtp_senddigit_continuation(), ast_rtp_senddigit_end(), ast_say_number_full_he(), ast_set_indication_country(), ast_set_priority(), ast_speech_register(), ast_speech_unregister(), ast_streamfile(), ast_udptl_read(), ast_udptl_reload(), ast_udptl_write(), ast_unregister_application(), ast_unregister_indication_country(), ast_unregister_translator(), astman_append(), async_wait(), attempt_thread(), attempt_transfer(), auth_headers(), begin_dial(), bridge_p2p_rtp_write(), build_device(), build_gateway(), builtin_automonitor(), builtin_blindtransfer(), builtin_disconnect(), cb_extensionstate(), check_for_conference(), check_peer_ok(), check_user_full(), check_user_ok(), check_via(), config_odbc_prepare(), config_text_file_load(), config_text_file_save(), create_addr(), create_jb(), dnsmgr_refresh(), do_monitor(), do_parking_thread(), do_register_auth(), do_sip_monitor(), dundi_debug_output(), exit_now(), find_command(), find_gtalk(), find_line_by_name(), find_subchannel_and_lock(), get_also_info(), get_destination(), get_input(), get_rdnis(), get_refer_info(), gtalk_do_reload(), gtalk_handle_dtmf(), h323_ep_hangup(), h323_reload(), handle_alarm_message(), handle_button_template_req_message(), handle_capabilities_res_message(), handle_command_response(), handle_exec(), handle_frame(), handle_frame_ownerless(), handle_getoption(), handle_init_event(), handle_keypad_button_message(), handle_message(), handle_offhook_message(), handle_onhook_message(), handle_open_receive_channel_ack_message(), handle_register_message(), handle_request(), handle_request_info(), handle_request_invite(), handle_request_message(), handle_request_refer(), handle_request_register(), handle_request_subscribe(), handle_response(), handle_soft_key_event_message(), handle_stimulus_message(), handle_streamfile(), handle_verbose(), iax2_ack_registry(), iax2_bridge(), iax2_exec(), iax2_hangup(), iax2_prov_app(), iax_debug_output(), iax_provision_reload(), init_logger(), initialize_initreq(), jb_debug_output(), jingle_handle_dtmf(), launch_script(), list_route(), load_module(), load_modules(), load_pbx(), load_resource(), logger_print_normal(), make_file_from_fd(), mgcp_answer(), mgcp_call(), mgcp_hangup(), mgcp_indicate(), mgcp_new(), mgcp_reload(), mgcp_request(), mgcp_ss(), mgcpsock_read(), misdn_bridge(), misdn_call(), moh_alloc(), moh_files_alloc(), moh_files_release(), moh_release(), oh323_call(), oss_answer(), oss_call(), oss_digit_end(), oss_hangup(), oss_indicate(), oss_text(), park_exec(), parse(), parse_register_contact(), parse_srv(), pbx_builtin_goto(), pbx_builtin_pushvar_helper(), pbx_builtin_setvar_helper(), pbx_builtin_waitexten(), pbx_extension_helper(), phone_check_exception(), phone_exception(), phone_hangup(), process_ast_dsp(), process_sdp(), purge_sessions(), quit_handler(), realtime_exec(), receive_message(), refresh_list(), reg_source_db(), reload(), reload_config(), reload_firmware(), remap_feature(), resend_response(), retrans_pkt(), run_agi(), send_cwcidspill(), send_request(), send_response(), set_address_from_contact(), set_config(), set_destination(), setformat(), setup_incoming_call(), setup_zap(), sip_reload(), sip_scheddestroy(), sip_sendtext(), sipsock_read(), sipsocket_open(), skinny_answer(), skinny_call(), skinny_hangup(), skinny_hold(), skinny_indicate(), skinny_new(), skinny_request(), skinny_reset_device(), skinny_session(), skinny_ss(), skinny_unhold(), socket_process(), ss_thread(), ssl_setup(), stun_handle_packet(), stun_process_attr(), timing_read(), transmit_connection_del(), transmit_connection_del_w_params(), transmit_displaymessage(), transmit_displaynotify(), transmit_displaypromptstatus(), transmit_modify_request(), transmit_notify_request(), transmit_notify_request_with_callerid(), transmit_register(), transmit_ringer_mode(), try_load_key(), unload_module(), update_registry(), zap_restart(), zt_bridge(), zt_call(), zt_handle_event(), zt_hangup(), and zt_read().

00988 {
00989    struct logmsg *logmsg = NULL;
00990    struct ast_str *buf = NULL;
00991    int res = 0;
00992    va_list ap;
00993 
00994    if (!(buf = ast_str_thread_get(&verbose_buf, VERBOSE_BUF_INIT_SIZE)))
00995       return;
00996 
00997    /* Build string */
00998    va_start(ap, fmt);
00999    res = ast_str_set_va(&buf, 0, fmt, ap);
01000    va_end(ap);
01001 
01002    /* If the build failed then we can drop this allocated message */
01003    if (res == AST_DYNSTR_BUILD_FAILED)
01004       return;
01005 
01006    if (!(logmsg = ast_calloc(1, sizeof(*logmsg) + res + 1)))
01007       return;
01008 
01009    strcpy(logmsg->str, buf->str);
01010 
01011    /* Set type */
01012    logmsg->type = LOGMSG_VERBOSE;
01013    
01014    if (ast_opt_timestamp) {
01015       time_t t;
01016       struct tm tm;
01017       char date[40];
01018       char *datefmt;
01019 
01020       time(&t);
01021       localtime_r(&t, &tm);
01022       strftime(date, sizeof(date), dateformat, &tm);
01023       datefmt = alloca(strlen(date) + 3 + strlen(fmt) + 1);
01024       sprintf(datefmt, "[%s] %s", date, fmt);
01025       fmt = datefmt;
01026    }
01027 
01028    /* Add to the list and poke the thread if possible */
01029    if (logthread != AST_PTHREADT_NULL) {
01030       AST_LIST_LOCK(&logmsgs);
01031       AST_LIST_INSERT_TAIL(&logmsgs, logmsg, list);
01032       ast_cond_signal(&logcond);
01033       AST_LIST_UNLOCK(&logmsgs);
01034    } else {
01035       logger_print_verbose(logmsg);
01036       free(logmsg);
01037    }
01038 }

void close_logger void   ) 
 

Provided by logger.c

Definition at line 825 of file logger.c.

References ast_cond_signal(), AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, close_logger_thread, eventlog, logchannel::fileptr, logcond, and qlog.

00826 {
00827    struct logchannel *f = NULL;
00828 
00829    /* Stop logger thread */
00830    AST_LIST_LOCK(&logmsgs);
00831    close_logger_thread = 1;
00832    ast_cond_signal(&logcond);
00833    AST_LIST_UNLOCK(&logmsgs);
00834 
00835    AST_LIST_LOCK(&logchannels);
00836 
00837    if (eventlog) {
00838       fclose(eventlog);
00839       eventlog = NULL;
00840    }
00841 
00842    if (qlog) {
00843       fclose(qlog);
00844       qlog = NULL;
00845    }
00846 
00847    AST_LIST_TRAVERSE(&logchannels, f, list) {
00848       if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) {
00849          fclose(f->fileptr);
00850          f->fileptr = NULL;
00851       }
00852    }
00853 
00854    closelog(); /* syslog */
00855 
00856    AST_LIST_UNLOCK(&logchannels);
00857 
00858    return;
00859 }

static int handle_logger_reload int  fd,
int  argc,
char *  argv[]
[static]
 

Definition at line 524 of file logger.c.

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

00525 {
00526    if (reload_logger(0)) {
00527       ast_cli(fd, "Failed to reload the logger\n");
00528       return RESULT_FAILURE;
00529    } else
00530       return RESULT_SUCCESS;
00531 }

static int handle_logger_rotate int  fd,
int  argc,
char *  argv[]
[static]
 

Definition at line 533 of file logger.c.

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

00534 {
00535    if (reload_logger(1)) {
00536       ast_cli(fd, "Failed to reload the logger and rotate log files\n");
00537       return RESULT_FAILURE;
00538    } else
00539       return RESULT_SUCCESS;
00540 }

static int handle_logger_show_channels int  fd,
int  argc,
char *  argv[]
[static]
 

CLI command to show logging system configuration.

Definition at line 543 of file logger.c.

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

00544 {
00545 #define FORMATL   "%-35.35s %-8.8s %-9.9s "
00546    struct logchannel *chan;
00547 
00548    ast_cli(fd,FORMATL, "Channel", "Type", "Status");
00549    ast_cli(fd, "Configuration\n");
00550    ast_cli(fd,FORMATL, "-------", "----", "------");
00551    ast_cli(fd, "-------------\n");
00552    AST_LIST_LOCK(&logchannels);
00553    AST_LIST_TRAVERSE(&logchannels, chan, list) {
00554       ast_cli(fd, FORMATL, chan->filename, chan->type==LOGTYPE_CONSOLE ? "Console" : (chan->type==LOGTYPE_SYSLOG ? "Syslog" : "File"),
00555          chan->disabled ? "Disabled" : "Enabled");
00556       ast_cli(fd, " - ");
00557       if (chan->logmask & (1 << __LOG_DEBUG)) 
00558          ast_cli(fd, "Debug ");
00559       if (chan->logmask & (1 << __LOG_DTMF)) 
00560          ast_cli(fd, "DTMF ");
00561       if (chan->logmask & (1 << __LOG_VERBOSE)) 
00562          ast_cli(fd, "Verbose ");
00563       if (chan->logmask & (1 << __LOG_WARNING)) 
00564          ast_cli(fd, "Warning ");
00565       if (chan->logmask & (1 << __LOG_NOTICE)) 
00566          ast_cli(fd, "Notice ");
00567       if (chan->logmask & (1 << __LOG_ERROR)) 
00568          ast_cli(fd, "Error ");
00569       if (chan->logmask & (1 << __LOG_EVENT)) 
00570          ast_cli(fd, "Event ");
00571       ast_cli(fd, "\n");
00572    }
00573    AST_LIST_UNLOCK(&logchannels);
00574    ast_cli(fd, "\n");
00575       
00576    return RESULT_SUCCESS;
00577 }

static int handle_SIGXFSZ int  sig  )  [static]
 

Definition at line 612 of file logger.c.

Referenced by init_logger().

00613 {
00614    /* Indicate need to reload */
00615    filesize_reload_needed = 1;
00616    return 0;
00617 }

int init_logger void   ) 
 

Provided by logger.c

Definition at line 779 of file logger.c.

References ast_cli_register_multiple(), ast_cond_destroy(), ast_cond_init(), ast_config_AST_LOG_DIR, ast_log(), ast_pthread_create, ast_queue_log(), ast_verbose(), cli_logger, EVENTLOG, eventlog, handle_SIGXFSZ(), init_logger_chain(), LOG_ERROR, LOG_EVENT, logcond, logfiles, logger_thread(), logthread, option_verbose, and qlog.

00780 {
00781    char tmp[256];
00782    int res = 0;
00783 
00784    /* auto rotate if sig SIGXFSZ comes a-knockin */
00785    (void) signal(SIGXFSZ,(void *) handle_SIGXFSZ);
00786 
00787    /* start logger thread */
00788    ast_cond_init(&logcond, NULL);
00789    if (ast_pthread_create(&logthread, NULL, logger_thread, NULL) < 0) {
00790       ast_cond_destroy(&logcond);
00791       return -1;
00792    }
00793 
00794    /* register the logger cli commands */
00795    ast_cli_register_multiple(cli_logger, sizeof(cli_logger) / sizeof(struct ast_cli_entry));
00796 
00797    mkdir(ast_config_AST_LOG_DIR, 0755);
00798   
00799    /* create log channels */
00800    init_logger_chain();
00801 
00802    /* create the eventlog */
00803    if (logfiles.event_log) {
00804       mkdir(ast_config_AST_LOG_DIR, 0755);
00805       snprintf(tmp, sizeof(tmp), "%s/%s", ast_config_AST_LOG_DIR, EVENTLOG);
00806       eventlog = fopen(tmp, "a");
00807       if (eventlog) {
00808          ast_log(LOG_EVENT, "Started Asterisk Event Logger\n");
00809          if (option_verbose)
00810             ast_verbose("Asterisk Event Logger Started %s\n", tmp);
00811       } else {
00812          ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno));
00813          res = -1;
00814       }
00815    }
00816 
00817    if (logfiles.queue_log) {
00818       snprintf(tmp, sizeof(tmp), "%s/%s", ast_config_AST_LOG_DIR, queue_log_name);
00819       qlog = fopen(tmp, "a");
00820       ast_queue_log("NONE", "NONE", "NONE", "QUEUESTART", "%s", "");
00821    }
00822    return res;
00823 }

static void init_logger_chain void   )  [static]
 

Definition at line 309 of file logger.c.

References ast_calloc, ast_config_load(), AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, ast_log(), ast_true(), ast_variable_browse(), ast_variable_retrieve(), free, LOG_WARNING, logfiles, LOGTYPE_CONSOLE, make_logchannel(), s, and var.

Referenced by init_logger().

00310 {
00311    struct logchannel *chan;
00312    struct ast_config *cfg;
00313    struct ast_variable *var;
00314    const char *s;
00315 
00316    /* delete our list of log channels */
00317    AST_LIST_LOCK(&logchannels);
00318    while ((chan = AST_LIST_REMOVE_HEAD(&logchannels, list)))
00319       free(chan);
00320    AST_LIST_UNLOCK(&logchannels);
00321    
00322    global_logmask = 0;
00323    errno = 0;
00324    /* close syslog */
00325    closelog();
00326    
00327    cfg = ast_config_load("logger.conf");
00328    
00329    /* If no config file, we're fine, set default options. */
00330    if (!cfg) {
00331       if (errno)
00332          fprintf(stderr, "Unable to open logger.conf: %s; default settings will be used.\n", strerror(errno));
00333       else
00334          fprintf(stderr, "Errors detected in logger.conf: see above; default settings will be used.\n");
00335       if (!(chan = ast_calloc(1, sizeof(*chan))))
00336          return;
00337       chan->type = LOGTYPE_CONSOLE;
00338       chan->logmask = 28; /*warning,notice,error */
00339       AST_LIST_LOCK(&logchannels);
00340       AST_LIST_INSERT_HEAD(&logchannels, chan, list);
00341       AST_LIST_UNLOCK(&logchannels);
00342       global_logmask |= chan->logmask;
00343       return;
00344    }
00345    
00346    if ((s = ast_variable_retrieve(cfg, "general", "appendhostname"))) {
00347       if (ast_true(s)) {
00348          if (gethostname(hostname, sizeof(hostname) - 1)) {
00349             ast_copy_string(hostname, "unknown", sizeof(hostname));
00350             ast_log(LOG_WARNING, "What box has no hostname???\n");
00351          }
00352       } else
00353          hostname[0] = '\0';
00354    } else
00355       hostname[0] = '\0';
00356    if ((s = ast_variable_retrieve(cfg, "general", "dateformat")))
00357       ast_copy_string(dateformat, s, sizeof(dateformat));
00358    else
00359       ast_copy_string(dateformat, "%b %e %T", sizeof(dateformat));
00360    if ((s = ast_variable_retrieve(cfg, "general", "queue_log")))
00361       logfiles.queue_log = ast_true(s);
00362    if ((s = ast_variable_retrieve(cfg, "general", "event_log")))
00363       logfiles.event_log = ast_true(s);
00364    if ((s = ast_variable_retrieve(cfg, "general", "queue_log_name")))
00365       ast_copy_string(queue_log_name, s, sizeof(queue_log_name));
00366    if ((s = ast_variable_retrieve(cfg, "general", "rotatetimestamp")))
00367       rotatetimestamp = ast_true(s);
00368 
00369    AST_LIST_LOCK(&logchannels);
00370    var = ast_variable_browse(cfg, "logfiles");
00371    for (; var; var = var->next) {
00372       if (!(chan = make_logchannel(var->name, var->value, var->lineno)))
00373          continue;
00374       AST_LIST_INSERT_HEAD(&logchannels, chan, list);
00375       global_logmask |= chan->logmask;
00376    }
00377    AST_LIST_UNLOCK(&logchannels);
00378 
00379    ast_config_destroy(cfg);
00380 }

static void logger_print_normal struct logmsg logmsg  )  [static]
 

Definition at line 645 of file logger.c.

References __LOG_EVENT, __LOG_VERBOSE, ast_console_puts_mutable(), AST_LIST_EMPTY, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), ast_log_vsyslog(), ast_strlen_zero(), ast_verbose(), COLOR_BRWHITE, colors, logmsg::date, logchannel::disabled, EVENT_FLAG_SYSTEM, eventlog, logmsg::file, logchannel::filename, logchannel::fileptr, logmsg::function, GETTID, logmsg::level, levels, logmsg::line, LOG_EVENT, logfiles, logchannel::logmask, LOGTYPE_CONSOLE, LOGTYPE_FILE, LOGTYPE_SYSLOG, manager_event, option_verbose, reload_logger(), term_color(), and logchannel::type.

Referenced by ast_log(), and logger_thread().

00646 {
00647    struct logchannel *chan = NULL;
00648    char buf[BUFSIZ];
00649 
00650    AST_LIST_LOCK(&logchannels);
00651 
00652    if (logfiles.event_log && logmsg->level == __LOG_EVENT) {
00653       fprintf(eventlog, "%s asterisk[%ld]: %s", logmsg->date, (long)getpid(), logmsg->str);
00654       fflush(eventlog);
00655       AST_LIST_UNLOCK(&logchannels);
00656       return;
00657    }
00658 
00659    if (!AST_LIST_EMPTY(&logchannels)) {
00660       AST_LIST_TRAVERSE(&logchannels, chan, list) {
00661          /* If the channel is disabled, then move on to the next one */
00662          if (chan->disabled)
00663             continue;
00664          /* Check syslog channels */
00665          if (chan->type == LOGTYPE_SYSLOG && (chan->logmask & (1 << logmsg->level))) {
00666             ast_log_vsyslog(logmsg->level, logmsg->file, logmsg->line, logmsg->function, logmsg->str);
00667          /* Console channels */
00668          } else if (chan->type == LOGTYPE_CONSOLE && (chan->logmask & (1 << logmsg->level))) {
00669             char linestr[128];
00670             char tmp1[80], tmp2[80], tmp3[80], tmp4[80];
00671 
00672             /* If the level is verbose, then skip it */
00673             if (logmsg->level == __LOG_VERBOSE)
00674                continue;
00675 
00676             /* Turn the numerical line number into a string */
00677             snprintf(linestr, sizeof(linestr), "%d", logmsg->line);
00678             /* Build string to print out */
00679             snprintf(buf, sizeof(buf), "[%s] %s[%ld]: %s:%s %s: %s",
00680                 logmsg->date,
00681                 term_color(tmp1, levels[logmsg->level], colors[logmsg->level], 0, sizeof(tmp1)),
00682                 (long)GETTID(),
00683                 term_color(tmp2, logmsg->file, COLOR_BRWHITE, 0, sizeof(tmp2)),
00684                 term_color(tmp3, linestr, COLOR_BRWHITE, 0, sizeof(tmp3)),
00685                 term_color(tmp4, logmsg->function, COLOR_BRWHITE, 0, sizeof(tmp4)),
00686                 logmsg->str);
00687             /* Print out */
00688             ast_console_puts_mutable(buf);
00689          /* File channels */
00690          } else if (chan->type == LOGTYPE_FILE && (chan->logmask & (1 << logmsg->level))) {
00691             int res = 0;
00692 
00693             /* If no file pointer exists, skip it */
00694             if (!chan->fileptr)
00695                continue;
00696             
00697             /* Print out to the file */
00698             res = fprintf(chan->fileptr, "[%s] %s[%ld] %s: %s",
00699                      logmsg->date, levels[logmsg->level], (long)GETTID(), logmsg->file, logmsg->str);
00700             if (res <= 0 && !ast_strlen_zero(logmsg->str)) {
00701                fprintf(stderr, "**** Asterisk Logging Error: ***********\n");
00702                if (errno == ENOMEM || errno == ENOSPC)
00703                   fprintf(stderr, "Asterisk logging error: Out of disk space, can't log to log file %s\n", chan->filename);
00704                else
00705                   fprintf(stderr, "Logger Warning: Unable to write to log file '%s': %s (disabled)\n", chan->filename, strerror(errno));
00706                manager_event(EVENT_FLAG_SYSTEM, "LogChannel", "Channel: %s\r\nEnabled: No\r\nReason: %d - %s\r\n", chan->filename, errno, strerror(errno));
00707                chan->disabled = 1;
00708             }
00709          }
00710       }
00711    } else if (logmsg->level != __LOG_VERBOSE) {
00712       fputs(logmsg->str, stdout);
00713    }
00714 
00715    AST_LIST_UNLOCK(&logchannels);
00716 
00717    /* If we need to reload because of the file size, then do so */
00718    if (filesize_reload_needed) {
00719       reload_logger(1);
00720       ast_log(LOG_EVENT, "Rotated Logs Per SIGXFSZ (Exceeded file size limit)\n");
00721       if (option_verbose)
00722          ast_verbose("Rotated Logs Per SIGXFSZ (Exceeded file size limit)\n");
00723    }
00724 
00725    return;
00726 }

static void logger_print_verbose struct logmsg logmsg  )  [static]
 

Definition at line 729 of file logger.c.

References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, and verb::verboser.

Referenced by ast_verbose(), and logger_thread().

00730 {
00731    struct verb *v = NULL;
00732 
00733    /* Iterate through the list of verbosers and pass them the log message string */
00734    AST_LIST_LOCK(&verbosers);
00735    AST_LIST_TRAVERSE(&verbosers, v, list)
00736       v->verboser(logmsg->str);
00737    AST_LIST_UNLOCK(&verbosers);
00738 
00739    return;
00740 }

static void* logger_thread void *  data  )  [static]
 

Definition at line 743 of file logger.c.

References ast_cond_wait(), AST_LIST_EMPTY, AST_LIST_FIRST, AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_LOCK, AST_LIST_NEXT, AST_LIST_UNLOCK, close_logger_thread, free, logcond, logger_print_normal(), logger_print_verbose(), LOGMSG_NORMAL, and LOGMSG_VERBOSE.

Referenced by init_logger().

00744 {
00745    struct logmsg *next = NULL, *msg = NULL;
00746 
00747    for (;;) {
00748       /* We lock the message list, and see if any message exists... if not we wait on the condition to be signalled */
00749       AST_LIST_LOCK(&logmsgs);
00750       if (AST_LIST_EMPTY(&logmsgs))
00751          ast_cond_wait(&logcond, &logmsgs.lock);
00752       next = AST_LIST_FIRST(&logmsgs);
00753       AST_LIST_HEAD_INIT_NOLOCK(&logmsgs);
00754       AST_LIST_UNLOCK(&logmsgs);
00755 
00756       /* If we should stop, then stop */
00757       if (close_logger_thread)
00758          break;
00759 
00760       /* Otherwise go through and process each message in the order added */
00761       while ((msg = next)) {
00762          /* Get the next entry now so that we can free our current structure later */
00763          next = AST_LIST_NEXT(msg, list);
00764 
00765          /* Depending on the type, send it to the proper function */
00766          if (msg->type == LOGMSG_NORMAL)
00767             logger_print_normal(msg);
00768          else if (msg->type == LOGMSG_VERBOSE)
00769             logger_print_verbose(msg);
00770 
00771          /* Free the data since we are done */
00772          free(msg);
00773       }
00774    }
00775 
00776    return NULL;
00777 }

static int make_components char *  s,
int  lineno
[static]
 

Definition at line 168 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().

00169 {
00170    char *w;
00171    int res = 0;
00172    char *stringp = s;
00173 
00174    while ((w = strsep(&stringp, ","))) {
00175       w = ast_skip_blanks(w);
00176       if (!strcasecmp(w, "error")) 
00177          res |= (1 << __LOG_ERROR);
00178       else if (!strcasecmp(w, "warning"))
00179          res |= (1 << __LOG_WARNING);
00180       else if (!strcasecmp(w, "notice"))
00181          res |= (1 << __LOG_NOTICE);
00182       else if (!strcasecmp(w, "event"))
00183          res |= (1 << __LOG_EVENT);
00184       else if (!strcasecmp(w, "debug"))
00185          res |= (1 << __LOG_DEBUG);
00186       else if (!strcasecmp(w, "verbose"))
00187          res |= (1 << __LOG_VERBOSE);
00188       else if (!strcasecmp(w, "dtmf"))
00189          res |= (1 << __LOG_DTMF);
00190       else {
00191          fprintf(stderr, "Logfile Warning: Unknown keyword '%s' at line %d of logger.conf\n", w, lineno);
00192       }
00193    }
00194 
00195    return res;
00196 }

static struct logchannel* make_logchannel char *  channel,
char *  components,
int  lineno
[static]
 

Definition at line 198 of file logger.c.

References ast_calloc, ast_config_AST_LOG_DIR, ast_strlen_zero(), logchannel::facility, free, LOGTYPE_CONSOLE, LOGTYPE_FILE, LOGTYPE_SYSLOG, and make_components().

Referenced by init_logger_chain().

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

int reload_logger int   ) 
 

Provided by logger.c

Definition at line 397 of file logger.c.

References ast_config_AST_LOG_DIR, AST_LIST_LOCK, AST_LIST_TRAVERSE, logchannel::disabled, EVENT_FLAG_SYSTEM, eventlog, logchannel::filename, logchannel::fileptr, manager_event, and qlog.

Referenced by handle_logger_reload(), handle_logger_rotate(), and logger_print_normal().

00398 {
00399    char old[PATH_MAX] = "";
00400    char new[PATH_MAX];
00401    int event_rotate = rotate, queue_rotate = rotate;
00402    struct logchannel *f;
00403    FILE *myf;
00404    int x, res = 0;
00405 
00406    AST_LIST_LOCK(&logchannels);
00407 
00408    if (eventlog) 
00409       fclose(eventlog);
00410    else 
00411       event_rotate = 0;
00412    eventlog = NULL;
00413 
00414    if (qlog) 
00415       fclose(qlog);
00416    else 
00417       queue_rotate = 0;
00418    qlog = NULL;
00419 
00420    mkdir(ast_config_AST_LOG_DIR, 0755);
00421 
00422    AST_LIST_TRAVERSE(&logchannels, f, list) {
00423       if (f->disabled) {
00424          f->disabled = 0;  /* Re-enable logging at reload */
00425          manager_event(EVENT_FLAG_SYSTEM, "LogChannel", "Channel: %s\r\nEnabled: Yes\r\n", f->filename);
00426       }
00427       if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) {
00428          fclose(f->fileptr);  /* Close file */
00429          f->fileptr = NULL;
00430          if (rotate) {
00431             ast_copy_string(old, f->filename, sizeof(old));
00432             
00433             if (!rotatetimestamp) { 
00434                for (x = 0; ; x++) {
00435                   snprintf(new, sizeof(new), "%s.%d", f->filename, x);
00436                   myf = fopen(new, "r");
00437                   if (myf)
00438                      fclose(myf);
00439                   else
00440                      break;
00441                }
00442             } else 
00443                snprintf(new, sizeof(new), "%s.%ld", f->filename, (long)time(NULL));
00444 
00445             /* do it */
00446             if (rename(old,new))
00447                fprintf(stderr, "Unable to rename file '%s' to '%s'\n", old, new);
00448          }
00449       }
00450    }
00451 
00452    filesize_reload_needed = 0;
00453    
00454    init_logger_chain();
00455 
00456    if (logfiles.event_log) {
00457       snprintf(old, sizeof(old), "%s/%s", ast_config_AST_LOG_DIR, EVENTLOG);
00458       if (event_rotate) {
00459          if (!rotatetimestamp) { 
00460             for (x=0;;x++) {
00461                snprintf(new, sizeof(new), "%s/%s.%d", ast_config_AST_LOG_DIR, EVENTLOG,x);
00462                myf = fopen(new, "r");
00463                if (myf)    /* File exists */
00464                   fclose(myf);
00465                else
00466                   break;
00467             }
00468          } else 
00469             snprintf(new, sizeof(new), "%s/%s.%ld", ast_config_AST_LOG_DIR, EVENTLOG,(long)time(NULL));
00470    
00471          /* do it */
00472          if (rename(old,new))
00473             ast_log(LOG_ERROR, "Unable to rename file '%s' to '%s'\n", old, new);
00474       }
00475 
00476       eventlog = fopen(old, "a");
00477       if (eventlog) {
00478          ast_log(LOG_EVENT, "Restarted Asterisk Event Logger\n");
00479          if (option_verbose)
00480             ast_verbose("Asterisk Event Logger restarted\n");
00481       } else {
00482          ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno));
00483          res = -1;
00484       }
00485    }
00486 
00487    if (logfiles.queue_log) {
00488       snprintf(old, sizeof(old), "%s/%s", ast_config_AST_LOG_DIR, queue_log_name);
00489       if (queue_rotate) {
00490          if (!rotatetimestamp) { 
00491             for (x = 0; ; x++) {
00492                snprintf(new, sizeof(new), "%s/%s.%d", ast_config_AST_LOG_DIR, queue_log_name, x);
00493                myf = fopen(new, "r");
00494                if (myf)    /* File exists */
00495                   fclose(myf);
00496                else
00497                   break;
00498             }
00499    
00500          } else 
00501             snprintf(new, sizeof(new), "%s/%s.%ld", ast_config_AST_LOG_DIR, queue_log_name,(long)time(NULL));
00502          /* do it */
00503          if (rename(old, new))
00504             ast_log(LOG_ERROR, "Unable to rename file '%s' to '%s'\n", old, new);
00505       }
00506 
00507       qlog = fopen(old, "a");
00508       if (qlog) {
00509          ast_queue_log("NONE", "NONE", "NONE", "CONFIGRELOAD", "%s", "");
00510          ast_log(LOG_EVENT, "Restarted Asterisk Queue Logger\n");
00511          if (option_verbose)
00512             ast_verbose("Asterisk Queue Logger restarted\n");
00513       } else {
00514          ast_log(LOG_ERROR, "Unable to create queue log: %s\n", strerror(errno));
00515          res = -1;
00516       }
00517    }
00518 
00519    AST_LIST_UNLOCK(&logchannels);
00520 
00521    return res;
00522 }


Variable Documentation

struct ast_cli_entry cli_logger[] [static]
 

Definition at line 598 of file logger.c.

Referenced by init_logger().

int close_logger_thread [static]
 

Definition at line 137 of file logger.c.

Referenced by close_logger(), and logger_thread().

int colors[] [static]
 

Definition at line 152 of file logger.c.

Referenced by logger_print_normal().

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

Definition at line 85 of file logger.c.

unsigned int event_log
 

Definition at line 95 of file logger.c.

FILE* eventlog [static]
 

Definition at line 139 of file logger.c.

Referenced by close_logger(), init_logger(), logger_print_normal(), and reload_logger().

int filesize_reload_needed [static]
 

Definition at line 89 of file logger.c.

int global_logmask = -1 [static]
 

Definition at line 90 of file logger.c.

char hostname[MAXHOSTNAMELEN] [static]
 

Definition at line 98 of file logger.c.

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

char* levels[] [static]
 

Definition at line 142 of file logger.c.

Referenced by ast_log_vsyslog(), and logger_print_normal().

ast_cond_t logcond [static]
 

Definition at line 136 of file logger.c.

Referenced by ast_log(), ast_verbose(), close_logger(), init_logger(), and logger_thread().

struct { ... } logfiles [static]
 

Referenced by init_logger(), init_logger_chain(), and logger_print_normal().

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 586 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 590 of file logger.c.

char logger_show_channels_help[] [static]
 

Initial value:

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

Definition at line 594 of file logger.c.

pthread_t logthread = AST_PTHREADT_NULL [static]
 

Definition at line 135 of file logger.c.

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

FILE* qlog [static]
 

Definition at line 140 of file logger.c.

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

unsigned int queue_log
 

Definition at line 94 of file logger.c.

char queue_log_name[256] = QUEUELOG [static]
 

Definition at line 87 of file logger.c.

int rotatetimestamp [static]
 

Definition at line 91 of file logger.c.

int syslog_level_map[] [static]
 

Definition at line 50 of file logger.c.


Asterisk is a trademark for Digium, inc.. | Edvina.net | Asterisk.org | This documentation was generated with Doxygen