Sat Apr 26 2014 22:03:19

Asterisk developer's documentation


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.
const char * ast_syslog_facility_name (int facility)
 Maps a syslog facility constant to a string.
int ast_syslog_priority (const char *priority)
 Maps a syslog priority name from a string to a syslog priority constant.
int ast_syslog_priority_from_loglevel (int level)
 Maps an Asterisk log level (i.e. LOG_ERROR) to a syslog priority constant.
const char * ast_syslog_priority_name (int priority)
 Maps a syslog priority constant to a string.

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@malleable.com>

Definition in file syslog.c.


Function Documentation

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 87 of file syslog.c.

References ARRAY_LEN, facility_map, and name.

Referenced by load_config(), and make_logchannel().

{
   int index;

   for (index = 0; index < ARRAY_LEN(facility_map); index++) {
      if (!strcasecmp(facility_map[index].name, facility)) {
         return facility_map[index].value;
      }
   }

   return -1;
}
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 100 of file syslog.c.

References ARRAY_LEN, facility_map, and value.

Referenced by load_config().

{
   int index;

   for (index = 0; index < ARRAY_LEN(facility_map); index++) {
      if (facility_map[index].value == facility) {
         return facility_map[index].name;
      }
   }

   return NULL;
}
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 128 of file syslog.c.

References ARRAY_LEN, name, and priority_map.

Referenced by load_config().

{
   int index;

   for (index = 0; index < ARRAY_LEN(priority_map); index++) {
      if (!strcasecmp(priority_map[index].name, priority)) {
         return priority_map[index].value;
      }
   }

   return -1;
}

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 164 of file syslog.c.

References ARRAY_LEN.

Referenced by ast_log_vsyslog().

{
   if (level < 0 || level >= ARRAY_LEN(logger_level_to_syslog_map)) {
      return -1;
   }
   return logger_level_to_syslog_map[level];
}
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 141 of file syslog.c.

References ARRAY_LEN, priority_map, and value.

Referenced by load_config().

{
   int index;

   for (index = 0; index < ARRAY_LEN(priority_map); index++) {
      if (priority_map[index].value == priority) {
         return priority_map[index].name;
      }
   }

   return NULL;
}

Variable Documentation

struct { ... } facility_map[] [static]
const int logger_level_to_syslog_map[] [static]

Definition at line 154 of file syslog.c.

const char* name

Definition at line 38 of file syslog.c.

struct { ... } priority_map[] [static]
int value

Definition at line 39 of file syslog.c.

Referenced by __astman_get_header(), __init_manager(), access_counter_file(), apply_options(), ast_cc_get_param(), ast_channel_adsicpe_set(), ast_channel_amaflags_set(), ast_channel_appl_set(), ast_channel_audiohooks_set(), ast_channel_blocker_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_insmpl_set(), ast_channel_internal_bridge_set(), ast_channel_internal_bridged_channel_set(), ast_channel_internal_fd_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_nativeformats_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_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_describe_caller_presentation(), ast_eivr_getvariable(), ast_eivr_setvariable(), 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_dtls_set_fingerprint(), ast_rtp_instance_set_prop(), 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_slinear_saturated_divide(), ast_syslog_facility_name(), ast_syslog_priority_name(), build_calendar(), console_cmd(), data_search_generate(), database_increment(), db_get_common(), dialgroup_write(), dump_queue_members(), dump_raw(), encode_length(), free_config(), func_channel_write(), function_realtime_read(), function_realtime_readdestroy(), handle_updates(), httpd_helper_thread(), iax_ie_append_versioned_uint64(), iax_provflags2str(), load_values_config(), lua_get_variable(), lua_get_variable_value(), lua_set_variable(), lua_set_variable_value(), my_set_needringing(), my_set_polarity(), osp_get_varfloat(), osp_get_varint(), osp_report_qos(), parse_contact_header(), parse_uri_full(), pbx_builtin_importvar(), pbx_builtin_setvar(), pbx_builtin_setvar_multiple(), pgsql_log(), process_echocancel(), process_sdp(), process_sdp_a_dtls(), pvalVarDecSetValue(), realtime_ldap_entry_to_var(), realtime_ldap_result_to_vars(), realtime_sqlite3_destroy(), realtime_sqlite3_helper(), realtime_sqlite3_store(), realtime_sqlite3_update(), realtime_sqlite3_update2(), realtime_update2_handler(), realtimefield_read(), set_ulimit(), sla_add_trunk_to_station(), sort_internal(), transtime(), update_peer_lastmsgssent(), vm_change_password(), vm_msg_forward(), vm_msg_play(), vm_msg_snapshot_create(), and write_cdr().