Asterisk - The Open Source Telephony Project GIT-master-85241bd
Functions | Variables
syslog.c File Reference

Asterisk Syslog Utility Functions. More...

#include "asterisk.h"
#include "asterisk/utils.h"
#include "asterisk/syslog.h"
Include dependency graph for syslog.c:

Go to the source code of this file.

Functions

int ast_syslog_facility (const char *facility)
 Maps a syslog facility name from a string to a syslog facility constant. More...
 
const char * ast_syslog_facility_name (int facility)
 Maps a syslog facility constant to a string. More...
 
int ast_syslog_priority (const char *priority)
 Maps a syslog priority name from a string to a syslog priority constant. More...
 
int ast_syslog_priority_from_loglevel (int level)
 Maps an Asterisk log level (i.e. LOG_ERROR) to a syslog priority constant. More...
 
const char * ast_syslog_priority_name (int priority)
 Maps a syslog priority constant to a string. More...
 

Variables

struct {
   const char *   name
 
   int   value
 
facility_map []
 
static const int logger_level_to_syslog_map []
 
struct {
   const char *   name
 
   int   value
 
priority_map []
 

Detailed Description

Asterisk Syslog Utility Functions.

Author
Sean Bright sean@.nosp@m.mall.nosp@m.eable.nosp@m..com

Definition in file syslog.c.

Function Documentation

◆ ast_syslog_facility()

int ast_syslog_facility ( const char *  facility)

Maps a syslog facility name from a string to a syslog facility constant.

Since
1.8
Parameters
facilityFacility name to map (i.e. "daemon")
Return values
syslogfacility constant (i.e. LOG_DAEMON) if found
-1if facility is not found

Definition at line 85 of file syslog.c.

86{
87 int index;
88
89 for (index = 0; index < ARRAY_LEN(facility_map); index++) {
90 if (!strcasecmp(facility_map[index].name, facility)) {
91 return facility_map[index].value;
92 }
93 }
94
95 return -1;
96}
static const struct @404 facility_map[]
const char * name
Definition: syslog.c:36
#define ARRAY_LEN(a)
Definition: utils.h:666

References ARRAY_LEN, facility_map, and name.

Referenced by make_logchannel().

◆ ast_syslog_facility_name()

const char * ast_syslog_facility_name ( int  facility)

Maps a syslog facility constant to a string.

Since
1.8
Parameters
facilitysyslog facility constant to map (i.e. LOG_DAEMON)
Return values
facilityname (i.e. "daemon") if found
NULLif facility is not found

Definition at line 98 of file syslog.c.

99{
100 int index;
101
102 for (index = 0; index < ARRAY_LEN(facility_map); index++) {
103 if (facility_map[index].value == facility) {
104 return facility_map[index].name;
105 }
106 }
107
108 return NULL;
109}
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37

References ARRAY_LEN, facility_map, NULL, and value.

◆ ast_syslog_priority()

int ast_syslog_priority ( const char *  priority)

Maps a syslog priority name from a string to a syslog priority constant.

Since
1.8
Parameters
priorityPriority name to map (i.e. "notice")
Return values
syslogpriority constant (i.e. LOG_NOTICE) if found
-1if priority is not found

Definition at line 126 of file syslog.c.

127{
128 int index;
129
130 for (index = 0; index < ARRAY_LEN(priority_map); index++) {
131 if (!strcasecmp(priority_map[index].name, priority)) {
132 return priority_map[index].value;
133 }
134 }
135
136 return -1;
137}
static int priority
static const struct @405 priority_map[]

References ARRAY_LEN, name, priority, and priority_map.

◆ ast_syslog_priority_from_loglevel()

int ast_syslog_priority_from_loglevel ( int  level)

Maps an Asterisk log level (i.e. LOG_ERROR) to a syslog priority constant.

Since
1.8
Parameters
levelAsterisk log level constant (i.e. LOG_ERROR)
Return values
syslogpriority constant (i.e. LOG_ERR) if found
-1if priority is not found

Definition at line 162 of file syslog.c.

163{
164 /* First 16 levels are reserved for system use.
165 * Default to using LOG_NOTICE for dynamic logging.
166 */
167 if (level >= 16 && level < ASTNUMLOGLEVELS) {
168 return LOG_NOTICE;
169 }
170
171 if (level < 0 || level >= ARRAY_LEN(logger_level_to_syslog_map)) {
172 return -1;
173 }
174
175 return logger_level_to_syslog_map[level];
176}
#define LOG_NOTICE
static const int logger_level_to_syslog_map[]
Definition: syslog.c:152
#define ASTNUMLOGLEVELS
Definition: syslog.h:32

References ARRAY_LEN, ASTNUMLOGLEVELS, LOG_NOTICE, and logger_level_to_syslog_map.

Referenced by logger_print_normal().

◆ ast_syslog_priority_name()

const char * ast_syslog_priority_name ( int  priority)

Maps a syslog priority constant to a string.

Since
1.8
Parameters
prioritysyslog priority constant to map (i.e. LOG_NOTICE)
Return values
priorityname (i.e. "notice") if found
NULLif priority is not found

Definition at line 139 of file syslog.c.

140{
141 int index;
142
143 for (index = 0; index < ARRAY_LEN(priority_map); index++) {
144 if (priority_map[index].value == priority) {
145 return priority_map[index].name;
146 }
147 }
148
149 return NULL;
150}

References ARRAY_LEN, NULL, priority, priority_map, and value.

Variable Documentation

◆ 

const struct { ... } facility_map[]

◆ logger_level_to_syslog_map

const int logger_level_to_syslog_map[]
static

Definition at line 152 of file syslog.c.

Referenced by ast_syslog_priority_from_loglevel().

◆ name

const char* name

Definition at line 36 of file syslog.c.

Referenced by ast_syslog_facility(), and ast_syslog_priority().

◆ 

const struct { ... } priority_map[]

◆ value

int value

Definition at line 37 of file syslog.c.

Referenced by __astman_get_header(), __init_manager(), _ast_var_assign(), _ast_variable_new(), access_counter_file(), acf_cc_write(), acf_curl_write(), acf_curlopt_write(), acf_faxopt_write(), acf_iaxvar_write(), acf_odbc_write(), acf_transaction_write(), add_header(), add_redirect(), add_row_to_bdb(), alloc_header(), alloc_str(), analog_set_needringing(), analog_str_to_cidstart(), aoc_charge_type_str(), aoc_charged_item_str(), aoc_rate_type_str(), aoc_scale_str(), aoc_time_scale_str(), aoc_type_of_totaling_str(), aoc_volume_unit_str(), aoc_xml_create_attr(), append_var_and_value_to_filter(), append_variable(), apply_dtls_attrib(), apply_option(), apply_options(), array(), assign_and_insert(), ast_ari_asterisk_get_global_var(), ast_ari_channels_get_channel_var(), ast_bridge_call_with_flags(), ast_bridge_set_transfer_variables(), ast_bucket_file_json(), ast_bucket_file_metadata_set(), ast_cc_get_param(), ast_cc_set_param(), ast_cdr_getvar(), ast_cdr_setvar(), ast_channel_adsicpe_set(), ast_channel_amaflags_set(), ast_channel_answertime_set(), ast_channel_appl_set(), ast_channel_audiohooks_set(), ast_channel_blocker_set(), ast_channel_blocker_tid_set(), ast_channel_blockproc_set(), ast_channel_caller_set(), ast_channel_callgroup_set(), ast_channel_cdr_set(), ast_channel_connected_set(), ast_channel_context_set(), ast_channel_creationtime_set(), ast_channel_data_set(), ast_channel_dialed_set(), ast_channel_dtmf_digit_to_emulate_set(), ast_channel_dtmf_tv_set(), ast_channel_dtmff_set(), ast_channel_emulate_dtmf_duration_set(), ast_channel_exten_set(), ast_channel_fd_add(), ast_channel_fdno_set(), ast_channel_fin_set(), ast_channel_fout_set(), ast_channel_framehooks_set(), ast_channel_generator_set(), ast_channel_generatordata_set(), ast_channel_hangupcause_set(), ast_channel_hold_state_set(), ast_channel_insmpl_set(), ast_channel_internal_bridge_channel_set(), ast_channel_internal_bridge_set(), ast_channel_internal_fd_set(), ast_channel_jb_set(), ast_channel_masq_set(), ast_channel_masqr_set(), ast_channel_music_state_set(), ast_channel_named_callgroups_set(), ast_channel_named_pickupgroups_set(), ast_channel_nativeformats_set(), ast_channel_outsmpl_set(), ast_channel_pbx_set(), ast_channel_pickupgroup_set(), ast_channel_priority_set(), ast_channel_publish_varset(), ast_channel_readtrans_set(), ast_channel_redirecting_set(), ast_channel_rings_set(), ast_channel_sched_set(), ast_channel_sending_dtmf_digit_set(), ast_channel_sending_dtmf_tv_set(), ast_channel_set_bridge_role_option(), ast_channel_set_unbridged(), ast_channel_set_unbridged_nolock(), ast_channel_softhangup_internal_flag_add(), ast_channel_softhangup_internal_flag_set(), ast_channel_state_set(), ast_channel_stream_set(), ast_channel_streamid_set(), ast_channel_tech_pvt_set(), ast_channel_tech_set(), ast_channel_timer_set(), ast_channel_timingdata_set(), ast_channel_timingfd_set(), ast_channel_timingfunc_set(), ast_channel_transfercapability_set(), ast_channel_varshead_set(), ast_channel_visible_indication_set(), ast_channel_vstream_set(), ast_channel_vstreamid_set(), ast_channel_whentohangup_set(), ast_channel_writetrans_set(), ast_channel_zone_set(), ast_cli_completion_add(), ast_connected_line_build_data(), ast_connected_line_parse_data(), ast_connected_line_source_describe(), ast_connected_line_source_name(), ast_context_add_ignorepat(), ast_context_add_ignorepat2(), ast_context_add_include2(), ast_context_add_switch2(), ast_db_get(), ast_db_put(), ast_describe_caller_presentation(), ast_eivr_getvariable(), ast_eivr_setvariable(), ast_format_attribute_set(), ast_func_write(), ast_http_header_match(), ast_http_header_match_in(), ast_http_header_parse(), ast_jb_read_conf(), ast_json_array_append(), ast_json_array_insert(), ast_json_array_set(), ast_json_boolean(), ast_json_copy(), ast_json_deep_copy(), ast_json_integer_create(), ast_json_integer_set(), ast_json_object_iter_set(), ast_json_object_set(), ast_json_real_create(), ast_json_real_set(), ast_json_string_create(), ast_json_string_set(), ast_json_to_ast_variables(), ast_media_cache_retrieve_metadata(), ast_msg_data_alloc(), ast_msg_set_var(), ast_msg_set_var_outbound(), ast_msg_var_iterator_get_next(), ast_msg_var_iterator_next(), ast_msg_var_iterator_next_received(), ast_named_caller_presentation(), ast_party_name_charset_describe(), ast_party_name_charset_str(), ast_redirecting_build_data(), ast_redirecting_parse_data(), ast_redirecting_reason_describe(), ast_redirecting_reason_name(), ast_refer_set_var_outbound(), ast_refer_var_iterator_next(), ast_rtp_dtls_cfg_parse(), ast_rtp_instance_set_extended_prop(), ast_rtp_instance_set_prop(), ast_rtp_prop_set(), ast_set_cc_agent_dialstring(), ast_set_cc_agent_policy(), ast_set_cc_callback_sub(), ast_set_cc_max_agents(), ast_set_cc_max_monitors(), ast_set_cc_monitor_policy(), ast_set_cc_offer_timer(), ast_set_cc_recall_timer(), ast_set_ccbs_available_timer(), ast_set_ccnr_available_timer(), ast_sip_add_global_request_header(), ast_sip_add_global_response_header(), ast_sip_add_header(), ast_sip_add_header2(), ast_sip_auth_vector_init(), ast_sip_call_codec_pref_to_str(), ast_sip_presence_xml_create_attr(), ast_sip_remove_headers_by_name_and_value(), ast_sip_security_mechanism_vector_init(), ast_sip_str_to_security_mechanism(), ast_slinear_saturated_add(), ast_slinear_saturated_divide(), ast_slinear_saturated_divide_float(), ast_slinear_saturated_multiply(), ast_slinear_saturated_multiply_float(), ast_slinear_saturated_subtract(), ast_sorcery_object_set_extended(), ast_sorcery_objectset_json_create(), ast_speech_change(), ast_statsd_log(), ast_statsd_log_full(), ast_statsd_log_full_va(), ast_statsd_log_sample(), ast_statsd_log_string(), ast_statsd_log_string_va(), ast_str2cos(), ast_str2tos(), ast_str_append_event_header(), ast_str_substring(), ast_stream_codec_prefs_parse(), ast_stream_set_metadata(), ast_syslog_facility_name(), ast_syslog_priority_name(), AST_TEST_DEFINE(), ast_tls_read_conf(), ast_var_assign(), ast_variable_new(), ast_variable_retrieve_filtered(), ast_variable_update(), ast_xml_set_attribute(), asterisk_start_devicestate_publishing(), asterisk_start_mwi_publishing(), bucket_metadata_alloc(), build_calendar(), build_channels(), build_mapping(), build_notify(), cache_test_message_create(), cache_test_message_create_full(), calendar_write_exec(), callerid_write(), cdr_object_format_property(), cdr_object_format_var_internal(), cdr_prop_write(), cdr_read_callback(), cdr_retrieve_time(), cdr_write(), celt_set(), check_cache_aggregate(), chunked_atoh(), cli_completion_vector_add(), cli_show_subscription_common(), compare_by_value(), configuration_parse_unsigned_integer(), connectedline_write(), contactstatus_to_ami(), convert_bdb_to_sqlite3(), curl_header_callback(), curl_header_cb(), dahdi_func_write(), database_increment(), db_get_common(), db_gettree_common(), db_put_raw(), devstate_write(), dialgroup_write(), double2db(), dump_addr(), dump_answer(), dump_byte(), dump_cause(), dump_datetime(), dump_eid(), dump_encrypted(), dump_hint(), dump_int(), dump_ipaddr(), dump_prefs(), dump_prov(), dump_prov_flags(), dump_queue_members(), dump_raw(), dump_samprate(), dump_short(), dump_string(), dump_string_hex(), dump_versioned_codec(), dundi_ie_append_int(), dundi_ie_append_short(), encode_length(), env_write(), evaluate_history_entry(), expression_token_alloc(), feature_write(), featuremap_set(), featuremap_write(), file_write(), find_by_value(), float_validator(), frame_drop_helper(), frame_set_var(), frame_trace_helper(), free_config(), func_channel_write(), func_channel_write_real(), func_confbridge_helper(), func_export_write(), func_mchan_write(), func_mute_write(), func_write_header(), func_write_param(), function_db_write(), function_ooh323_write(), function_realtime_read(), function_realtime_readdestroy(), function_realtime_store(), function_realtime_write(), general_set(), geoloc_eprofile_to_intermediate(), geoloc_gml_list_to_xml(), geoloc_profile_write(), get_auth_methods(), get_defaults(), get_diversion_header(), get_history_info_header(), get_mid_bundle_group(), global_write(), group_function_write(), handle_cli_ooh323_show_config(), handle_cli_ooh323_show_gk(), handle_setting(), handle_updates(), hash_write(), hfp_parse_ciev(), hfp_parse_cind_indicator(), hfp_send_vgs(), hook_write(), http_request_headers_get(), iax2_register(), iax_ie_append_int(), iax_ie_append_short(), iax_ie_append_versioned_uint64(), iax_provflags2str(), ignorepat_alloc(), include_alloc(), incoming_in_dialog_request(), internal_feature_write(), internal_featuremap_write(), jack_hook_write(), jb_helper(), json_utf8_check_full(), ldap_mod_create(), ldap_mod_duplicate(), load_config(), load_users(), load_values_config(), local_write(), localized_context_add_ignorepat2(), localized_context_add_include2(), localized_context_add_switch2(), log_group_write(), lua_get_variable(), lua_get_variable_value(), lua_set_variable(), lua_set_variable_value(), manager_json_value_str_append(), minivm_counter_func_write(), msg_data_func_write(), msg_func_write(), msg_set_var_full(), msg_to_json(), my_set_needringing(), my_set_polarity(), myexit(), NearestNeighbor(), non_neg_value_range(), opus_set(), P2(), parse_cdata(), parse_empty_options(), parse_refer_json(), party_id_write(), party_name_write(), party_number_write(), party_subaddress_write(), pbx_builtin_pushvar_helper(), pbx_builtin_setvar(), pbx_builtin_setvar_helper(), pbx_builtin_setvar_multiple(), peerstatus_to_ami(), persistence_generator_data_struct2str(), pgsql_log(), pickup_set(), pitchshift_helper(), pjsip_acf_dtmf_mode_write(), pjsip_acf_media_offer_write(), pjsip_acf_moh_passthrough_write(), pjsip_acf_session_refresh_write(), polarity_write(), pos3d_validator(), pos_validator(), presence_write(), process_echocancel(), prometheus_config_post_apply(), pvalVarDecSetValue(), queue_function_mem_write(), queue_function_memberpenalty_write(), realtime_ldap_entry_to_var(), realtime_ldap_result_to_vars(), realtimefield_read(), redirecting_reason_build_data(), redirecting_write(), refer_set_var_full(), save_response_fields_to_transport(), sayfile_exec(), scramble_write(), set_active(), set_member_value(), set_member_value_help_members(), set_passthru_update(), set_t38timeout(), set_ulimit(), set_variable(), setup_bridge_role_option(), setup_stunaddr(), shared_write(), silk_set(), sla_add_trunk_to_station(), sorcery_astdb_create(), sorcery_astdb_delete(), sorcery_astdb_retrieve_id(), sorcery_astdb_update(), sorcery_config_open(), sorcery_memory_cache_open(), sorcery_realtime_open(), sorcery_realtime_retrieve_multiple(), sorcery_realtime_retrieve_prefix(), sorcery_realtime_retrieve_regex(), sort_internal(), speech_aeap_engine_change(), speech_aeap_set(), speech_engine_write(), speech_results_type_write(), speex_write(), stasis_app_control_set_channel_var(), stasis_app_device_state_update(), statsd_exec(), store_callerid(), store_config_core(), store_config_tone_zone(), store_tone_zone_ring_cadence(), str_to_agent_policy(), str_to_monitor_policy(), substitute_escapes(), substring(), sw_alloc(), talk_detect_fn_write(), test_core_format_attribute_set(), testtime_write(), timeout_write(), tos_handler(), transport_tos_handler(), transtime(), uom_validator(), update_modem_bits(), update_realtime_member_field(), user_event_hook_cb(), userevent_exec(), validate_metric_type_counter(), validate_metric_type_gauge(), validate_metric_type_set(), validate_metric_type_timer(), value_in_range(), var_list_from_confidence(), var_list_from_node(), variable_list_append(), vars_to_headers(), varset_to_ami(), verify_user_event_fields(), vm_change_password(), vm_msg_forward(), vm_msg_play(), vm_msg_snapshot_create(), voicin_(), volume_write(), vp8_set(), websocket_client_handshake_get_response(), write_cdr(), write_cel(), xfer_set(), and xmldoc_attribute_match().