On Wed, 9 Jun 2010, Ruediger Pluem wrote:
On 06/09/2010 09:36 PM, Stefan Fritsch wrote:
On Wed, 9 Jun 2010, Ruediger Pluem wrote:
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.


 /**
  * 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_?

There is no ap_log_perror_ because the pool p does not have a per-module
loglevel configuration.

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


I am still confused then.
Why having AP_DECLARE(void) ap_log_perror_ then?
Why define ap_log_perror to ap_log_perror_ on non C99 compilers then?
ap_do_log_perror only shows up in the definition of ap_log_perror__ nowhere 
else.
What does it do?

It allows (with C99 compilers) to remove debug/trace logging at compile time by defining APLOG_MAX_LOGLEVEL. The other ap_log_*error functions allow the same.

Reply via email to