[asterisk-commits] seanbright: trunk r203188 - /trunk/main/logger.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jun 25 12:01:36 CDT 2009


Author: seanbright
Date: Thu Jun 25 12:01:32 2009
New Revision: 203188

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=203188
Log:
Pass a logmsg to ast_log_vsyslog instead of separate arguments.

Modified:
    trunk/main/logger.c

Modified: trunk/main/logger.c
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/main/logger.c?view=diff&rev=203188&r1=203187&r2=203188
==============================================================================
--- trunk/main/logger.c (original)
+++ trunk/main/logger.c Thu Jun 25 12:01:32 2009
@@ -840,29 +840,29 @@
 	return 0;
 }
 
-static void ast_log_vsyslog(int level, const char *file, int line, const char *function, const char *str, long pid)
+static void ast_log_vsyslog(struct logmsg *msg)
 {
 	char buf[BUFSIZ];
 
-	if (level >= SYSLOG_NLEVELS) {
+	if (msg->level >= SYSLOG_NLEVELS) {
 		/* we are locked here, so cannot ast_log() */
-		fprintf(stderr, "ast_log_vsyslog called with bogus level: %d\n", level);
-		return;
-	}
-
-	if (level == __LOG_VERBOSE) {
-		snprintf(buf, sizeof(buf), "VERBOSE[%ld]: %s", pid, str);
-		level = __LOG_DEBUG;
-	} else if (level == __LOG_DTMF) {
-		snprintf(buf, sizeof(buf), "DTMF[%ld]: %s", pid, str);
-		level = __LOG_DEBUG;
+		fprintf(stderr, "ast_log_vsyslog called with bogus level: %d\n", msg->level);
+		return;
+	}
+
+	if (msg->level == __LOG_VERBOSE) {
+		snprintf(buf, sizeof(buf), "VERBOSE[%ld]: %s", msg->process_id, msg->message);
+		msg->level = __LOG_DEBUG;
+	} else if (msg->level == __LOG_DTMF) {
+		snprintf(buf, sizeof(buf), "DTMF[%ld]: %s", msg->process_id, msg->message);
+		msg->level = __LOG_DEBUG;
 	} else {
 		snprintf(buf, sizeof(buf), "%s[%ld]: %s:%d in %s: %s",
-			 levels[level], pid, file, line, function, str);
+			 levels[msg->level], msg->process_id, msg->file, msg->line, msg->function, msg->message);
 	}
 
 	term_strip(buf, buf, strlen(buf) + 1);
-	syslog(syslog_level_map[level], "%s", buf);
+	syslog(syslog_level_map[msg->level], "%s", buf);
 }
 
 /*! \brief Print a normal log message to the channels */
@@ -880,7 +880,7 @@
 				continue;
 			/* Check syslog channels */
 			if (chan->type == LOGTYPE_SYSLOG && (chan->logmask & (1 << logmsg->level))) {
-				ast_log_vsyslog(logmsg->level, logmsg->file, logmsg->line, logmsg->function, logmsg->message, logmsg->process_id);
+				ast_log_vsyslog(logmsg);
 			/* Console channels */
 			} else if (chan->type == LOGTYPE_CONSOLE && (chan->logmask & (1 << logmsg->level))) {
 				char linestr[128];




More information about the asterisk-commits mailing list