[asterisk-commits] mmichelson: trunk r94782 - in /trunk: ./ configs/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Dec 26 09:58:17 CST 2007


Author: mmichelson
Date: Wed Dec 26 09:58:17 2007
New Revision: 94782

URL: http://svn.digium.com/view/asterisk?view=rev&rev=94782
Log:
Adding support for storing the queue log entries in a realtime backend.

(closes issue #11625, reported and patched by sergee)

Thank you very much to sergee for adding this new feature!


Modified:
    trunk/CHANGES
    trunk/configs/extconfig.conf.sample
    trunk/main/logger.c

Modified: trunk/CHANGES
URL: http://svn.digium.com/view/asterisk/trunk/CHANGES?view=diff&rev=94782&r1=94781&r2=94782
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Wed Dec 26 09:58:17 2007
@@ -384,6 +384,7 @@
      command to be run after rotation.  This is primarily useful with
      rotatestrategry=rotate, to allow a limit on the number of logfiles kept
      and to ensure that the oldest log file gets deleted.
+  * Added realtime support for the queue log
 
 Miscellaneous 
 -------------

Modified: trunk/configs/extconfig.conf.sample
URL: http://svn.digium.com/view/asterisk/trunk/configs/extconfig.conf.sample?view=diff&rev=94782&r1=94781&r2=94782
==============================================================================
--- trunk/configs/extconfig.conf.sample (original)
+++ trunk/configs/extconfig.conf.sample Wed Dec 26 09:58:17 2007
@@ -59,4 +59,5 @@
 ;queues => odbc,asterisk
 ;queue_members => odbc,asterisk
 ;musiconhold => mysql,asterisk
+;queue_log => mysql,aasterisk
 

Modified: trunk/main/logger.c
URL: http://svn.digium.com/view/asterisk/trunk/main/logger.c?view=diff&rev=94782&r1=94781&r2=94782
==============================================================================
--- trunk/main/logger.c (original)
+++ trunk/main/logger.c Wed Dec 26 09:58:17 2007
@@ -418,18 +418,34 @@
 	va_list ap;
 	char qlog_msg[8192];
 	int qlog_len;
-	if (qlog) {
+	char time_str[16];
+
+	if (ast_check_realtime("queue_log")) {
 		va_start(ap, fmt);
-		qlog_len = snprintf(qlog_msg, sizeof(qlog_msg), "%ld|%s|%s|%s|%s|", (long)time(NULL), callid, queuename, agent, event);
-		vsnprintf(qlog_msg + qlog_len, sizeof(qlog_msg) - qlog_len, fmt, ap);
+		vsnprintf(qlog_msg, sizeof(qlog_msg), fmt, ap);
 		va_end(ap);
-	}
-	AST_RWLIST_RDLOCK(&logchannels);
-	if (qlog) {
-		fprintf(qlog, "%s\n", qlog_msg);
-		fflush(qlog);
-	}
-	AST_RWLIST_UNLOCK(&logchannels);
+		snprintf(time_str, sizeof(time_str), "%ld", (long)time(NULL));
+		ast_store_realtime("queue_log", "time", time_str, 
+						"callid", callid, 
+						"queuename", queuename, 
+						"agent", agent, 
+						"event", event,
+						"data", qlog_msg,
+						NULL);
+	} else {
+		if (qlog) {
+			va_start(ap, fmt);
+			qlog_len = snprintf(qlog_msg, sizeof(qlog_msg), "%ld|%s|%s|%s|%s|", (long)time(NULL), callid, queuename, agent, event);
+			vsnprintf(qlog_msg + qlog_len, sizeof(qlog_msg) - qlog_len, fmt, ap);
+			va_end(ap);
+		}
+		AST_RWLIST_RDLOCK(&logchannels);
+		if (qlog) {
+			fprintf(qlog, "%s\n", qlog_msg);
+			fflush(qlog);
+		}
+		AST_RWLIST_UNLOCK(&logchannels);
+	}
 }
 
 static int rotate_file(const char *filename)




More information about the asterisk-commits mailing list