On 06/06/2010 06:54 PM, s...@apache.org wrote:
> Author: sf
> Date: Sun Jun  6 16:54:51 2010
> New Revision: 951893
> 
> URL: http://svn.apache.org/viewvc?rev=951893&view=rev
> Log:
> - 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.
> 
> Modified:
>     httpd/httpd/trunk/configure.in
>     httpd/httpd/trunk/include/ap_mmn.h
>     httpd/httpd/trunk/include/http_config.h
>     httpd/httpd/trunk/include/http_log.h
>     httpd/httpd/trunk/include/httpd.h
>     httpd/httpd/trunk/server/config.c
>     httpd/httpd/trunk/server/core.c
>     httpd/httpd/trunk/server/log.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=951893&r1=951892&r2=951893&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/include/http_config.h (original)
> +++ httpd/httpd/trunk/include/http_config.h Sun Jun  6 16:54:51 2010

> @@ -470,6 +482,44 @@ AP_DECLARE(void) ap_set_module_config(ap
>  
>  
>  /**
> + * Generic accessor for modules to get the module-specific loglevel
> + * @param s The server 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_module_loglevel(const server_rec *s, int index);
> +
> +/**
> + * Accessor to set module-specific loglevel
> + * @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
> + */
> +AP_DECLARE(void) ap_set_module_loglevel(apr_pool_t *p, server_rec *s,
> +                                        int index, int level);

Nitpick: Documentation and declaration do not match. This functions returns 
void.

> +
> +#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])
> +
> +#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

Nitpick: Documentation and declaration do not match. This functions returns 
void.


> + */
> +AP_DECLARE(void) ap_reset_module_loglevels(server_rec *s);
> +
> +/**
>   * Generic command handling function for strings
>   * @param cmd The command parameters for this directive
>   * @param struct_ptr pointer into a given type
> 
> Modified: httpd/httpd/trunk/include/http_log.h
> URL: 
> http://svn.apache.org/viewvc/httpd/httpd/trunk/include/http_log.h?rev=951893&r1=951892&r2=951893&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/include/http_log.h (original)
> +++ httpd/httpd/trunk/include/http_log.h Sun Jun  6 16:54:51 2010

> @@ -91,9 +109,79 @@ extern "C" {
>  #define DEFAULT_LOGLEVEL     APLOG_WARNING
>  #endif
>  
> +#define APLOG_NO_MODULE         -1
> +
> +/*
> + * Objects with static storage duration are set to NULL if not
> + * initialized explicitly. This means if aplog_module_index
> + * is not initalized using the APLOG_USE_MODULE or the
> + * AP_DECLARE_MODULE macro, we can safely fall back to
> + * use APLOG_NO_MODULE.
> + */
> +static int * const aplog_module_index;
> +#define APLOG_MODULE_INDEX  \
> +    (aplog_module_index ? *aplog_module_index : APLOG_NO_MODULE)
> +
> +/*
> + * APLOG_MAX_LOGLEVEL can be used to remove logging above some
> + * specified level at compile time.
> + */
> +#ifndef APLOG_MAX_LOGLEVEL
> +#define APLOG_MODULE_IS_LEVEL(s,module_index,level)              \
> +          ( (((level)&APLOG_LEVELMASK) <= APLOG_NOTICE) ||       \
> +            (s == NULL) ||                                       \
> +            (ap_get_module_loglevel(s, 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)             \
> +             >= ((level)&APLOG_LEVELMASK) ) ) )
> +#endif
> +
> +#define APLOG_IS_LEVEL(s,level)     \
> +    APLOG_MODULE_IS_LEVEL(s,APLOG_MODULE_INDEX,level)
> +
> +#define APLOGinfo(s)                APLOG_IS_LEVEL(s,APLOG_INFO)
> +#define APLOGdebug(s)               APLOG_IS_LEVEL(s,APLOG_DEBUG)
> +#define APLOGtrace1(s)              APLOG_IS_LEVEL(s,APLOG_TRACE1)
> +#define APLOGtrace2(s)              APLOG_IS_LEVEL(s,APLOG_TRACE2)
> +#define APLOGtrace3(s)              APLOG_IS_LEVEL(s,APLOG_TRACE3)
> +#define APLOGtrace4(s)              APLOG_IS_LEVEL(s,APLOG_TRACE4)
> +#define APLOGtrace5(s)              APLOG_IS_LEVEL(s,APLOG_TRACE5)
> +#define APLOGtrace6(s)              APLOG_IS_LEVEL(s,APLOG_TRACE6)
> +#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)
> +#define APLOGrtrace2(r)             APLOG_R_IS_LEVEL(r,APLOG_TRACE2)
> +#define APLOGrtrace3(r)             APLOG_R_IS_LEVEL(r,APLOG_TRACE3)
> +#define APLOGrtrace4(r)             APLOG_R_IS_LEVEL(r,APLOG_TRACE4)
> +#define APLOGrtrace5(r)             APLOG_R_IS_LEVEL(r,APLOG_TRACE5)
> +#define APLOGrtrace6(r)             APLOG_R_IS_LEVEL(r,APLOG_TRACE6)
> +#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)
> +#define APLOGctrace2(r)             APLOG_C_IS_LEVEL(c,APLOG_TRACE2)
> +#define APLOGctrace3(r)             APLOG_C_IS_LEVEL(c,APLOG_TRACE3)
> +#define APLOGctrace4(r)             APLOG_C_IS_LEVEL(c,APLOG_TRACE4)
> +#define APLOGctrace5(r)             APLOG_C_IS_LEVEL(c,APLOG_TRACE5)
> +#define APLOGctrace6(r)             APLOG_C_IS_LEVEL(c,APLOG_TRACE6)
> +#define APLOGctrace7(r)             APLOG_C_IS_LEVEL(c,APLOG_TRACE7)
> +#define APLOGctrace8(r)             APLOG_C_IS_LEVEL(c,APLOG_TRACE8)

Why r on the left side and c on the right one?
I guess it should be

#define APLOGctrace1(c)             APLOG_C_IS_LEVEL(c,APLOG_TRACE1)

instead for example.


> +
>  extern int AP_DECLARE_DATA ap_default_loglevel;
>  
> -#define APLOG_MARK   __FILE__,__LINE__
> +#define APLOG_MARK     __FILE__,__LINE__,APLOG_MODULE_INDEX
>  
>  /**
>   * Set up for logging to stderr.
> @@ -164,10 +253,20 @@ void ap_logs_child_init(apr_pool_t *p, s
>   * simple format string like "%s", followed by the string containing the 
>   * untrusted data.
>   */
> -AP_DECLARE(void) ap_log_error(const char *file, int line, int level, 
> -                             apr_status_t status, const server_rec *s, 
> -                             const char *fmt, ...)
> -                         __attribute__((format(printf,6,7)));
> +#if __STDC_VERSION__ >= 199901L
> +/* need additional step to expand APLOG_MARK first */
> +#define ap_log_error(...) ap_log_error__(__VA_ARGS__)
> +#define ap_log_error__(file, line, mi, level, status, s, ...)           \
> +    do { server_rec *sr = s; if (APLOG_MODULE_IS_LEVEL(sr, mi, level))  \
> +             ap_log_error_(file, line, mi, level, status, sr, __VA_ARGS__); \
> +    } while(0)

Why can't we use s directly and need sr?

> +#else
> +#define ap_log_error ap_log_error_
> +#endif
> +AP_DECLARE(void) ap_log_error_(const char *file, int line, int module_index,
> +                               int level, apr_status_t status,
> +                               const server_rec *s, const char *fmt, ...)
> +                              __attribute__((format(printf,7,8)));
>  
>  /**
>   * ap_log_perror() - log messages which are not related to a particular
> @@ -188,10 +288,20 @@ AP_DECLARE(void) ap_log_error(const char
>   * simple format string like "%s", followed by the string containing the 
>   * untrusted data.
>   */
> -AP_DECLARE(void) ap_log_perror(const char *file, int line, int level, 
> -                             apr_status_t status, apr_pool_t *p, 
> -                             const char *fmt, ...)
> -                         __attribute__((format(printf,6,7)));
> +#if __STDC_VERSION__ >= 199901L && defined(APLOG_MAX_LOGLEVEL)
> +/* need additional step to expand APLOG_MARK first */
> +#define ap_log_perror(...) ap_log_perror__(__VA_ARGS__)
> +#define ap_log_perror__(file, line, mi, level, status, p, ...)            \
> +    do { if ((level) <= APLOG_MAX_LOGLEVEL )                              \
> +             ap_do_log_perror(file, line, mi, level, status, p,           \
> +                             __VA_ARGS__); } while(0)

Why ap_do_log_perror and not ap_log_perror_?

> +#else
> +#define ap_log_perror ap_log_perror_
> +#endif
> +AP_DECLARE(void) ap_log_perror_(const char *file, int line, int module_index,
> +                                int level, apr_status_t status, apr_pool_t 
> *p,
> +                                const char *fmt, ...)
> +                               __attribute__((format(printf,7,8)));
>  
>  /**
>   * ap_log_rerror() - log messages which are related to a particular


Regards

RĂ¼diger

Reply via email to