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:
facility Facility name to map (i.e. "daemon")
Return values:
syslog facility constant (i.e. LOG_DAEMON) if found
-1 if 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().

00088 {
00089    int index;
00090 
00091    for (index = 0; index < ARRAY_LEN(facility_map); index++) {
00092       if (!strcasecmp(facility_map[index].name, facility)) {
00093          return facility_map[index].value;
00094       }
00095    }
00096 
00097    return -1;
00098 }

const char* ast_syslog_facility_name ( int  facility  ) 

Maps a syslog facility constant to a string.

Since:
1.8
Parameters:
facility syslog facility constant to map (i.e. LOG_DAEMON)
Return values:
facility name (i.e. "daemon") if found
NULL if facility is not found

Definition at line 100 of file syslog.c.

References ARRAY_LEN, facility_map, NULL, and value.

Referenced by load_config().

00101 {
00102    int index;
00103 
00104    for (index = 0; index < ARRAY_LEN(facility_map); index++) {
00105       if (facility_map[index].value == facility) {
00106          return facility_map[index].name;
00107       }
00108    }
00109 
00110    return NULL;
00111 }

int ast_syslog_priority ( const char *  priority  ) 

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

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

Definition at line 128 of file syslog.c.

References ARRAY_LEN, name, and priority_map.

Referenced by load_config().

00129 {
00130    int index;
00131 
00132    for (index = 0; index < ARRAY_LEN(priority_map); index++) {
00133       if (!strcasecmp(priority_map[index].name, priority)) {
00134          return priority_map[index].value;
00135       }
00136    }
00137 
00138    return -1;
00139 }

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:
level Asterisk log level constant (i.e. LOG_ERROR)
Return values:
syslog priority constant (i.e. LOG_ERR) if found
-1 if priority is not found

Definition at line 164 of file syslog.c.

References ARRAY_LEN, ASTNUMLOGLEVELS, and LOG_NOTICE.

Referenced by ast_log_vsyslog().

00165 {
00166    /* First 16 levels are reserved for system use.
00167     * Default to using LOG_NOTICE for dynamic logging.
00168     */
00169    if (level >= 16 && level < ASTNUMLOGLEVELS) {
00170       return LOG_NOTICE;
00171    }
00172 
00173    if (level < 0 || level >= ARRAY_LEN(logger_level_to_syslog_map)) {
00174       return -1;
00175    }
00176 
00177    return logger_level_to_syslog_map[level];
00178 }

const char* ast_syslog_priority_name ( int  priority  ) 

Maps a syslog priority constant to a string.

Since:
1.8
Parameters:
priority syslog priority constant to map (i.e. LOG_NOTICE)
Return values:
priority name (i.e. "notice") if found
NULL if priority is not found

Definition at line 141 of file syslog.c.

References ARRAY_LEN, NULL, priority_map, and value.

Referenced by load_config().

00142 {
00143    int index;
00144 
00145    for (index = 0; index < ARRAY_LEN(priority_map); index++) {
00146       if (priority_map[index].value == priority) {
00147          return priority_map[index].name;
00148       }
00149    }
00150 
00151    return NULL;
00152 }


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(), add_row_to_bdb(), aMYSQL_set(), 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_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_json_object_update_existing(), ast_json_object_update_missing(), 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_sorcery_objectset_json_create(), ast_syslog_facility_name(), ast_syslog_priority_name(), AST_TEST_DEFINE(), asterisk_start_devicestate_publishing(), asterisk_start_mwi_publishing(), bridge_check_monitor(), build_calendar(), cdr_read_callback(), chunked_atoh(), console_cmd(), convert_bdb_to_sqlite3(), data_search_generate(), database_increment(), db_get_common(), dialgroup_write(), dump_queue_members(), free_config(), function_realtime_read(), function_realtime_readdestroy(), get_defaults(), get_diversion_header(), handle_cli_ooh323_show_config(), handle_cli_ooh323_show_gk(), handle_updates(), http_request_headers_get(), iax_provflags2str(), load_config(), load_users(), load_values_config(), lua_get_variable(), lua_get_variable_value(), lua_set_variable(), lua_set_variable_value(), msg_to_json(), mysql_log(), 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(), peerstatus_to_ami(), permanent_contact_validate(), pgsql_log(), process_echocancel(), process_sdp(), process_sdp_a_dtls(), realtime_is_object_matching(), realtime_ldap_entry_to_var(), realtime_ldap_result_to_vars(), realtimefield_read(), redirecting_reason_build_data(), sla_add_trunk_to_station(), sorcery_astdb_create(), sorcery_astdb_delete(), sorcery_astdb_retrieve_id(), sorcery_astdb_update(), sorcery_config_open(), sorcery_json_to_objectset(), sorcery_objectset_to_json(), sorcery_realtime_retrieve_multiple(), sorcery_realtime_retrieve_regex(), sort_internal(), tos_handler(), transport_tos_handler(), transtime(), 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(), write_cdr(), and write_cel().


Generated on Thu Apr 16 06:34:07 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6