1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 * @brief Apache Logging library
21 * @defgroup APACHE_CORE_LOG Logging library
22 * @ingroup APACHE_CORE
26 #ifndef APACHE_HTTP_LOG_H
27 #define APACHE_HTTP_LOG_H
33 #include "apr_thread_proc.h"
34 #include "http_config.h"
43 #define APLOG_EMERG LOG_EMERG /* system is unusable */
44 #define APLOG_ALERT LOG_ALERT /* action must be taken immediately */
45 #define APLOG_CRIT LOG_CRIT /* critical conditions */
46 #define APLOG_ERR LOG_ERR /* error conditions */
47 #define APLOG_WARNING LOG_WARNING /* warning conditions */
48 #define APLOG_NOTICE LOG_NOTICE /* normal but significant condition */
49 #define APLOG_INFO LOG_INFO /* informational */
50 #define APLOG_DEBUG LOG_DEBUG /* debug-level messages */
51 #define APLOG_TRACE1 (LOG_DEBUG + 1) /* trace-level 1 messages */
52 #define APLOG_TRACE2 (LOG_DEBUG + 2) /* trace-level 2 messages */
53 #define APLOG_TRACE3 (LOG_DEBUG + 3) /* trace-level 3 messages */
54 #define APLOG_TRACE4 (LOG_DEBUG + 4) /* trace-level 4 messages */
55 #define APLOG_TRACE5 (LOG_DEBUG + 5) /* trace-level 5 messages */
56 #define APLOG_TRACE6 (LOG_DEBUG + 6) /* trace-level 6 messages */
57 #define APLOG_TRACE7 (LOG_DEBUG + 7) /* trace-level 7 messages */
58 #define APLOG_TRACE8 (LOG_DEBUG + 8) /* trace-level 8 messages */
60 #define APLOG_LEVELMASK 15 /* mask off the level value */
64 #define APLOG_EMERG 0 /* system is unusable */
65 #define APLOG_ALERT 1 /* action must be taken immediately */
66 #define APLOG_CRIT 2 /* critical conditions */
67 #define APLOG_ERR 3 /* error conditions */
68 #define APLOG_WARNING 4 /* warning conditions */
69 #define APLOG_NOTICE 5 /* normal but significant condition */
70 #define APLOG_INFO 6 /* informational */
71 #define APLOG_DEBUG 7 /* debug-level messages */
72 #define APLOG_TRACE1 8 /* trace-level 1 messages */
73 #define APLOG_TRACE2 9 /* trace-level 2 messages */
74 #define APLOG_TRACE3 10 /* trace-level 3 messages */
75 #define APLOG_TRACE4 11 /* trace-level 4 messages */
76 #define APLOG_TRACE5 12 /* trace-level 5 messages */
77 #define APLOG_TRACE6 13 /* trace-level 6 messages */
78 #define APLOG_TRACE7 14 /* trace-level 7 messages */
79 #define APLOG_TRACE8 15 /* trace-level 8 messages */
81 #define APLOG_LEVELMASK 15 /* mask off the level value */
85 /* APLOG_NOERRNO is ignored and should not be used. It will be
86 * removed in a future release of Apache.
88 #define APLOG_NOERRNO (APLOG_LEVELMASK + 1)
90 /** Use APLOG_TOCLIENT on ap_log_rerror() to give content
91 * handlers the option of including the error text in the
92 * ErrorDocument sent back to the client. Setting APLOG_TOCLIENT
93 * will cause the error text to be saved in the request_rec->notes
94 * table, keyed to the string "error-notes", if and only if:
95 * - the severity level of the message is APLOG_WARNING or greater
96 * - there are no other "error-notes" set in request_rec->notes
97 * Once error-notes is set, it is up to the content handler to
98 * determine whether this text should be sent back to the client.
99 * Note: Client generated text streams sent back to the client MUST
100 * be escaped to prevent CSS attacks.
102 #define APLOG_TOCLIENT ((APLOG_LEVELMASK + 1) * 2)
104 /* normal but significant condition on startup, usually printed to stderr */
105 #define APLOG_STARTUP ((APLOG_LEVELMASK + 1) * 4)
107 #ifndef DEFAULT_LOGLEVEL
108 #define DEFAULT_LOGLEVEL APLOG_WARNING
112 * APLOG_NO_MODULE may be passed as module_index to ap_log_error() and related
113 * functions if the module causing the log message is not known. Normally this
114 * should not be used directly. Use ::APLOG_MARK or ::APLOG_MODULE_INDEX
118 * @see APLOG_MODULE_INDEX
121 #define APLOG_NO_MODULE -1
125 * C++ modules must invoke ::APLOG_USE_MODULE or ::AP_DECLARE_MODULE in
126 * every file which uses ap_log_* before the first use of ::APLOG_MARK
127 * or ::APLOG_MODULE_INDEX.
128 * (C modules *should* do that as well, to enable module-specific log
129 * levels. C modules need not obey the ordering, though).
131 #else /* __cplusplus */
133 * Constant to store module_index for the current file.
134 * Objects with static storage duration are set to NULL if not
135 * initialized explicitly. This means that if aplog_module_index
136 * is not initalized using the ::APLOG_USE_MODULE or the
137 * ::AP_DECLARE_MODULE macro, we can safely fall back to
138 * use ::APLOG_NO_MODULE. This variable will usually be optimized away.
140 static int * const aplog_module_index;
141 #endif /* __cplusplus */
144 * APLOG_MODULE_INDEX contains the module_index of the current module if
145 * it has been set via the ::APLOG_USE_MODULE or ::AP_DECLARE_MODULE macro.
146 * Otherwise it contains ::APLOG_NO_MODULE (for example in unmodified httpd
149 * If ::APLOG_MARK is used in ap_log_error() and related functions,
150 * ::APLOG_MODULE_INDEX will be passed as module_index. In cases where
151 * ::APLOG_MARK cannot be used, ::APLOG_MODULE_INDEX should normally be passed
158 #define APLOG_MODULE_INDEX (*aplog_module_index)
159 #else /* __cplusplus */
160 #define APLOG_MODULE_INDEX \
161 (aplog_module_index ? *aplog_module_index : APLOG_NO_MODULE)
162 #endif /* __cplusplus */
165 * APLOG_MAX_LOGLEVEL can be defined to remove logging above some
166 * specified level at compile time.
168 * This requires a C99 compiler.
171 #define APLOG_MAX_LOGLEVEL
173 #ifndef APLOG_MAX_LOGLEVEL
174 #define APLOG_MODULE_IS_LEVEL(s,module_index,level) \
175 ( (((level)&APLOG_LEVELMASK) <= APLOG_NOTICE) || \
177 (ap_get_server_module_loglevel(s, module_index) \
178 >= ((level)&APLOG_LEVELMASK) ) )
179 #define APLOG_C_MODULE_IS_LEVEL(c,module_index,level) \
180 ( (((level)&APLOG_LEVELMASK) <= APLOG_NOTICE) || \
181 (ap_get_conn_module_loglevel(c, module_index) \
182 >= ((level)&APLOG_LEVELMASK) ) )
183 #define APLOG_CS_MODULE_IS_LEVEL(c,s,module_index,level) \
184 ( (((level)&APLOG_LEVELMASK) <= APLOG_NOTICE) || \
185 (ap_get_conn_server_module_loglevel(c, s, module_index) \
186 >= ((level)&APLOG_LEVELMASK) ) )
187 #define APLOG_R_MODULE_IS_LEVEL(r,module_index,level) \
188 ( (((level)&APLOG_LEVELMASK) <= APLOG_NOTICE) || \
189 (ap_get_request_module_loglevel(r, module_index) \
190 >= ((level)&APLOG_LEVELMASK) ) )
192 #define APLOG_MODULE_IS_LEVEL(s,module_index,level) \
193 ( (((level)&APLOG_LEVELMASK) <= APLOG_MAX_LOGLEVEL) && \
194 ( (((level)&APLOG_LEVELMASK) <= APLOG_NOTICE) || \
196 (ap_get_server_module_loglevel(s, module_index) \
197 >= ((level)&APLOG_LEVELMASK) ) ) )
198 #define APLOG_CS_MODULE_IS_LEVEL(c,s,module_index,level) \
199 ( (((level)&APLOG_LEVELMASK) <= APLOG_MAX_LOGLEVEL) && \
200 ( (((level)&APLOG_LEVELMASK) <= APLOG_NOTICE) || \
201 (ap_get_conn_server_module_loglevel(c, s, module_index) \
202 >= ((level)&APLOG_LEVELMASK) ) ) )
203 #define APLOG_C_MODULE_IS_LEVEL(c,module_index,level) \
204 ( (((level)&APLOG_LEVELMASK) <= APLOG_MAX_LOGLEVEL) && \
205 ( (((level)&APLOG_LEVELMASK) <= APLOG_NOTICE) || \
206 (ap_get_conn_module_loglevel(c, module_index) \
207 >= ((level)&APLOG_LEVELMASK) ) ) )
208 #define APLOG_R_MODULE_IS_LEVEL(r,module_index,level) \
209 ( (((level)&APLOG_LEVELMASK) <= APLOG_MAX_LOGLEVEL) && \
210 ( (((level)&APLOG_LEVELMASK) <= APLOG_NOTICE) || \
211 (ap_get_request_module_loglevel(r, module_index) \
212 >= ((level)&APLOG_LEVELMASK) ) ) )
215 #define APLOG_IS_LEVEL(s,level) \
216 APLOG_MODULE_IS_LEVEL(s,APLOG_MODULE_INDEX,level)
217 #define APLOG_C_IS_LEVEL(c,level) \
218 APLOG_C_MODULE_IS_LEVEL(c,APLOG_MODULE_INDEX,level)
219 #define APLOG_CS_IS_LEVEL(c,s,level) \
220 APLOG_CS_MODULE_IS_LEVEL(c,s,APLOG_MODULE_INDEX,level)
221 #define APLOG_R_IS_LEVEL(r,level) \
222 APLOG_R_MODULE_IS_LEVEL(r,APLOG_MODULE_INDEX,level)
225 #define APLOGinfo(s) APLOG_IS_LEVEL(s,APLOG_INFO)
226 #define APLOGdebug(s) APLOG_IS_LEVEL(s,APLOG_DEBUG)
227 #define APLOGtrace1(s) APLOG_IS_LEVEL(s,APLOG_TRACE1)
228 #define APLOGtrace2(s) APLOG_IS_LEVEL(s,APLOG_TRACE2)
229 #define APLOGtrace3(s) APLOG_IS_LEVEL(s,APLOG_TRACE3)
230 #define APLOGtrace4(s) APLOG_IS_LEVEL(s,APLOG_TRACE4)
231 #define APLOGtrace5(s) APLOG_IS_LEVEL(s,APLOG_TRACE5)
232 #define APLOGtrace6(s) APLOG_IS_LEVEL(s,APLOG_TRACE6)
233 #define APLOGtrace7(s) APLOG_IS_LEVEL(s,APLOG_TRACE7)
234 #define APLOGtrace8(s) APLOG_IS_LEVEL(s,APLOG_TRACE8)
236 #define APLOGrinfo(r) APLOG_R_IS_LEVEL(r,APLOG_INFO)
237 #define APLOGrdebug(r) APLOG_R_IS_LEVEL(r,APLOG_DEBUG)
238 #define APLOGrtrace1(r) APLOG_R_IS_LEVEL(r,APLOG_TRACE1)
239 #define APLOGrtrace2(r) APLOG_R_IS_LEVEL(r,APLOG_TRACE2)
240 #define APLOGrtrace3(r) APLOG_R_IS_LEVEL(r,APLOG_TRACE3)
241 #define APLOGrtrace4(r) APLOG_R_IS_LEVEL(r,APLOG_TRACE4)
242 #define APLOGrtrace5(r) APLOG_R_IS_LEVEL(r,APLOG_TRACE5)
243 #define APLOGrtrace6(r) APLOG_R_IS_LEVEL(r,APLOG_TRACE6)
244 #define APLOGrtrace7(r) APLOG_R_IS_LEVEL(r,APLOG_TRACE7)
245 #define APLOGrtrace8(r) APLOG_R_IS_LEVEL(r,APLOG_TRACE8)
247 #define APLOGcinfo(c) APLOG_C_IS_LEVEL(c,APLOG_INFO)
248 #define APLOGcdebug(c) APLOG_C_IS_LEVEL(c,APLOG_DEBUG)
249 #define APLOGctrace1(c) APLOG_C_IS_LEVEL(c,APLOG_TRACE1)
250 #define APLOGctrace2(c) APLOG_C_IS_LEVEL(c,APLOG_TRACE2)
251 #define APLOGctrace3(c) APLOG_C_IS_LEVEL(c,APLOG_TRACE3)
252 #define APLOGctrace4(c) APLOG_C_IS_LEVEL(c,APLOG_TRACE4)
253 #define APLOGctrace5(c) APLOG_C_IS_LEVEL(c,APLOG_TRACE5)
254 #define APLOGctrace6(c) APLOG_C_IS_LEVEL(c,APLOG_TRACE6)
255 #define APLOGctrace7(c) APLOG_C_IS_LEVEL(c,APLOG_TRACE7)
256 #define APLOGctrace8(c) APLOG_C_IS_LEVEL(c,APLOG_TRACE8)
258 extern int AP_DECLARE_DATA ap_default_loglevel;
261 * APLOG_MARK is a convenience macro for use as the first three parameters in
262 * ap_log_error() and related functions, i.e. file, line, and module_index.
264 * The module_index parameter was introduced in version 2.3.6. Before that
265 * version, APLOG_MARK only replaced the file and line parameters.
266 * This means that APLOG_MARK can be used with ap_log_*error in all versions
269 * @see APLOG_MODULE_INDEX
273 * @see ap_log_cserror
275 #define APLOG_MARK __FILE__,__LINE__,APLOG_MODULE_INDEX
278 * Set up for logging to stderr.
279 * @param p The pool to allocate out of
281 AP_DECLARE(void) ap_open_stderr_log(apr_pool_t *p);
284 * Replace logging to stderr with logging to the given file.
285 * @param p The pool to allocate out of
286 * @param file Name of the file to log stderr output
288 AP_DECLARE(apr_status_t) ap_replace_stderr_log(apr_pool_t *p,
292 * Open the error log and replace stderr with it.
293 * @param pconf Not used
294 * @param plog The pool to allocate the logs from
295 * @param ptemp Pool used for temporary allocations
296 * @param s_main The main server
297 * @note ap_open_logs isn't expected to be used by modules, it is
298 * an internal core function
300 int ap_open_logs(apr_pool_t *pconf, apr_pool_t *plog,
301 apr_pool_t *ptemp, server_rec *s_main);
304 * Perform special processing for piped loggers in MPM child
308 * @note ap_logs_child_init is not for use by modules; it is an
309 * internal core function
311 void ap_logs_child_init(apr_pool_t *p, server_rec *s);
314 * The primary logging functions, ap_log_error, ap_log_rerror, ap_log_cerror,
315 * and ap_log_perror use a printf style format string to build the log message.
316 * It is VERY IMPORTANT that you not include any raw data from the network,
317 * such as the request-URI or request header fields, within the format
318 * string. Doing so makes the server vulnerable to a denial-of-service
319 * attack and other messy behavior. Instead, use a simple format string
320 * like "%s", followed by the string containing the untrusted data.
324 * ap_log_error() - log messages which are not related to a particular
325 * request or connection. This uses a printf-like format to log messages
327 * @param file The file in which this function is called
328 * @param line The line number on which this function is called
329 * @param module_index The module_index of the module generating this message
330 * @param level The level of this error message
331 * @param status The status code from the previous command
332 * @param s The server on which we are logging
333 * @param fmt The format string
334 * @param ... The arguments to use to fill out fmt.
335 * @note ap_log_error is implemented as a macro
336 * @note Use APLOG_MARK to fill out file and line
337 * @note If a request_rec is available, use that with ap_log_rerror()
338 * in preference to calling this function. Otherwise, if a conn_rec is
339 * available, use that with ap_log_cerror() in preference to calling
341 * @warning It is VERY IMPORTANT that you not include any raw data from
342 * the network, such as the request-URI or request header fields, within
343 * the format string. Doing so makes the server vulnerable to a
344 * denial-of-service attack and other messy behavior. Instead, use a
345 * simple format string like "%s", followed by the string containing the
349 AP_DECLARE(void) ap_log_error(const char *file, int line, int module_index,
350 int level, apr_status_t status,
351 const server_rec *s, const char *fmt, ...);
353 #if __STDC_VERSION__ >= 199901L
354 /* need additional step to expand APLOG_MARK first */
355 #define ap_log_error(...) ap_log_error__(__VA_ARGS__)
356 /* need server_rec *sr = ... for the case if s is verbatim NULL */
357 #define ap_log_error__(file, line, mi, level, status, s, ...) \
358 do { const server_rec *sr = s; if (APLOG_MODULE_IS_LEVEL(sr, mi, level)) \
359 ap_log_error_(file, line, mi, level, status, sr, __VA_ARGS__); \
362 #define ap_log_error ap_log_error_
364 AP_DECLARE(void) ap_log_error_(const char *file, int line, int module_index,
365 int level, apr_status_t status,
366 const server_rec *s, const char *fmt, ...)
367 __attribute__((format(printf,7,8)));
371 * ap_log_perror() - log messages which are not related to a particular
372 * request, connection, or virtual server. This uses a printf-like
373 * format to log messages to the error_log.
374 * @param file The file in which this function is called
375 * @param line The line number on which this function is called
376 * @param module_index ignored dummy value for use by APLOG_MARK
377 * @param level The level of this error message
378 * @param status The status code from the previous command
379 * @param p The pool which we are logging for
380 * @param fmt The format string
381 * @param ... The arguments to use to fill out fmt.
382 * @note ap_log_perror is implemented as a macro
383 * @note Use APLOG_MARK to fill out file, line, and module_index
384 * @warning It is VERY IMPORTANT that you not include any raw data from
385 * the network, such as the request-URI or request header fields, within
386 * the format string. Doing so makes the server vulnerable to a
387 * denial-of-service attack and other messy behavior. Instead, use a
388 * simple format string like "%s", followed by the string containing the
392 AP_DECLARE(void) ap_log_perror(const char *file, int line, int module_index,
393 int level, apr_status_t status, apr_pool_t *p,
394 const char *fmt, ...);
396 #if __STDC_VERSION__ >= 199901L && defined(APLOG_MAX_LOGLEVEL)
397 /* need additional step to expand APLOG_MARK first */
398 #define ap_log_perror(...) ap_log_perror__(__VA_ARGS__)
399 #define ap_log_perror__(file, line, mi, level, status, p, ...) \
400 do { if ((level) <= APLOG_MAX_LOGLEVEL ) \
401 ap_log_perror_(file, line, mi, level, status, p, \
402 __VA_ARGS__); } while(0)
404 #define ap_log_perror ap_log_perror_
406 AP_DECLARE(void) ap_log_perror_(const char *file, int line, int module_index,
407 int level, apr_status_t status, apr_pool_t *p,
408 const char *fmt, ...)
409 __attribute__((format(printf,7,8)));
413 * ap_log_rerror() - log messages which are related to a particular
414 * request. This uses a printf-like format to log messages to the
416 * @param file The file in which this function is called
417 * @param line The line number on which this function is called
418 * @param module_index The module_index of the module generating this message
419 * @param level The level of this error message
420 * @param status The status code from the previous command
421 * @param r The request which we are logging for
422 * @param fmt The format string
423 * @param ... The arguments to use to fill out fmt.
424 * @note ap_log_rerror is implemented as a macro
425 * @note Use APLOG_MARK to fill out file, line, and module_index
426 * @warning It is VERY IMPORTANT that you not include any raw data from
427 * the network, such as the request-URI or request header fields, within
428 * the format string. Doing so makes the server vulnerable to a
429 * denial-of-service attack and other messy behavior. Instead, use a
430 * simple format string like "%s", followed by the string containing the
434 AP_DECLARE(void) ap_log_rerror(const char *file, int line, int module_index,
435 int level, apr_status_t status,
436 const request_rec *r, const char *fmt, ...);
438 #if __STDC_VERSION__ >= 199901L
439 /* need additional step to expand APLOG_MARK first */
440 #define ap_log_rerror(...) ap_log_rerror__(__VA_ARGS__)
441 #define ap_log_rerror__(file, line, mi, level, status, r, ...) \
442 do { if (APLOG_R_MODULE_IS_LEVEL(r, mi, level)) \
443 ap_log_rerror_(file, line, mi, level, status, r, __VA_ARGS__); \
446 #define ap_log_rerror ap_log_rerror_
448 AP_DECLARE(void) ap_log_rerror_(const char *file, int line, int module_index,
449 int level, apr_status_t status,
450 const request_rec *r, const char *fmt, ...)
451 __attribute__((format(printf,7,8)));
455 * ap_log_cerror() - log messages which are related to a particular
456 * connection. This uses a printf-like format to log messages to the
458 * @param file The file in which this function is called
459 * @param line The line number on which this function is called
460 * @param level The level of this error message
461 * @param module_index The module_index of the module generating this message
462 * @param status The status code from the previous command
463 * @param c The connection which we are logging for
464 * @param fmt The format string
465 * @param ... The arguments to use to fill out fmt.
466 * @note ap_log_cerror is implemented as a macro
467 * @note Use APLOG_MARK to fill out file, line, and module_index
468 * @note If a request_rec is available, use that with ap_log_rerror()
469 * in preference to calling this function.
470 * @warning It is VERY IMPORTANT that you not include any raw data from
471 * the network, such as the request-URI or request header fields, within
472 * the format string. Doing so makes the server vulnerable to a
473 * denial-of-service attack and other messy behavior. Instead, use a
474 * simple format string like "%s", followed by the string containing the
478 AP_DECLARE(void) ap_log_cerror(const char *file, int line, int module_index,
479 int level, apr_status_t status,
480 const conn_rec *c, const char *fmt, ...);
482 #if __STDC_VERSION__ >= 199901L
483 /* need additional step to expand APLOG_MARK first */
484 #define ap_log_cerror(...) ap_log_cerror__(__VA_ARGS__)
485 #define ap_log_cerror__(file, line, mi, level, status, c, ...) \
486 do { if (APLOG_C_MODULE_IS_LEVEL(c, mi, level)) \
487 ap_log_cerror_(file, line, mi, level, status, c, __VA_ARGS__); \
490 #define ap_log_cerror ap_log_cerror_
492 AP_DECLARE(void) ap_log_cerror_(const char *file, int line, int module_index,
493 int level, apr_status_t status,
494 const conn_rec *c, const char *fmt, ...)
495 __attribute__((format(printf,7,8)));
499 * ap_log_cserror() - log messages which are related to a particular
500 * connection and to a vhost other than c->base_server. This uses a
501 * printf-like format to log messages to the error_log.
502 * @param file The file in which this function is called
503 * @param line The line number on which this function is called
504 * @param level The level of this error message
505 * @param module_index The module_index of the module generating this message
506 * @param status The status code from the previous command
507 * @param c The connection which we are logging for
508 * @param s The server which we are logging for
509 * @param fmt The format string
510 * @param ... The arguments to use to fill out fmt.
511 * @note ap_log_cserror is implemented as a macro
512 * @note Use APLOG_MARK to fill out file, line, and module_index
513 * @note If a request_rec is available, use that with ap_log_rerror()
514 * in preference to calling this function. This function is mainly useful for
515 * modules like mod_ssl to use before the request_rec is created.
516 * @warning It is VERY IMPORTANT that you not include any raw data from
517 * the network, such as the request-URI or request header fields, within
518 * the format string. Doing so makes the server vulnerable to a
519 * denial-of-service attack and other messy behavior. Instead, use a
520 * simple format string like "%s", followed by the string containing the
524 AP_DECLARE(void) ap_log_cserror(const char *file, int line, int module_index,
525 int level, apr_status_t status,
526 const conn_rec *c, const server_rec *s,
527 const char *fmt, ...);
529 #if __STDC_VERSION__ >= 199901L
530 /* need additional step to expand APLOG_MARK first */
531 #define ap_log_cserror(...) ap_log_cserror__(__VA_ARGS__)
532 #define ap_log_cserror__(file, line, mi, level, status, c, s, ...) \
533 do { if (APLOG_CS_MODULE_IS_LEVEL(c, s, mi, level)) \
534 ap_log_cserror_(file, line, mi, level, status, c, s, \
538 #define ap_log_cserror ap_log_cserror_
540 AP_DECLARE(void) ap_log_cserror_(const char *file, int line, int module_index,
541 int level, apr_status_t status,
542 const conn_rec *c, const server_rec *s,
543 const char *fmt, ...)
544 __attribute__((format(printf,8,9)));
548 * Convert stderr to the error log
549 * @param s The current server
551 AP_DECLARE(void) ap_error_log2stderr(server_rec *s);
554 * Log the command line used to start the server.
555 * @param p The pool to use for logging
556 * @param s The server_rec whose process's command line we want to log.
557 * The command line is logged to that server's error log.
559 AP_DECLARE(void) ap_log_command_line(apr_pool_t *p, server_rec *s);
562 * Log the current pid of the parent process
563 * @param p The pool to use for processing
564 * @param fname The name of the file to log to
566 AP_DECLARE(void) ap_log_pid(apr_pool_t *p, const char *fname);
569 * Remove the pidfile.
570 * @param p The pool to use for processing
571 * @param fname The name of the pid file to remove
573 AP_DECLARE(void) ap_remove_pid(apr_pool_t *p, const char *fname);
576 * Retrieve the pid from a pidfile.
577 * @param p The pool to use for processing
578 * @param filename The name of the file containing the pid
579 * @param mypid Pointer to pid_t (valid only if return APR_SUCCESS)
581 AP_DECLARE(apr_status_t) ap_read_pid(apr_pool_t *p, const char *filename, pid_t *mypid);
583 /** @see piped_log */
584 typedef struct piped_log piped_log;
587 * Open the piped log process
588 * @param p The pool to allocate out of
589 * @param program The program to run in the logging process
590 * @return The piped log structure
591 * @note The log program is invoked as @p APR_PROGRAM_ENV,
592 * @see ap_open_piped_log_ex to modify this behavior
594 AP_DECLARE(piped_log *) ap_open_piped_log(apr_pool_t *p, const char *program);
597 * Open the piped log process specifying the execution choice for program
598 * @param p The pool to allocate out of
599 * @param program The program to run in the logging process
600 * @param cmdtype How to invoke program, e.g. APR_PROGRAM, APR_SHELLCMD_ENV, etc
601 * @return The piped log structure
603 AP_DECLARE(piped_log *) ap_open_piped_log_ex(apr_pool_t *p,
605 apr_cmdtype_e cmdtype);
608 * Close the piped log and kill the logging process
609 * @param pl The piped log structure
611 AP_DECLARE(void) ap_close_piped_log(piped_log *pl);
614 * A function to return the read side of the piped log pipe
615 * @param pl The piped log structure
616 * @return The native file descriptor
618 AP_DECLARE(apr_file_t *) ap_piped_log_read_fd(piped_log *pl);
621 * A function to return the write side of the piped log pipe
622 * @param pl The piped log structure
623 * @return The native file descriptor
625 AP_DECLARE(apr_file_t *) ap_piped_log_write_fd(piped_log *pl);
628 * hook method to log error messages
630 * @param file The file in which this function is called
631 * @param line The line number on which this function is called
632 * @param module_index The module_index of the module generating this message
633 * @param level The level of this error message
634 * @param status The status code from the previous command
635 * @param s The server which we are logging for
636 * @param r The request which we are logging for
637 * @param pool Memory pool to allocate from
638 * @param errstr message to log
640 AP_DECLARE_HOOK(void, error_log, (const char *file, int line,
641 int module_index, int level,
642 apr_status_t status, const server_rec *s,
643 const request_rec *r, apr_pool_t *pool,
647 * hook method to generate unique id for connection or request
649 * @param c the conn_rec of the connections
650 * @param r the request_req (may be NULL)
651 * @param id the place where to store the unique id
652 * @return OK or DECLINE
654 AP_DECLARE_HOOK(int, generate_log_id,
655 (const conn_rec *c, const request_rec *r, const char **id))
662 #endif /* !APACHE_HTTP_LOG_H */