Selaa lähdekoodia

Unit test: Print all messages to stdout

bel2125 7 vuotta sitten
vanhempi
commit
0a9254c6d1
1 muutettua tiedostoa jossa 21 lisäystä ja 0 poistoa
  1. 21 0
      test/public_server.c

+ 21 - 0
test/public_server.c

@@ -271,6 +271,18 @@ log_msg_func(const struct mg_connection *conn, const char *message)
 	ud[255] = 0;
 	mark_point();
 
+	printf("LOG_MSG_FUNC: %s\n", message);
+	mark_point();
+
+	return 1;
+}
+
+
+static int
+test_log_message(const struct mg_connection *conn, const char *message)
+{
+	printf("LOG_MESSAGE: %s\n", message);
+	mark_point();
 	return 1;
 }
 
@@ -281,6 +293,15 @@ test_mg_start(const struct mg_callbacks *callbacks,
               const char **configuration_options)
 {
 	struct mg_context *ctx;
+	struct mg_callbacks cb;
+
+	memset(cb, 0, sizeof(cb));
+	if (!callbacks) {
+		callbacks = &cb;
+	}
+	if (callbacks->log_message == NULL) {
+		callbacks.log_message = test_log_message;
+	}
 
 	mark_point();
 	test_sleep(SLEEP_BEFORE_MG_START);