Wed Jan 8 2020 09:50:21

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

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
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().

88 {
89  int index;
90 
91  for (index = 0; index < ARRAY_LEN(facility_map); index++) {
92  if (!strcasecmp(facility_map[index].name, facility)) {
93  return facility_map[index].value;
94  }
95  }
96 
97  return -1;
98 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static const char name[]
static struct @301 facility_map[]
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().

101 {
102  int index;
103 
104  for (index = 0; index < ARRAY_LEN(facility_map); index++) {
105  if (facility_map[index].value == facility) {
106  return facility_map[index].name;
107  }
108  }
109 
110  return NULL;
111 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
int value
Definition: syslog.c:39
static struct @301 facility_map[]
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().

129 {
130  int index;
131 
132  for (index = 0; index < ARRAY_LEN(priority_map); index++) {
133  if (!strcasecmp(priority_map[index].name, priority)) {
134  return priority_map[index].value;
135  }
136  }
137 
138  return -1;
139 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static struct @302 priority_map[]
static const char name[]
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 164 of file syslog.c.

References ARRAY_LEN.

Referenced by ast_log_vsyslog().

165 {
166  if (level < 0 || level >= ARRAY_LEN(logger_level_to_syslog_map)) {
167  return -1;
168  }
169  return logger_level_to_syslog_map[level];
170 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static const int logger_level_to_syslog_map[]
Definition: syslog.c:154
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().

142 {
143  int index;
144 
145  for (index = 0; index < ARRAY_LEN(priority_map); index++) {
146  if (priority_map[index].value == priority) {
147  return priority_map[index].name;
148  }
149  }
150 
151  return NULL;
152 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static struct @302 priority_map[]
int value
Definition: syslog.c:39