httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r951897 - in /httpd/httpd/trunk: include/http_config.h include/http_core.h include/http_log.h include/httpd.h modules/generators/mod_cgid.c server/config.c server/core.c server/log.c server/request.c server/util_debug.c
Date Sun, 06 Jun 2010 17:04:40 GMT
Author: sf
Date: Sun Jun  6 17:04:40 2010
New Revision: 951897

URL: http://svn.apache.org/viewvc?rev=951897&view=rev
Log:
- Add loglevels to request_rec and conn_rec
- Introduce per-directory loglevel configuration

Modified:
    httpd/httpd/trunk/include/http_config.h
    httpd/httpd/trunk/include/http_core.h
    httpd/httpd/trunk/include/http_log.h
    httpd/httpd/trunk/include/httpd.h
    httpd/httpd/trunk/modules/generators/mod_cgid.c
    httpd/httpd/trunk/server/config.c
    httpd/httpd/trunk/server/core.c
    httpd/httpd/trunk/server/log.c
    httpd/httpd/trunk/server/request.c
    httpd/httpd/trunk/server/util_debug.c

Modified: httpd/httpd/trunk/include/http_config.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/http_config.h?rev=951897&r1=951896&r2=951897&view=diff
==============================================================================
--- httpd/httpd/trunk/include/http_config.h (original)
+++ httpd/httpd/trunk/include/http_config.h Sun Jun  6 17:04:40 2010
@@ -487,7 +487,23 @@ AP_DECLARE(void) ap_set_module_config(ap
  * @param index The module_index of the module to get the loglevel for.
  * @return The module-specific loglevel
  */
-AP_DECLARE(int) ap_get_module_loglevel(const server_rec *s, int index);
+AP_DECLARE(int) ap_get_server_module_loglevel(const server_rec *s, int index);
+
+/**
+ * Generic accessor for modules the module-specific loglevel
+ * @param c The connection from which to get the loglevel.
+ * @param index The module_index of the module to get the loglevel for.
+ * @return The module-specific loglevel
+ */
+AP_DECLARE(int) ap_get_conn_module_loglevel(const conn_rec *c, int index);
+
+/**
+ * Generic accessor for modules to get the module-specific loglevel
+ * @param r The request from which to get the loglevel.
+ * @param index The module_index of the module to get the loglevel for.
+ * @return The module-specific loglevel
+ */
+AP_DECLARE(int) ap_get_request_module_loglevel(const request_rec *r, int index);
 
 /**
  * Accessor to set module-specific loglevel
@@ -497,27 +513,42 @@ AP_DECLARE(int) ap_get_module_loglevel(c
  * @param level The new log level
  * @return The module-specific loglevel
  */
-AP_DECLARE(void) ap_set_module_loglevel(apr_pool_t *p, server_rec *s,
+AP_DECLARE(void) ap_set_module_loglevel(apr_pool_t *p, struct ap_logconf *l,
                                         int index, int level);
 
 #if !defined(AP_DEBUG)
 
-#define ap_get_module_loglevel(s,i)	        \
-    (i < 0 || (s)->module_loglevels == NULL || (((s)->module_loglevels)[i]) <
0 ?   \
-     (s)->loglevel :                            \
-     ((s)->module_loglevels)[i])
+#define ap_get_conn_logconf(c)                     \
+    ((c)->log             ? (c)->log             : \
+     &(c)->base_server->log)
+
+#define ap_get_request_logconf(r)                  \
+    ((r)->log             ? (r)->log             : \
+     (r)->connection->log ? (r)->connection->log : \
+     &(r)->server->log)
+
+#define ap_get_module_loglevel(l,i)                                     \
+    (((i) < 0 || (l)->module_levels == NULL || (l)->module_levels[i] < 0) ? 
\
+     (l)->level :                                                         \
+     (l)->module_levels[i])
+
+#define ap_get_server_module_loglevel(s,i)  \
+    (ap_get_module_loglevel(&(s)->log,i))
+
+#define ap_get_conn_module_loglevel(c,i)  \
+    (ap_get_module_loglevel(ap_get_conn_logconf(c),i))
+
+#define ap_get_request_module_loglevel(r,i)  \
+    (ap_get_module_loglevel(ap_get_request_logconf(r),i))
 
 #endif /* AP_DEBUG */
 
 /**
- * Reset all module-specific loglevels to server default
- * @param p A pool
- * @param s The server for which to set the loglevel.
- * @param index The module_index of the module to set the loglevel for.
- * @param level The new log level
- * @return The module-specific loglevel
+ * Set all module-specific loglevels to val
+ * @param l The log config for which to set the loglevels.
+ * @param val the value to set all loglevels to
  */
-AP_DECLARE(void) ap_reset_module_loglevels(server_rec *s);
+AP_DECLARE(void) ap_reset_module_loglevels(struct ap_logconf *l, int val);
 
 /**
  * Generic command handling function for strings
@@ -910,6 +941,24 @@ AP_CORE_DECLARE(ap_conf_vector_t*) ap_me
                                            ap_conf_vector_t *base,
                                            ap_conf_vector_t *new_conf);
 
+/**
+ * Allocate new ap_logconf and make (deep) copy of old ap_logconf
+ * @param p The pool to alloc from
+ * @param old The ap_logconf to copy (may be NULL)
+ * @return The new ap_logconf struct
+ */
+AP_DECLARE(struct ap_logconf *) ap_new_log_config(apr_pool_t *p,
+                                                  const struct ap_logconf *old);
+
+/**
+ * Merge old ap_logconf into new ap_logconf.
+ * old and new must have the same life time.
+ * @param old The ap_logconf to merge from
+ * @param new The ap_logconf to merge into
+ */
+AP_DECLARE(void) ap_merge_log_config(const struct ap_logconf *old,
+                                     struct ap_logconf *new);
+
 /* For http_connection.c... */
 /**
  * Setup the config vector for a connection_rec

Modified: httpd/httpd/trunk/include/http_core.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/http_core.h?rev=951897&r1=951896&r2=951897&view=diff
==============================================================================
--- httpd/httpd/trunk/include/http_core.h (original)
+++ httpd/httpd/trunk/include/http_core.h Sun Jun  6 17:04:40 2010
@@ -536,6 +536,9 @@ typedef struct {
     unsigned use_canonical_phys_port : 2;
 
     ap_parse_node_t *condition;   /* Conditionally merge <If> sections */
+
+    /** per-dir log config */
+    struct ap_logconf *log;
 } core_dir_config;
 
 /* Per-server core configuration */

Modified: httpd/httpd/trunk/include/http_log.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/http_log.h?rev=951897&r1=951896&r2=951897&view=diff
==============================================================================
--- httpd/httpd/trunk/include/http_log.h (original)
+++ httpd/httpd/trunk/include/http_log.h Sun Jun  6 17:04:40 2010
@@ -130,19 +130,42 @@ static int * const aplog_module_index;
 #define APLOG_MODULE_IS_LEVEL(s,module_index,level)              \
           ( (((level)&APLOG_LEVELMASK) <= APLOG_NOTICE) ||       \
             (s == NULL) ||                                       \
-            (ap_get_module_loglevel(s, module_index)             \
+            (ap_get_server_module_loglevel(s, module_index)      \
+             >= ((level)&APLOG_LEVELMASK) ) )
+#define APLOG_C_MODULE_IS_LEVEL(c,module_index,level)            \
+          ( (((level)&APLOG_LEVELMASK) <= APLOG_NOTICE) ||       \
+            (ap_get_conn_module_loglevel(c, module_index)        \
+             >= ((level)&APLOG_LEVELMASK) ) )
+#define APLOG_R_MODULE_IS_LEVEL(r,module_index,level)            \
+          ( (((level)&APLOG_LEVELMASK) <= APLOG_NOTICE) ||       \
+            (ap_get_request_module_loglevel(r, module_index)     \
              >= ((level)&APLOG_LEVELMASK) ) )
 #else
 #define APLOG_MODULE_IS_LEVEL(s,module_index,level)              \
         ( (((level)&APLOG_LEVELMASK) <= APLOG_MAX_LOGLEVEL) &&   \
           ( (((level)&APLOG_LEVELMASK) <= APLOG_NOTICE) ||       \
             (s == NULL) ||                                       \
-            (ap_get_module_loglevel(s, module_index)             \
+            (ap_get_server_module_loglevel(s, module_index)      \
+             >= ((level)&APLOG_LEVELMASK) ) ) )
+#define APLOG_C_MODULE_IS_LEVEL(c,module_index,level)            \
+        ( (((level)&APLOG_LEVELMASK) <= APLOG_MAX_LOGLEVEL) &&   \
+          ( (((level)&APLOG_LEVELMASK) <= APLOG_NOTICE) ||       \
+            (ap_get_conn_module_loglevel(c, module_index)        \
+             >= ((level)&APLOG_LEVELMASK) ) ) )
+#define APLOG_R_MODULE_IS_LEVEL(r,module_index,level)            \
+        ( (((level)&APLOG_LEVELMASK) <= APLOG_MAX_LOGLEVEL) &&   \
+          ( (((level)&APLOG_LEVELMASK) <= APLOG_NOTICE) ||       \
+            (ap_get_request_module_loglevel(r, module_index)     \
              >= ((level)&APLOG_LEVELMASK) ) ) )
 #endif
 
 #define APLOG_IS_LEVEL(s,level)     \
     APLOG_MODULE_IS_LEVEL(s,APLOG_MODULE_INDEX,level)
+#define APLOG_C_IS_LEVEL(c,level)   \
+    APLOG_C_MODULE_IS_LEVEL(c,APLOG_MODULE_INDEX,level)
+#define APLOG_R_IS_LEVEL(r,level)   \
+    APLOG_R_MODULE_IS_LEVEL(r,APLOG_MODULE_INDEX,level)
+
 
 #define APLOGinfo(s)                APLOG_IS_LEVEL(s,APLOG_INFO)
 #define APLOGdebug(s)               APLOG_IS_LEVEL(s,APLOG_DEBUG)
@@ -155,7 +178,6 @@ static int * const aplog_module_index;
 #define APLOGtrace7(s)              APLOG_IS_LEVEL(s,APLOG_TRACE7)
 #define APLOGtrace8(s)              APLOG_IS_LEVEL(s,APLOG_TRACE8)
 
-#define APLOG_R_IS_LEVEL(r,level)   APLOG_IS_LEVEL(r->server,level)
 #define APLOGrinfo(r)               APLOG_R_IS_LEVEL(r,APLOG_INFO)
 #define APLOGrdebug(r)              APLOG_R_IS_LEVEL(r,APLOG_DEBUG)
 #define APLOGrtrace1(r)             APLOG_R_IS_LEVEL(r,APLOG_TRACE1)
@@ -167,7 +189,6 @@ static int * const aplog_module_index;
 #define APLOGrtrace7(r)             APLOG_R_IS_LEVEL(r,APLOG_TRACE7)
 #define APLOGrtrace8(r)             APLOG_R_IS_LEVEL(r,APLOG_TRACE8)
 
-#define APLOG_C_IS_LEVEL(c,level)   APLOG_IS_LEVEL(c->base_server,level)
 #define APLOGcinfo(c)               APLOG_C_IS_LEVEL(c,APLOG_INFO)
 #define APLOGcdebug(c)              APLOG_C_IS_LEVEL(c,APLOG_DEBUG)
 #define APLOGctrace1(r)             APLOG_C_IS_LEVEL(c,APLOG_TRACE1)

Modified: httpd/httpd/trunk/include/httpd.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/httpd.h?rev=951897&r1=951896&r2=951897&view=diff
==============================================================================
--- httpd/httpd/trunk/include/httpd.h (original)
+++ httpd/httpd/trunk/include/httpd.h Sun Jun  6 17:04:40 2010
@@ -977,6 +977,11 @@ struct request_rec {
      *  request */
     struct ap_filter_t *proto_input_filters;
 
+    /** Optional request log level configuration. Will usually point
+     *  to a server or per_dir config, i.e. must be copied before
+     *  modifying */
+    const struct ap_logconf *log;
+ 
     /** A flag to determine if the eos bucket has been sent yet */
     int eos_sent;
 
@@ -1094,6 +1099,10 @@ struct conn_rec {
      */
     int clogging_input_filters;
     
+    /** Optional connection log level configuration. May point to a server or
+     *  per_dir config, i.e. must be copied before modifying */
+    const struct ap_logconf *log;
+
     /** This points to the current thread being used to process this request,
      * over the lifetime of a request, the value may change. Users of the connection
      * record should not rely upon it staying the same between calls that invole
@@ -1161,6 +1170,13 @@ struct server_addr_rec {
     char *virthost;
 };
 
+struct ap_logconf {
+    /** The per-module log levels */
+    int *module_levels;
+
+    /** The log level for this server */
+    int level;
+};
 /** 
  * @brief A structure to store information for each virtual server 
  */
@@ -1186,14 +1202,12 @@ struct server_rec {
 
     /* Log files --- note that transfer log is now in the modules... */
 
-    /** The per-module log levels */
-    int *module_loglevels;
     /** The name of the error log */
     char *error_fname;
     /** A file descriptor that references the error log */
     apr_file_t *error_log;
-    /** The log level for this server */
-    int loglevel;
+    /** The log level configuration */
+    struct ap_logconf log;
 
     /* Module-specific configuration for server, and defaults... */
 

Modified: httpd/httpd/trunk/modules/generators/mod_cgid.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/generators/mod_cgid.c?rev=951897&r1=951896&r2=951897&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/generators/mod_cgid.c (original)
+++ httpd/httpd/trunk/modules/generators/mod_cgid.c Sun Jun  6 17:04:40 2010
@@ -394,7 +394,7 @@ static apr_status_t get_req(int fd, requ
     if (stat != APR_SUCCESS) {
         return stat;
     }
-    r->server->loglevel = req->loglevel;
+    r->server->log.level = req->loglevel;
     if (req->req_type == GETPID_REQ) {
         /* no more data sent for this request */
         return APR_SUCCESS;
@@ -503,7 +503,7 @@ static apr_status_t send_req(int fd, req
     req.argv0_len = strlen(argv0);
     req.uri_len = strlen(r->uri);
     req.args_len = r->args ? strlen(r->args) : 0;
-    req.loglevel = r->server->loglevel;
+    req.loglevel = r->server->log.level;
 
     /* Write the request header */
     if (req.args_len) {

Modified: httpd/httpd/trunk/server/config.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/config.c?rev=951897&r1=951896&r2=951897&view=diff
==============================================================================
--- httpd/httpd/trunk/server/config.c (original)
+++ httpd/httpd/trunk/server/config.c Sun Jun  6 17:04:40 2010
@@ -50,6 +50,7 @@
 #include "http_vhost.h"
 #include "util_cfgtree.h"
 
+#define APLOG_UNSET   (APLOG_NO_MODULE - 1)
 APLOG_USE_MODULE(core);
 
 AP_DECLARE_DATA const char *ap_server_argv0 = NULL;
@@ -1355,24 +1356,30 @@ AP_DECLARE_NONSTD(const char *) ap_set_d
     return cmd->cmd->errmsg;
 }
 
-AP_DECLARE(void) ap_reset_module_loglevels(server_rec *s)
+AP_DECLARE(void) ap_reset_module_loglevels(struct ap_logconf *l, int val)
 {
-    if (s->module_loglevels) {
-        memset(s->module_loglevels, -1,
-               sizeof(int) * (total_modules + DYNAMIC_MODULE_LIMIT));
+    if (l->module_levels) {
+        int i;
+        for (i = 0; i < total_modules + DYNAMIC_MODULE_LIMIT; i++)
+            l->module_levels[i] = val;
     }
 }
 
-AP_DECLARE(void) ap_set_module_loglevel(apr_pool_t *pool, server_rec *s,
+AP_DECLARE(void) ap_set_module_loglevel(apr_pool_t *pool, struct ap_logconf *l,
                                         int index, int level)
 {
-    if (!s->module_loglevels) {
-        s->module_loglevels = apr_palloc(pool,
+    if (!l->module_levels) {
+        l->module_levels = apr_palloc(pool,
                      sizeof(int) * (total_modules + DYNAMIC_MODULE_LIMIT));
-        ap_reset_module_loglevels(s);
+        if (l->level == APLOG_UNSET) {
+                ap_reset_module_loglevels(l, APLOG_UNSET);
+        }
+        else {
+                ap_reset_module_loglevels(l, APLOG_NO_MODULE);
+        }
     }
 
-    s->module_loglevels[index] = level;
+    l->module_levels[index] = level;
 }
 
 /*****************************************************************
@@ -1981,8 +1988,8 @@ AP_CORE_DECLARE(const char *) ap_init_vi
     s->keep_alive = -1;
     s->keep_alive_max = -1;
     s->error_log = main_server->error_log;
-    s->loglevel = main_server->loglevel;
-    s->module_loglevels = NULL;
+    s->log.level = main_server->log.level;
+    s->log.module_levels = NULL;
     /* useful default, otherwise we get a port of 0 on redirects */
     s->port = main_server->port;
     s->next = NULL;
@@ -2003,10 +2010,53 @@ AP_CORE_DECLARE(const char *) ap_init_vi
     return ap_parse_vhost_addrs(p, hostname, s);
 }
 
+AP_DECLARE(struct ap_logconf *) ap_new_log_config(apr_pool_t *p,
+                                                  const struct ap_logconf *old)
+{
+    struct ap_logconf *l = apr_pcalloc(p, sizeof(struct ap_logconf));
+    if (old) {
+        l->level = old->level;
+        if (old->module_levels) {
+            l->module_levels =
+                apr_pmemdup(p, old->module_levels,
+                            sizeof(int) * (total_modules + DYNAMIC_MODULE_LIMIT));
+        }
+    }
+    else {
+        l->level = APLOG_UNSET;
+    }
+    return l;
+}
+
+AP_DECLARE(void) ap_merge_log_config(const struct ap_logconf *old,
+                                     struct ap_logconf *new)
+{
+    if (new->level != APLOG_UNSET) {
+        /* Setting the main loglevel resets all per-module log levels.
+         * I.e. if new->level has been set, we must ignore old->module_levels.
+         */
+        return;
+    }
+
+    new->level = old->level;
+    if (new->module_levels == NULL) {
+        new->module_levels = old->module_levels;
+    }
+    else if (old->module_levels != NULL) {
+        int i;
+        for (i = 0; i < total_modules + DYNAMIC_MODULE_LIMIT; i++) {
+            if (new->module_levels[i] == APLOG_UNSET)
+                new->module_levels[i] = old->module_levels[i];
+        }
+    }
+}
 
 AP_DECLARE(void) ap_fixup_virtual_hosts(apr_pool_t *p, server_rec *main_server)
 {
     server_rec *virt;
+    core_dir_config *dconf = ap_get_module_config(main_server->lookup_defaults,
+                                                  &core_module);
+    dconf->log = &main_server->log;
 
     for (virt = main_server->next; virt; virt = virt->next) {
         merge_server_configs(p, main_server->module_config,
@@ -2031,17 +2081,10 @@ AP_DECLARE(void) ap_fixup_virtual_hosts(
         if (virt->keep_alive_max == -1)
             virt->keep_alive_max = main_server->keep_alive_max;
 
-        if (virt->module_loglevels == NULL) {
-            virt->module_loglevels = main_server->module_loglevels;
-        }
-        else if (main_server->module_loglevels != NULL) {
-            int i;
-            for (i = 0; i < total_modules + DYNAMIC_MODULE_LIMIT; i++) {
-                if (virt->module_loglevels[i] < 0)
-                    virt->module_loglevels[i] =
-                        main_server->module_loglevels[i];
-            }
-        }
+        ap_merge_log_config(&main_server->log, &virt->log);
+
+        dconf = ap_get_module_config(virt->lookup_defaults, &core_module);
+        dconf->log = &virt->log;
 
         /* XXX: this is really something that should be dealt with by a
          * post-config api phase
@@ -2075,8 +2118,8 @@ static server_rec *init_server_config(pr
     s->server_hostname = NULL;
     s->server_scheme = NULL;
     s->error_fname = DEFAULT_ERRORLOG;
-    s->loglevel = DEFAULT_LOGLEVEL;
-    s->module_loglevels = NULL;
+    s->log.level = DEFAULT_LOGLEVEL;
+    s->log.module_levels = NULL;
     s->limit_req_line = DEFAULT_LIMIT_REQUEST_LINE;
     s->limit_req_fieldsize = DEFAULT_LIMIT_REQUEST_FIELDSIZE;
     s->limit_req_fields = DEFAULT_LIMIT_REQUEST_FIELDS;

Modified: httpd/httpd/trunk/server/core.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/core.c?rev=951897&r1=951896&r2=951897&view=diff
==============================================================================
--- httpd/httpd/trunk/server/core.c (original)
+++ httpd/httpd/trunk/server/core.c Sun Jun  6 17:04:40 2010
@@ -419,6 +419,16 @@ static void *merge_core_dir_configs(apr_
 
     conf->allow_encoded_slashes = new->allow_encoded_slashes;
 
+    if (new->log) {
+        if (!conf->log) {
+            conf->log = new->log;
+        }
+        else {
+            conf->log = ap_new_log_config(a, new->log);
+            ap_merge_log_config(base->log, conf->log);
+        }
+    }
+
     return (void*)conf;
 }
 
@@ -2625,17 +2635,33 @@ static const char *include_config (cmd_p
     return NULL;
 }
 
-static const char *set_loglevel(cmd_parms *cmd, void *dummy, const char *arg_)
+static const char *set_loglevel(cmd_parms *cmd, void *config_, const char *arg_)
 {
     char *level_str;
     int level;
     module *module;
     char *arg = apr_pstrdup(cmd->temp_pool, arg_);
+    struct ap_logconf *log;
+    const char *err;
 
+    /* XXX: what check is necessary here? */
+#if 0
     const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE);
     if (err != NULL) {
         return err;
     }
+#endif
+
+    if (cmd->path) {
+        core_dir_config *dconf = config_;
+        if (!dconf->log) {
+            dconf->log = ap_new_log_config(cmd->pool, NULL);
+        }
+        log = dconf->log;
+    }
+    else {
+        log = &cmd->server->log;
+    }
 
     if (arg == NULL)
         return "LogLevel requires level keyword or module loglevel specifier";
@@ -2643,10 +2669,10 @@ static const char *set_loglevel(cmd_parm
     level_str = ap_strchr(arg, ':');
 
     if (level_str == NULL) {
-        err = ap_parse_log_level(arg, &cmd->server->loglevel);
+        err = ap_parse_log_level(arg, &log->level);
         if (err != NULL)
             return err;
-        ap_reset_module_loglevels(cmd->server);
+        ap_reset_module_loglevels(log, APLOG_NO_MODULE);
         ap_log_error(APLOG_MARK, APLOG_TRACE3, 0, cmd->server,
                      "Setting LogLevel for all modules to %s", arg);
         return NULL;
@@ -2666,15 +2692,14 @@ static const char *set_loglevel(cmd_parm
         char *name = apr_psprintf(cmd->temp_pool, "%s_module", arg);
         ap_log_error(APLOG_MARK, APLOG_TRACE6, 0, cmd->server,
                      "Cannot find module '%s', trying '%s'", arg, name);
-	module = find_module(cmd->server, name);
+        module = find_module(cmd->server, name);
     }
 
     if (module == NULL) {
         return apr_psprintf(cmd->temp_pool, "Cannot find module %s", arg);
     }
 
-    ap_set_module_loglevel(cmd->pool, cmd->server, module->module_index,
-                           level);
+    ap_set_module_loglevel(cmd->pool, log, module->module_index, level);
     ap_log_error(APLOG_MARK, APLOG_TRACE3, 0, cmd->server,
                  "Setting LogLevel for module %s to %s", module->name,
                  level_str);
@@ -3355,7 +3380,7 @@ AP_INIT_TAKE1("IncludeOptional", include
   (RSRC_CONF | ACCESS_CONF | EXEC_ON_READ),
   "Name or pattern of the config file(s) to be included; ignored if the file "
   "does not exist or the pattern does not match any files"),
-AP_INIT_ITERATE("LogLevel", set_loglevel, NULL, RSRC_CONF,
+AP_INIT_ITERATE("LogLevel", set_loglevel, NULL, RSRC_CONF|ACCESS_CONF,
   "Level of verbosity in error logging"),
 AP_INIT_TAKE1("NameVirtualHost", ap_set_name_virtual_host, NULL, RSRC_CONF,
   "A numeric IP address:port, or the name of a host"),

Modified: httpd/httpd/trunk/server/log.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/log.c?rev=951897&r1=951896&r2=951897&view=diff
==============================================================================
--- httpd/httpd/trunk/server/log.c (original)
+++ httpd/httpd/trunk/server/log.c Sun Jun  6 17:04:40 2010
@@ -580,25 +580,30 @@ static void log_error_core(const char *f
 
         logf = stderr_log;
     }
-    else if (s->error_log) {
-        /*
-         * If we are doing normal logging, don't log messages that are
-         * above the module's log level unless it is a startup/shutdown notice
-         */
-        if ((level_and_mask != APLOG_NOTICE)
-            && (level_and_mask > ap_get_module_loglevel(s, module_index))) {
-            return;
-        }
-
-        logf = s->error_log;
-    }
     else {
-        /*
-         * If we are doing syslog logging, don't log messages that are
-         * above the module's log level (including a startup/shutdown notice)
-         */
-        if (level_and_mask > ap_get_module_loglevel(s, module_index)) {
-            return;
+        int configured_level = r ? ap_get_request_module_loglevel(r, module_index) :
+                               c ? ap_get_conn_module_loglevel(c, module_index) :
+                                   ap_get_server_module_loglevel(s, module_index);
+        if (s->error_log) {
+            /*
+             * If we are doing normal logging, don't log messages that are
+             * above the module's log level unless it is a startup/shutdown notice
+             */
+            if ((level_and_mask != APLOG_NOTICE)
+                && (level_and_mask > configured_level)) {
+                return;
+            }
+
+            logf = s->error_log;
+        }
+        else {
+            /*
+             * If we are doing syslog logging, don't log messages that are
+             * above the module's log level (including a startup/shutdown notice)
+             */
+            if (level_and_mask > configured_level) {
+                return;
+            }
         }
     }
 

Modified: httpd/httpd/trunk/server/request.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/request.c?rev=951897&r1=951896&r2=951897&view=diff
==============================================================================
--- httpd/httpd/trunk/server/request.c (original)
+++ httpd/httpd/trunk/server/request.c Sun Jun  6 17:04:40 2010
@@ -112,10 +112,10 @@ AP_DECLARE(int) ap_process_request_inter
 {
     int file_req = (r->main && r->filename);
     int access_status;
+    core_dir_config *d;
 
     /* Ignore embedded %2F's in path for proxy requests */
     if (!r->proxyreq && r->parsed_uri.path) {
-        core_dir_config *d;
         d = ap_get_module_config(r->per_dir_config, &core_module);
         if (d->allow_encoded_slashes) {
             access_status = ap_unescape_url_keep2f(r->parsed_uri.path);
@@ -147,6 +147,11 @@ AP_DECLARE(int) ap_process_request_inter
             return access_status;
         }
 
+        d = ap_get_module_config(r->per_dir_config, &core_module);
+        if (d->log) {
+            r->log = d->log;
+        }
+
         if ((access_status = ap_run_translate_name(r))) {
             return decl_die(access_status, "translate", r);
         }
@@ -167,6 +172,11 @@ AP_DECLARE(int) ap_process_request_inter
         return access_status;
     }
 
+    d = ap_get_module_config(r->per_dir_config, &core_module);
+    if (d->log) {
+        r->log = d->log;
+    }
+
     /* Only on the main request! */
     if (r->main == NULL) {
         if ((access_status = ap_run_header_parser(r))) {
@@ -1589,6 +1599,7 @@ static request_rec *make_sub_request(con
     rnew->request_time   = r->request_time;
     rnew->connection     = r->connection;
     rnew->server         = r->server;
+    rnew->log            = r->log;
 
     rnew->request_config = ap_create_request_config(rnew->pool);
 

Modified: httpd/httpd/trunk/server/util_debug.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util_debug.c?rev=951897&r1=951896&r2=951897&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util_debug.c (original)
+++ httpd/httpd/trunk/server/util_debug.c Sun Jun  6 17:04:40 2010
@@ -106,20 +106,56 @@ AP_DECLARE(void *) ap_get_module_config(
     return ((void **)cv)[m->module_index];
 }
 
-#if defined(ap_get_module_loglevel)
-#undef ap_get_module_loglevel
-AP_DECLARE(int) ap_get_module_loglevel(const server_rec *s, int module_index);
+#if defined(ap_get_server_module_loglevel)
+#undef ap_get_server_module_loglevel
+AP_DECLARE(int) ap_get_server_module_loglevel(const server_rec *s, int module_index);
 #endif
 
-AP_DECLARE(int) ap_get_module_loglevel(const server_rec *s, int module_index)
+AP_DECLARE(int) ap_get_server_module_loglevel(const server_rec *s, int module_index)
 {
-    if (module_index < 0 || s->module_loglevels == NULL ||
-        s->module_loglevels[module_index] < 0)
+    if (module_index < 0 || s->log.module_levels == NULL ||
+        s->log.module_levels[module_index] < 0)
     {
-        return s->loglevel;
+        return s->log.level;
     }
 
-    return s->module_loglevels[module_index];
+    return s->log.module_levels[module_index];
+}
+
+#if defined(ap_get_conn_module_loglevel)
+#undef ap_get_conn_module_loglevel
+AP_DECLARE(int) ap_get_conn_module_loglevel(const conn_rec *c, int module_index);
+#endif
+
+AP_DECLARE(int) ap_get_conn_module_loglevel(const conn_rec *c, int module_index)
+{
+    const struct ap_logconf *l = (c)->log ? (c)->log : &(c)->base_server->log;
+    if (module_index < 0 || l->module_levels == NULL ||
+        l->module_levels[module_index] < 0)
+    {
+        return l->level;
+    }
+
+    return l->module_levels[module_index];
+}
+
+#if defined(ap_get_request_module_loglevel)
+#undef ap_get_request_module_loglevel
+AP_DECLARE(int) ap_get_request_module_loglevel(const request_rec *c, int module_index);
+#endif
+
+AP_DECLARE(int) ap_get_request_module_loglevel(const request_rec *r, int module_index)
+{
+    const struct ap_logconf *l = r->log             ? r->log             :
+                                 r->connection->log ? r->connection->log :
+                                 &r->server->log;
+    if (module_index < 0 || l->module_levels == NULL ||
+        l->module_levels[module_index] < 0)
+    {
+        return l->level;
+    }
+
+    return l->module_levels[module_index];
 }
 
 /**



Mime
View raw message