Mon Mar 12 2012 21:46:37

Asterisk developer's documentation


syslog.h File Reference

Syslog support functions for Asterisk logging. More...

This graph shows which files directly or indirectly include this file:

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:
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 83 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 96 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 124 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;
}
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 160 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 137 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;
}