Ver código fonte

add log_access() callback

log_message() is used for critical messages, log_access() used for
access logging.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
Yehuda Sadeh 11 anos atrás
pai
commit
bab2a3f627
2 arquivos alterados com 6 adições e 2 exclusões
  1. 4 0
      include/civetweb.h
  2. 2 2
      src/civetweb.c

+ 4 - 0
include/civetweb.h

@@ -104,6 +104,10 @@ struct mg_callbacks {
        non-zero, civetweb does not log anything. */
     int  (*log_message)(const struct mg_connection *, const char *message);
 
+    /* Called when civetweb is about to log access. If callback returns
+       non-zero, civetweb does not log anything. */
+    int  (*log_access)(const struct mg_connection *, const char *message);
+
     /* Called when civetweb initializes SSL library.
        Parameters:
          user_data: parameter user_data passed when starting the server.

+ 2 - 2
src/civetweb.c

@@ -6608,8 +6608,8 @@ static void log_access(const struct mg_connection *conn)
             conn->status_code, conn->num_bytes_sent,
 	    referer, user_agent);
 
-    if (conn->ctx->callbacks.log_message) {
-        conn->ctx->callbacks.log_message(conn, buf);
+    if (conn->ctx->callbacks.log_access) {
+        conn->ctx->callbacks.log_access(conn, buf);
     }
 
     if (fp) {