Fixes to logging system.
authorMarkus Kauppila <markus.kauppila@gmail.com>
Mon, 18 Jul 2011 16:37:02 +0300
changeset 5770 795a59de1ad5
parent 5769 8f51d6a55006
child 5771 3f908b34b645
Fixes to logging system.
test/test-automation/logger.h
test/test-automation/plain_logger.c
test/test-automation/plain_logger.h
test/test-automation/runner.c
test/test-automation/testdummy/testdummy.c
test/test-automation/xml_logger.c
test/test-automation/xml_logger.h
--- a/test/test-automation/logger.h	Mon Jul 18 16:16:41 2011 +0300
+++ b/test/test-automation/logger.h	Mon Jul 18 16:37:02 2011 +0300
@@ -51,7 +51,7 @@
 typedef	void (*AssertSummaryFp)(int numAsserts, int numAssertsFailed,
 								int numAssertsPass, time_t eventTime);
 
-typedef	void (*LogFp)(const char *logMessage, time_t eventTime);
+typedef	void (*LogFp)(time_t eventTime, char *fmt, ...);
 
 
 /*! Function pointers to actual logging function implementations */
--- a/test/test-automation/plain_logger.c	Mon Jul 18 16:16:41 2011 +0300
+++ b/test/test-automation/plain_logger.c	Mon Jul 18 16:37:02 2011 +0300
@@ -136,8 +136,17 @@
 }
 
 void
-PlainLog(const char *logMessage, time_t eventTime)
+PlainLog(time_t eventTime, char *fmt, ...)
 {
+	// create the log message
+	va_list args;
+	char logMessage[1024];
+	memset(logMessage, 0, sizeof(logMessage));
+
+	va_start( args, fmt );
+	SDL_vsnprintf( logMessage, sizeof(logMessage), fmt, args );
+	va_end( args );
+
 	Output(indentLevel, "%s", logMessage);
 }
 
--- a/test/test-automation/plain_logger.h	Mon Jul 18 16:16:41 2011 +0300
+++ b/test/test-automation/plain_logger.h	Mon Jul 18 16:37:02 2011 +0300
@@ -113,6 +113,6 @@
  * \param logMessage Message to be logged
  * \param eventTime Timestamp for log message
  */
-void PlainLog(const char *logMessage, time_t eventTime);
+void PlainLog(time_t eventTime, char *fmt, ...);
 
 #endif
--- a/test/test-automation/runner.c	Mon Jul 18 16:16:41 2011 +0300
+++ b/test/test-automation/runner.c	Mon Jul 18 16:37:02 2011 +0300
@@ -557,6 +557,7 @@
 	return testEnvQuit;
 }
 
+
 /*!
  * Loads function that returns failed assert count in the current
  * test environment
@@ -643,7 +644,7 @@
 {
 	if(testItem->timeout > 0 || universal_timeout > 0) {
 		if(execute_inproc) {
-			Log("Test asked for timeout which is not supported.", time(0));
+			Log(time(0), "Test asked for timeout which is not supported.");
 		}
 		else {
 			SetTestTimeout(testItem->timeout, KillHungTestInChildProcess);
@@ -700,7 +701,6 @@
 }
 
 
-
 /*!
  * If using out-of-proc execution of tests. This function
  * will handle the return value of the child process
@@ -721,7 +721,7 @@
 	} else if(WIFSIGNALED(stat_lock)) {
 		int signal = WTERMSIG(stat_lock);
 		// \todo add this to logger (add signal number)
-		Log("FAILURE: test was aborted due to signal\n", time(0));
+		Log(time(0), "FAILURE: test was aborted due to  %d\n", signal);
 		returnValue = 1;
 	}
 
@@ -972,8 +972,8 @@
 	RunStarted(argc, argv, time(0), loggerData);
 
 	if(execute_inproc && universal_timeout_enabled) {
-		Log("Test timeout is not supported with in-proc execution.", time(0));
-		Log("Timeout will be disabled...", time(0));
+		Log(time(0), "Test timeout is not supported with in-proc execution.");
+		Log(time(0), "Timeout will be disabled...");
 
 		universal_timeout_enabled = 0;
 		universal_timeout = -1;
--- a/test/test-automation/testdummy/testdummy.c	Mon Jul 18 16:16:41 2011 +0300
+++ b/test/test-automation/testdummy/testdummy.c	Mon Jul 18 16:37:02 2011 +0300
@@ -95,7 +95,7 @@
 dummycase2(void *arg)
 {
 	char *msg = "eello";
-	//msg[0] = 'H';
+	msg[0] = 'H';
 	AssertTrue(1, "Assert message");
 }
 
--- a/test/test-automation/xml_logger.c	Mon Jul 18 16:16:41 2011 +0300
+++ b/test/test-automation/xml_logger.c	Mon Jul 18 16:37:02 2011 +0300
@@ -571,15 +571,25 @@
 }
 
 void
-XMLLog(const char *logMessage, time_t eventTime)
+XMLLog(time_t eventTime, char *fmt, ...)
 {
+	// create the log message
+	va_list args;
+	char logMessage[1024];
+	memset(logMessage, 0, sizeof(logMessage));
+
+	va_start( args, fmt );
+	SDL_vsnprintf( logMessage, sizeof(logMessage), fmt, args );
+	va_end( args );
+
 	char *output = XMLOpenElement(logElementName);
-	XMLOutputter(indentLevel++, NO, output);
+	XMLOutputter(indentLevel++, YES, output);
 
 	// log message
 	output = XMLOpenElement(messageElementName);
 	XMLOutputter(indentLevel++, NO, output);
 
+	// fix this here!
 	output = XMLAddContent(logMessage);
 	XMLOutputter(indentLevel, NO, output);
 
--- a/test/test-automation/xml_logger.h	Mon Jul 18 16:16:41 2011 +0300
+++ b/test/test-automation/xml_logger.h	Mon Jul 18 16:37:02 2011 +0300
@@ -109,6 +109,6 @@
  * \param logMessage Message to be logged
  * \param eventTime Timestamp for log message
  */
-void XMLLog(const char *logMessage, time_t eventTime);
+void XMLLog(time_t eventTime, char *fmt, ...);
 
 #endif