http_log.h revision f062ed7bd262a37a909dd77ce5fc23b446818823
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd/* ====================================================================
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * The Apache Software License, Version 1.1
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd *
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * Copyright (c) 2000 The Apache Software Foundation. All rights
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * reserved.
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd *
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * Redistribution and use in source and binary forms, with or without
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * modification, are permitted provided that the following conditions
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * are met:
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd *
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * 1. Redistributions of source code must retain the above copyright
2e545ce2450a9953665f701bb05350f0d3f26275nd * notice, this list of conditions and the following disclaimer.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen *
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * 2. Redistributions in binary form must reproduce the above copyright
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * notice, this list of conditions and the following disclaimer in
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * the documentation and/or other materials provided with the
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen * distribution.
3f08db06526d6901aa08c110b5bc7dde6bc39905nd *
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * 3. The end-user documentation included with the redistribution,
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * if any, must include the following acknowledgment:
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * "This product includes software developed by the
3f08db06526d6901aa08c110b5bc7dde6bc39905nd * Apache Software Foundation (http://www.apache.org/)."
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * Alternately, this acknowledgment may appear in the software itself,
9472e4d3c410be3b3f1addbf3b1db1769f64e765nd * if and wherever such third-party acknowledgments normally appear.
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd *
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * 4. The names "Apache" and "Apache Software Foundation" must
7f5b59ccc63c0c0e3e678a168f09ee6a2f51f9d0nd * not be used to endorse or promote products derived from this
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * software without prior written permission. For written
fac8c35bfb158112226ab43ddf84d59daca5dc30nd * permission, please contact apache@apache.org.
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung *
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * 5. Products derived from this software may not be called "Apache",
4b575a6b6704b516f22d65a3ad35696d7b9ba372rpluem * nor may "Apache" appear in their name, without prior written
4b575a6b6704b516f22d65a3ad35696d7b9ba372rpluem * permission of the Apache Software Foundation.
4b575a6b6704b516f22d65a3ad35696d7b9ba372rpluem *
4b575a6b6704b516f22d65a3ad35696d7b9ba372rpluem * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * SUCH DAMAGE.
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * ====================================================================
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd *
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh * This software consists of voluntary contributions made by many
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * individuals on behalf of the Apache Software Foundation. For more
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * information on the Apache Software Foundation, please see
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * <http://www.apache.org/>.
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd *
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * Portions of this software are based upon public domain software
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * originally written at the National Center for Supercomputing Applications,
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * University of Illinois, Urbana-Champaign.
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd */
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#ifndef APACHE_HTTP_LOG_H
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#define APACHE_HTTP_LOG_H
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#ifdef __cplusplus
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34ndextern "C" {
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#endif
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#include "apr_thread_proc.h"
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#ifdef HAVE_SYSLOG
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#include <syslog.h>
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#define APLOG_EMERG LOG_EMERG /* system is unusable */
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#define APLOG_ALERT LOG_ALERT /* action must be taken immediately */
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#define APLOG_CRIT LOG_CRIT /* critical conditions */
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#define APLOG_ERR LOG_ERR /* error conditions */
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#define APLOG_WARNING LOG_WARNING /* warning conditions */
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#define APLOG_NOTICE LOG_NOTICE /* normal but significant condition */
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#define APLOG_INFO LOG_INFO /* informational */
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#define APLOG_DEBUG LOG_DEBUG /* debug-level messages */
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#define APLOG_LEVELMASK LOG_PRIMASK /* mask off the level value */
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#else
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#define APLOG_EMERG 0 /* system is unusable */
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#define APLOG_ALERT 1 /* action must be taken immediately */
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#define APLOG_CRIT 2 /* critical conditions */
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#define APLOG_ERR 3 /* error conditions */
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#define APLOG_WARNING 4 /* warning conditions */
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#define APLOG_NOTICE 5 /* normal but significant condition */
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#define APLOG_INFO 6 /* informational */
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#define APLOG_DEBUG 7 /* debug-level messages */
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#define APLOG_LEVELMASK 7 /* mask off the level value */
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#endif
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#define APLOG_NOERRNO (APLOG_LEVELMASK + 1)
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd/* normal but significant condition on startup, usually printed to stderr */
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#define APLOG_STARTUP ((APLOG_LEVELMASK + 1) * 4)
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#ifndef DEFAULT_LOGLEVEL
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#define DEFAULT_LOGLEVEL APLOG_WARNING
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#endif
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#define APLOG_MARK __FILE__,__LINE__
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34ndvoid ap_open_logs (server_rec *, ap_context_t *p);
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd/* The two primary logging functions, ap_log_error and ap_log_rerror,
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * use a printf style format string to build the log message. It is
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * VERY IMPORTANT that you not include any raw data from the network,
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * such as the request-URI or request header fields, within the format
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * string. Doing so makes the server vulnerable to a denial-of-service
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * attack and other messy behavior. Instead, use a simple format string
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * like "%s", followed by the string containing the untrusted data.
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd */
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34ndAPI_EXPORT(void) ap_log_error(const char *file, int line, int level,
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd ap_status_t status, const server_rec *s,
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd const char *fmt, ...)
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd __attribute__((format(printf,6,7)));
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34ndAPI_EXPORT(void) ap_log_rerror(const char *file, int line, int level,
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd ap_status_t status, const request_rec *s,
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd const char *fmt, ...)
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd __attribute__((format(printf,6,7)));
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34ndAPI_EXPORT(void) ap_error_log2stderr (server_rec *);
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34ndvoid ap_log_pid (ap_context_t *p, const char *fname);
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd/* These are for legacy code, new code should use ap_log_error,
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * or ap_log_rerror.
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd */
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34ndAPI_EXPORT(void) ap_log_error_old(const char *err, server_rec *s);
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34ndAPI_EXPORT(void) ap_log_unixerr(const char *routine, const char *file,
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd const char *msg, server_rec *s);
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34ndAPI_EXPORT(void) ap_log_printf(const server_rec *s, const char *fmt, ...)
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd __attribute__((format(printf,2,3)));
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34ndAPI_EXPORT(void) ap_log_reason(const char *reason, const char *fname,
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd request_rec *r);
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34ndtypedef struct piped_log {
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd ap_context_t *p;
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd ap_file_t *fds[2];
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd /* XXX - an #ifdef that needs to be eliminated from public view. Shouldn't
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd * be hard */
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#ifdef HAVE_RELIABLE_PIPED_LOGS
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd char *program;
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd ap_proc_t *pid;
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#endif
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd} piped_log;
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34ndAPI_EXPORT(piped_log *) ap_open_piped_log (ap_context_t *p, const char *program);
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34ndAPI_EXPORT(void) ap_close_piped_log (piped_log *);
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#define ap_piped_log_read_fd(pl) ((pl)->fds[0])
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#define ap_piped_log_write_fd(pl) ((pl)->fds[1])
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#ifdef __cplusplus
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd}
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#endif
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd#endif /* !APACHE_HTTP_LOG_H */
97a3ecc40b65d5f8e865bbe0b1c9325d8c016e34nd