Asterisk - The Open Source Telephony Project  18.5.0
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.

References ARRAY_LEN, facility_map, and name.

Referenced by load_config(), and make_logchannel().

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 @426 facility_map[]
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
const char * name
Definition: syslog.c:36

◆ 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.

References ARRAY_LEN, facility_map, LOG_DEBUG, LOG_NOTICE, LOG_WARNING, name, NULL, priority_map, and value.

Referenced by load_config().

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 }
static const struct @426 facility_map[]
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37

◆ 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.

References ARRAY_LEN, name, and priority_map.

Referenced by load_config().

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 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
const char * name
Definition: syslog.c:36
static int priority
static const struct @427 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.

References ARRAY_LEN, ASTNUMLOGLEVELS, LOG_NOTICE, and logger_level_to_syslog_map.

Referenced by logger_print_normal().

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 ARRAY_LEN(a)
Definition: isdn_lib.c:42
#define LOG_NOTICE
Definition: logger.h:263
static const int logger_level_to_syslog_map[]
Definition: syslog.c:152
#define ASTNUMLOGLEVELS
Definition: syslog.h:31

◆ 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.

References ARRAY_LEN, NULL, priority_map, and value.

Referenced by load_config().

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 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37
static int priority
static const struct @427 priority_map[]

Variable Documentation

◆ facility_map

const { ... } 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(), ast_syslog_facility_name(), and ast_syslog_priority().

◆ priority_map

const { ... } priority_map[]

◆ value

int value

Definition at line 37 of file syslog.c.

Referenced by __astman_get_header(), __init_manager(), access_counter_file(), add_row_to_bdb(), alloc_str(), aMYSQL_set(), analog_set_needringing(), apply_dtls_attrib(), apply_options(), ast_ari_asterisk_get_global_var(), ast_ari_channels_get_channel_var(), ast_bucket_file_json(), ast_cc_get_param(), 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_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_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_jb_set(), ast_channel_macropriority_set(), ast_channel_masq_set(), ast_channel_masqr_set(), ast_channel_monitor_set(), ast_channel_music_state_set(), ast_channel_outsmpl_set(), ast_channel_pbx_set(), ast_channel_pickupgroup_set(), ast_channel_priority_set(), 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_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_connected_line_build_data(), ast_connected_line_parse_data(), ast_connected_line_source_describe(), ast_connected_line_source_name(), ast_custom_function_find(), ast_describe_caller_presentation(), ast_eivr_getvariable(), ast_eivr_setvariable(), ast_format_attribute_set(), ast_get_context_name(), ast_json_to_ast_variables(), 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_rtp_instance_set_prop(), ast_rtp_prop_set(), ast_set_cc_agent_policy(), 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_call_codec_pref_to_str(), ast_slinear_saturated_divide(), ast_sorcery_objectset_json_create(), 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_stream_codec_prefs_parse(), ast_syslog_facility_name(), ast_syslog_priority_name(), AST_TEST_DEFINE(), ast_variable_retrieve_filtered(), asterisk_start_devicestate_publishing(), asterisk_start_mwi_publishing(), bridge_check_monitor(), build_calendar(), check_cache_aggregate(), chunked_atoh(), cli_show_subscription_common(), compare_by_value(), console_cmd(), contactstatus_to_ami(), convert_bdb_to_sqlite3(), curl_header_callback(), dahdi_chan_conf_default(), database_increment(), db_get_common(), db_gettree_common(), dialgroup_write(), double2db(), dump_queue_members(), dump_raw(), encode_length(), evaluate_history_entry(), expression_token_alloc(), find_by_value(), free_config(), func_channel_write(), func_confbridge_helper(), func_write_header(), function_realtime_read(), function_realtime_readdestroy(), get_chan_by_ast_name(), get_defaults(), get_diversion_header(), get_history_info_header(), get_mid_bundle_group(), handle_cli_ooh323_show_config(), handle_cli_ooh323_show_gk(), handle_updates(), has_media_level_attribute(), hfp_parse_ciev(), hfp_parse_cind_indicator(), hfp_send_vgs(), http_request_headers_get(), iax_ie_append_versioned_uint64(), iax_provflags2str(), ineligible_configuration(), json_utf8_check_full(), ldap_mod_create(), ldap_mod_duplicate(), load_config(), load_values_config(), lua_get_variable(), lua_get_variable_value(), lua_set_variable(), lua_set_variable_value(), msg_to_json(), my_set_needringing(), my_set_polarity(), mysql_log(), NearestNeighbor(), osp_get_varfloat(), osp_get_varint(), osp_report_qos(), oss_request(), parse_contact_header(), parse_uri_full(), pbx_builtin_importvar(), pbx_builtin_setvar(), pbx_builtin_setvar_multiple(), peerstatus_to_ami(), persistence_generator_data_struct2str(), pgsql_log(), process_echocancel(), process_sdp(), process_sdp_a_dtls(), prometheus_config_post_apply(), pvalVarDecSetValue(), realtime_ldap_entry_to_var(), realtime_ldap_result_to_vars(), realtimefield_read(), redirecting_reason_build_data(), save_response_fields_to_transport(), sayfile_exec(), set_passthru_update(), set_public_key_expiration(), set_ulimit(), setup_stunaddr(), 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(), statsd_exec(), stir_shaken_add_attest(), stir_shaken_add_iat(), stir_shaken_add_origid(), stir_shaken_add_x5u(), store_tone_zone_ring_cadence(), stun_start_monitor(), tos_handler(), transport_tos_handler(), transtime(), update_peer_lastmsgssent(), user_event_hook_cb(), userevent_exec(), vars_to_headers(), varset_to_ami(), vm_change_password(), vm_msg_forward(), vm_msg_play(), vm_msg_snapshot_create(), voicin_(), websocket_client_handshake_get_response(), and write_cel().