[asterisk-commits] seanbright: branch seanbright/cdr-syslog r203606 - in /team/seanbright/cdr-sy...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 26 08:01:32 CDT 2009


Author: seanbright
Date: Fri Jun 26 08:01:29 2009
New Revision: 203606

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=203606
Log:
Merged revisions 203605 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
  r203605 | seanbright | 2009-06-26 09:00:35 -0400 (Fri, 26 Jun 2009) | 5 lines
  
  Add functions to map syslog facilities and priorities constants to strings.
  
  Also change the default casing of the string contants to lowercase.  This really
  just saves us from have to lowercase them later when displaying them.
........

Modified:
    team/seanbright/cdr-syslog/   (props changed)
    team/seanbright/cdr-syslog/include/asterisk/syslog.h
    team/seanbright/cdr-syslog/main/syslog.c

Propchange: team/seanbright/cdr-syslog/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Jun 26 08:01:29 2009
@@ -1,1 +1,1 @@
-/trunk:1-203597
+/trunk:1-203605

Modified: team/seanbright/cdr-syslog/include/asterisk/syslog.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/seanbright/cdr-syslog/include/asterisk/syslog.h?view=diff&rev=203606&r1=203605&r2=203606
==============================================================================
--- team/seanbright/cdr-syslog/include/asterisk/syslog.h (original)
+++ team/seanbright/cdr-syslog/include/asterisk/syslog.h Fri Jun 26 08:01:29 2009
@@ -42,6 +42,17 @@
 
 /*!
  * \since 1.6.3
+ * \brief Maps a syslog facility constant to a string.
+ *
+ * \param facility syslog facility constant to map (i.e. LOG_DAEMON)
+ *
+ * \retval facility name (i.e. "daemon") if found
+ * \retval NULL if facility is not found
+ */
+const char *ast_syslog_facility_name(int facility);
+
+/*!
+ * \since 1.6.3
  * \brief Maps a syslog priority name from a string to a syslog priority
  *        constant.
  *
@@ -51,6 +62,17 @@
  * \retval -1 if priority is not found
  */
 int ast_syslog_priority(const char *priority);
+
+/*!
+ * \since 1.6.3
+ * \brief Maps a syslog priority constant to a string.
+ *
+ * \param priority syslog priority constant to map (i.e. LOG_NOTICE)
+ *
+ * \retval priority name (i.e. "notice") if found
+ * \retval NULL if priority is not found
+ */
+const char *ast_syslog_priority_name(int priority);
 
 /*!
  * \since 1.6.3

Modified: team/seanbright/cdr-syslog/main/syslog.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/seanbright/cdr-syslog/main/syslog.c?view=diff&rev=203606&r1=203605&r2=203606
==============================================================================
--- team/seanbright/cdr-syslog/main/syslog.c (original)
+++ team/seanbright/cdr-syslog/main/syslog.c Fri Jun 26 08:01:29 2009
@@ -35,48 +35,48 @@
 	int value;
 } facility_map[] = {
 	/* POSIX only specifies USER and LOCAL0 - LOCAL7 */
-	{ "USER",     LOG_USER     },
-	{ "LOCAL0",   LOG_LOCAL0   },
-	{ "LOCAL1",   LOG_LOCAL1   },
-	{ "LOCAL2",   LOG_LOCAL2   },
-	{ "LOCAL3",   LOG_LOCAL3   },
-	{ "LOCAL4",   LOG_LOCAL4   },
-	{ "LOCAL5",   LOG_LOCAL5   },
-	{ "LOCAL6",   LOG_LOCAL6   },
-	{ "LOCAL7",   LOG_LOCAL7   },
+	{ "user",     LOG_USER     },
+	{ "local0",   LOG_LOCAL0   },
+	{ "local1",   LOG_LOCAL1   },
+	{ "local2",   LOG_LOCAL2   },
+	{ "local3",   LOG_LOCAL3   },
+	{ "local4",   LOG_LOCAL4   },
+	{ "local5",   LOG_LOCAL5   },
+	{ "local6",   LOG_LOCAL6   },
+	{ "local7",   LOG_LOCAL7   },
 #if defined(HAVE_SYSLOG_FACILITY_LOG_KERN)
-	{ "KERN",     LOG_KERN     },
+	{ "kern",     LOG_KERN     },
 #endif
 #if defined(HAVE_SYSLOG_FACILITY_LOG_MAIL)
-	{ "MAIL",     LOG_MAIL     },
+	{ "mail",     LOG_MAIL     },
 #endif
 #if defined(HAVE_SYSLOG_FACILITY_LOG_DAEMON)
-	{ "DAEMON",   LOG_DAEMON   },
+	{ "daemon",   LOG_DAEMON   },
 #endif
 #if defined(HAVE_SYSLOG_FACILITY_LOG_AUTH)
-	{ "AUTH",     LOG_AUTH     },
-	{ "SECURITY", LOG_AUTH     },
+	{ "auth",     LOG_AUTH     },
+	{ "security", LOG_AUTH     },
 #endif
 #if defined(HAVE_SYSLOG_FACILITY_LOG_AUTHPRIV)
-	{ "AUTHPRIV", LOG_AUTHPRIV },
+	{ "authpriv", LOG_AUTHPRIV },
 #endif
 #if defined(HAVE_SYSLOG_FACILITY_LOG_SYSLOG)
-	{ "SYSLOG",   LOG_SYSLOG   },
+	{ "syslog",   LOG_SYSLOG   },
 #endif
 #if defined(HAVE_SYSLOG_FACILITY_LOG_FTP)
-	{ "FTP",      LOG_FTP      },
+	{ "ftp",      LOG_FTP      },
 #endif
 #if defined(HAVE_SYSLOG_FACILITY_LOG_LPR)
-	{ "LPR",      LOG_LPR      },
+	{ "lpr",      LOG_LPR      },
 #endif
 #if defined(HAVE_SYSLOG_FACILITY_LOG_NEWS)
-	{ "NEWS",     LOG_NEWS     },
+	{ "news",     LOG_NEWS     },
 #endif
 #if defined(HAVE_SYSLOG_FACILITY_LOG_UUCP)
-	{ "UUCP",     LOG_UUCP     },
+	{ "uucp",     LOG_UUCP     },
 #endif
 #if defined(HAVE_SYSLOG_FACILITY_LOG_CRON)
-	{ "CRON",     LOG_CRON     },
+	{ "cron",     LOG_CRON     },
 #endif
 };
 
@@ -93,19 +93,32 @@
 	return -1;
 }
 
+const char *ast_syslog_facility_name(int facility)
+{
+	int index;
+
+	for (index = 0; index < ARRAY_LEN(facility_map); index++) {
+		if (facility_map[index].value == facility) {
+			return facility_map[index].name;
+		}
+	}
+
+	return NULL;
+}
+
 static const struct {
 	const char *name;
 	int value;
 } priority_map[] = {
-	{ "ALERT",   LOG_ALERT   },
-	{ "CRIT",    LOG_CRIT    },
-	{ "DEBUG",   LOG_DEBUG   },
-	{ "EMERG",   LOG_EMERG   },
-	{ "ERR",     LOG_ERR     },
-	{ "ERROR",   LOG_ERR     },
-	{ "INFO",    LOG_INFO    },
-	{ "NOTICE",  LOG_NOTICE  },
-	{ "WARNING", LOG_WARNING }
+	{ "alert",   LOG_ALERT   },
+	{ "crit",    LOG_CRIT    },
+	{ "debug",   LOG_DEBUG   },
+	{ "emerg",   LOG_EMERG   },
+	{ "err",     LOG_ERR     },
+	{ "error",   LOG_ERR     },
+	{ "info",    LOG_INFO    },
+	{ "notice",  LOG_NOTICE  },
+	{ "warning", LOG_WARNING },
 };
 
 int ast_syslog_priority(const char *priority)
@@ -119,6 +132,19 @@
 	}
 
 	return -1;
+}
+
+const char *ast_syslog_priority_name(int priority)
+{
+	int index;
+
+	for (index = 0; index < ARRAY_LEN(priority_map); index++) {
+		if (priority_map[index].value == priority) {
+			return priority_map[index].name;
+		}
+	}
+
+	return NULL;
 }
 
 static const int logger_level_to_syslog_map[] = {




More information about the asterisk-commits mailing list