commit e07c332cea468e03582ee6bd8192968b94b01b6c
parent 1717035dfbe31add394e414e4016cc3cee5f7fb4
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Mon, 15 Mar 2021 16:35:07 +0300
MHD_start_daemon(): warn if messages could be printed by wrong logger
If MHD_OPTION_EXTERNAL_LOGGER is specified and not used in the first
position then some messages could be printed by standard MHD logger
before this option is processed. Warn about this situation.
Diffstat:
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
@@ -1520,6 +1520,8 @@ enum MHD_OPTION
* a function of type #MHD_LogCallback and the second a pointer
* `void *` which will be passed as the first argument to the log
* callback.
+ * Should be specified as the first option, otherwise some messages
+ * may be printed by standard MHD logger during daemon startup.
*
* Note that MHD will not generate any log messages
* if it was compiled without the "--enable-messages"
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
@@ -5741,6 +5741,12 @@ parse_options_va (struct MHD_Daemon *daemon,
VfprintfFunctionPointerType);
daemon->custom_error_log_cls = va_arg (ap,
void *);
+ if (1 != daemon->num_opts)
+ MHD_DLOG (daemon,
+ _ ("MHD_OPTION_EXTERNAL_LOGGER is not the first option "
+ "specified for the daemon. Some messages may be "
+ "printed by the standard MHD logger.\n"));
+
#else
va_arg (ap,
VfprintfFunctionPointerType);