Ver código fonte

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.
Evgeny Grin (Karlson2k) 4 anos atrás
pai
commit
e07c332cea
2 arquivos alterados com 8 adições e 0 exclusões
  1. 2 0
      src/include/microhttpd.h
  2. 6 0
      src/microhttpd/daemon.c

+ 2 - 0
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"

+ 6 - 0
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);