diff options
author | Stefan Fritsch <sf@apache.org> | 2010-06-06 17:04:40 +0000 |
---|---|---|
committer | Stefan Fritsch <sf@apache.org> | 2010-06-06 17:04:40 +0000 |
commit | 2334a1ea4fbf284c73be7dd0165170657dd86d34 (patch) | |
tree | 54c6c2b51b584cc4f0816447b574b3aafe433446 /include | |
parent | af4c0f4923061dde7821b5230f3fd58cb61360b2 (diff) | |
download | httpd-2334a1ea4fbf284c73be7dd0165170657dd86d34.tar.gz |
- Add loglevels to request_rec and conn_rec
- Introduce per-directory loglevel configuration
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@951897 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'include')
-rw-r--r-- | include/http_config.h | 75 | ||||
-rw-r--r-- | include/http_core.h | 3 | ||||
-rw-r--r-- | include/http_log.h | 29 | ||||
-rw-r--r-- | include/httpd.h | 22 |
4 files changed, 108 insertions, 21 deletions
diff --git a/include/http_config.h b/include/http_config.h index c5bbd48298..92c0812a56 100644 --- a/include/http_config.h +++ b/include/http_config.h @@ -487,7 +487,23 @@ AP_DECLARE(void) ap_set_module_config(ap_conf_vector_t *cv, const module *m, * @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(const server_rec *s, int index); * @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_merge_per_dir_configs(apr_pool_t *p, 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 diff --git a/include/http_core.h b/include/http_core.h index b83e3cb953..0127fe6d11 100644 --- a/include/http_core.h +++ b/include/http_core.h @@ -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 */ diff --git a/include/http_log.h b/include/http_log.h index 183be0aa8e..e296bedc32 100644 --- a/include/http_log.h +++ b/include/http_log.h @@ -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) diff --git a/include/httpd.h b/include/httpd.h index 9d1ccda5a6..c31a6f4562 100644 --- a/include/httpd.h +++ b/include/httpd.h @@ -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... */ |