Skip to content

Commit fbd058e

Browse files
author
Stefan Fritsch
committed
- Introduce log levels trace1/.../trace8
- Add macro wrappers for ap_log_*error. On C99, this will save argument preparation and function call overhead when a message is not logged because of the configured loglevel. - Introduce per-module loglevel configuration. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@951893 13f79535-47bb-0310-9956-ffa450edef68
1 parent 39f1ace commit fbd058e

9 files changed

Lines changed: 374 additions & 77 deletions

File tree

configure.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ dnl PCRE and for our config tests will be whatever PCRE determines.
170170
AC_PROG_CC
171171
AC_PROG_CPP
172172

173+
dnl Try to get c99 support for variadic macros
174+
AC_PROG_CC_C99
175+
173176
if test "x${cache_file}" = "x/dev/null"; then
174177
# Likewise, ensure that CC and CPP are passed through to the pcre
175178
# configure script iff caching is disabled (the autoconf 2.5x default).

include/ap_mmn.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,17 @@
221221
* 20100223.1 (2.3.6-dev) Added ap_process_fnmatch_configs().
222222
* 20100504.0 (2.3.6-dev) Added name arg to ap_{proc,global}_mutex_create().
223223
* 20100604.0 (2.3.6-dev) Remove unused core_dir_config::loglevel
224+
* 20100606.0 (2.3.6-dev) Make ap_log_*error macro wrappers around
225+
* ap_log_*error_ to save argument preparation and
226+
* function call overhead.
227+
* Introduce per-module loglevels
228+
*
224229
*/
225230

226231
#define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
227232

228233
#ifndef MODULE_MAGIC_NUMBER_MAJOR
229-
#define MODULE_MAGIC_NUMBER_MAJOR 20100604
234+
#define MODULE_MAGIC_NUMBER_MAJOR 20100606
230235
#endif
231236
#define MODULE_MAGIC_NUMBER_MINOR 0 /* 0...n */
232237

include/http_config.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#include "apr_hooks.h"
3030
#include "util_cfgtree.h"
31+
#include "ap_config.h"
3132

3233
#ifdef __cplusplus
3334
extern "C" {
@@ -394,6 +395,17 @@ struct module_struct {
394395
void (*register_hooks) (apr_pool_t *p);
395396
};
396397

398+
/*
399+
* Macro to choose which module a file belongs to, for logging.
400+
*/
401+
#define APLOG_USE_MODULE(foo) \
402+
extern module AP_MODULE_DECLARE_DATA foo##_module; \
403+
static int * const aplog_module_index = &(foo##_module.module_index)
404+
405+
#define AP_DECLARE_MODULE(foo) \
406+
APLOG_USE_MODULE(foo); \
407+
module AP_MODULE_DECLARE_DATA foo##_module
408+
397409
/**
398410
* @defgroup ModuleInit Module structure initializers
399411
*
@@ -469,6 +481,44 @@ AP_DECLARE(void) ap_set_module_config(ap_conf_vector_t *cv, const module *m,
469481
#endif /* AP_DEBUG */
470482

471483

484+
/**
485+
* Generic accessor for modules to get the module-specific loglevel
486+
* @param s The server from which to get the loglevel.
487+
* @param index The module_index of the module to get the loglevel for.
488+
* @return The module-specific loglevel
489+
*/
490+
AP_DECLARE(int) ap_get_module_loglevel(const server_rec *s, int index);
491+
492+
/**
493+
* Accessor to set module-specific loglevel
494+
* @param p A pool
495+
* @param s The server for which to set the loglevel.
496+
* @param index The module_index of the module to set the loglevel for.
497+
* @param level The new log level
498+
* @return The module-specific loglevel
499+
*/
500+
AP_DECLARE(void) ap_set_module_loglevel(apr_pool_t *p, server_rec *s,
501+
int index, int level);
502+
503+
#if !defined(AP_DEBUG)
504+
505+
#define ap_get_module_loglevel(s,i) \
506+
(i < 0 || (s)->module_loglevels == NULL || (((s)->module_loglevels)[i]) < 0 ? \
507+
(s)->loglevel : \
508+
((s)->module_loglevels)[i])
509+
510+
#endif /* AP_DEBUG */
511+
512+
/**
513+
* Reset all module-specific loglevels to server default
514+
* @param p A pool
515+
* @param s The server for which to set the loglevel.
516+
* @param index The module_index of the module to set the loglevel for.
517+
* @param level The new log level
518+
* @return The module-specific loglevel
519+
*/
520+
AP_DECLARE(void) ap_reset_module_loglevels(server_rec *s);
521+
472522
/**
473523
* Generic command handling function for strings
474524
* @param cmd The command parameters for this directive

0 commit comments

Comments
 (0)