[Asterisk-cvs] asterisk indications.c,1.9,1.10 logger.c,1.26,1.27

markster at lists.digium.com markster at lists.digium.com
Thu Feb 12 16:02:16 CST 2004


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv28379

Modified Files:
	indications.c logger.c 
Log Message:
Add queue logging and fix indications buglet


Index: indications.c
===================================================================
RCS file: /usr/cvsroot/asterisk/indications.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- indications.c	11 Feb 2004 05:14:19 -0000	1.9
+++ indications.c	12 Feb 2004 22:11:02 -0000	1.10
@@ -318,11 +318,11 @@
 		struct tone_zone_sound *tmp = zone->tones->next;
 		free((void*)zone->tones->name);
 		free((void*)zone->tones->data);
-		if (zone->ringcadance)
-			free((void*)zone->ringcadance);
 		free(zone->tones);
 		zone->tones = tmp;
 	}
+	if (zone->ringcadance)
+		free((void*)zone->ringcadance);
 	free(zone);
 }
 

Index: logger.c
===================================================================
RCS file: /usr/cvsroot/asterisk/logger.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- logger.c	3 Feb 2004 16:43:07 -0000	1.26
+++ logger.c	12 Feb 2004 22:11:02 -0000	1.27
@@ -220,6 +220,43 @@
 	ast_mutex_unlock(&loglock);
 }
 
+static FILE *qlog = NULL;
+static ast_mutex_t qloglock = AST_MUTEX_INITIALIZER;
+
+void ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt, ...)
+{
+	va_list ap;
+	ast_mutex_lock(&qloglock);
+	if (qlog) {
+		va_start(ap, fmt);
+		fprintf(qlog, "%ld|%s|%s|%s|%s|", (long)time(NULL), callid, queuename, agent, event);
+		vfprintf(qlog, fmt, ap);
+		fprintf(qlog, "\n");
+		va_end(ap);
+		fflush(qlog);
+	}
+	ast_mutex_unlock(&qloglock);
+}
+
+static void queue_log_init(void)
+{
+	char filename[256];
+	int reloaded = 0;
+	ast_mutex_lock(&qloglock);
+	if (qlog) {
+		reloaded = 1;
+		fclose(qlog);
+		qlog = NULL;
+	}
+	snprintf(filename, sizeof(filename), "%s/%s", (char *)ast_config_AST_LOG_DIR, "queue_log");
+	qlog = fopen(filename, "a");
+	ast_mutex_unlock(&qloglock);
+	if (reloaded) 
+		ast_queue_log("NONE", "NONE", "NONE", "CONFIGRELOAD", "");
+	else
+		ast_queue_log("NONE", "NONE", "NONE", "QUEUESTART", "");
+}
+
 int reload_logger(int rotate)
 {
 	char old[AST_CONFIG_MAX_PATH];
@@ -294,6 +331,7 @@
 		return 0;
 	} else 
 		ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno));
+	queue_log_init();
 	init_logger_chain();
 	return -1;
 }




More information about the svn-commits mailing list