From 55948cd431e11b684a616c5d02e4931556144a9d Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Fri, 10 Jun 2022 12:33:30 +0100 Subject: [PATCH] Allow to set log level --- examples/http-client/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/http-client/main.c b/examples/http-client/main.c index 2ff3ca8a..f4deebed 100644 --- a/examples/http-client/main.c +++ b/examples/http-client/main.c @@ -59,10 +59,13 @@ static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) { } int main(int argc, char *argv[]) { + const char *log_level = getenv("LOG_LEVEL"); // Allow user to set log level + if (log_level == NULL) log_level = "4"; // Default is verbose + struct mg_mgr mgr; // Event manager bool done = false; // Event handler flips it to true if (argc > 1) s_url = argv[1]; // Use URL provided in the command line - mg_log_set("4"); // Set to 0 to disable debug + mg_log_set(log_level); // Set to 0 to disable debug mg_mgr_init(&mgr); // Initialise event manager mg_http_connect(&mgr, s_url, fn, &done); // Create client connection while (!done) mg_mgr_poll(&mgr, 50); // Infinite event loop