Wed Apr 6 11:30:11 2011

Asterisk developer's documentation


syslog.h File Reference

Syslog support functions for Asterisk logging. More...

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.


Detailed Description

Syslog support functions for Asterisk logging.

Definition in file syslog.h.


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

References ARRAY_LEN, facility_map, and name.

Referenced by load_config(), and make_logchannel().

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

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

References ARRAY_LEN, facility_map, and value.

Referenced by load_config().

00097 {
00098    int index;
00099 
00100    for (index = 0; index < ARRAY_LEN(facility_map); index++) {
00101       if (facility_map[index].value == facility) {
00102          return facility_map[index].name;
00103       }
00104    }
00105 
00106    return NULL;
00107 }

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

References ARRAY_LEN, name, and priority_map.

Referenced by load_config().

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

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

References ARRAY_LEN.

Referenced by ast_log_vsyslog().

00161 {
00162    if (level < 0 || level >= ARRAY_LEN(logger_level_to_syslog_map)) {
00163       return -1;
00164    }
00165    return logger_level_to_syslog_map[level];
00166 }

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

References ARRAY_LEN, priority_map, and value.

Referenced by load_config().

00138 {
00139    int index;
00140 
00141    for (index = 0; index < ARRAY_LEN(priority_map); index++) {
00142       if (priority_map[index].value == priority) {
00143          return priority_map[index].name;
00144       }
00145    }
00146 
00147    return NULL;
00148 }


Generated on Wed Apr 6 11:30:11 2011 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7