http_log.h revision 2d2eda71267231c2526be701fe655db125852c1f
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony/* ====================================================================
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * Copyright (c) 1995-1999 The Apache Group. All rights reserved.
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony *
0a05fab9aadd37834734ffe106fc8ad4488fb3e3rbowen * Redistribution and use in source and binary forms, with or without
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * modification, are permitted provided that the following conditions
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * are met:
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony *
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * 1. Redistributions of source code must retain the above copyright
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * notice, this list of conditions and the following disclaimer.
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony *
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * 2. Redistributions in binary form must reproduce the above copyright
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * notice, this list of conditions and the following disclaimer in
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * the documentation and/or other materials provided with the
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * distribution.
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony *
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * 3. All advertising materials mentioning features or use of this
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * software must display the following acknowledgment:
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * "This product includes software developed by the Apache Group
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * for use in the Apache HTTP server project (http://www.apache.org/)."
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony *
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * 4. The names "Apache Server" and "Apache Group" must not be used to
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * endorse or promote products derived from this software without
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * prior written permission. For written permission, please contact
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * apache@apache.org.
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony *
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * 5. Products derived from this software may not be called "Apache"
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * nor may "Apache" appear in their names without prior written
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * permission of the Apache Group.
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony *
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * 6. Redistributions of any form whatsoever must retain the following
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * acknowledgment:
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * "This product includes software developed by the Apache Group
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * for use in the Apache HTTP server project (http://www.apache.org/)."
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony *
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
331e0914b4c54463a06069051f0245b4058a90c2nilgun * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
4d59c48d506af681afac46a88516e369495c1ae4nilgun * OF THE POSSIBILITY OF SUCH DAMAGE.
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun * ====================================================================
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun *
4d59c48d506af681afac46a88516e369495c1ae4nilgun * This software consists of voluntary contributions made by many
4d59c48d506af681afac46a88516e369495c1ae4nilgun * individuals on behalf of the Apache Group and was originally based
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun * on public domain software written at the National Center for
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun * Supercomputing Applications, University of Illinois, Urbana-Champaign.
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun * For more information on the Apache Group and the Apache HTTP server
4d59c48d506af681afac46a88516e369495c1ae4nilgun * project, please see <http://www.apache.org/>.
4d59c48d506af681afac46a88516e369495c1ae4nilgun *
4d59c48d506af681afac46a88516e369495c1ae4nilgun */
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun#ifndef APACHE_HTTP_LOG_H
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony#define APACHE_HTTP_LOG_H
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun#ifdef __cplusplus
243722a207c664dc2c62388a2095b1cba1fea3f0nilgunextern "C" {
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun#endif
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun#ifdef HAVE_SYSLOG
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun#include <syslog.h>
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony#define APLOG_EMERG LOG_EMERG /* system is unusable */
4d59c48d506af681afac46a88516e369495c1ae4nilgun#define APLOG_ALERT LOG_ALERT /* action must be taken immediately */
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun#define APLOG_CRIT LOG_CRIT /* critical conditions */
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun#define APLOG_ERR LOG_ERR /* error conditions */
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun#define APLOG_WARNING LOG_WARNING /* warning conditions */
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun#define APLOG_NOTICE LOG_NOTICE /* normal but significant condition */
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun#define APLOG_INFO LOG_INFO /* informational */
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun#define APLOG_DEBUG LOG_DEBUG /* debug-level messages */
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun#define APLOG_LEVELMASK LOG_PRIMASK /* mask off the level value */
4d59c48d506af681afac46a88516e369495c1ae4nilgun
4d59c48d506af681afac46a88516e369495c1ae4nilgun#else
4d59c48d506af681afac46a88516e369495c1ae4nilgun
4d59c48d506af681afac46a88516e369495c1ae4nilgun#define APLOG_EMERG 0 /* system is unusable */
4d59c48d506af681afac46a88516e369495c1ae4nilgun#define APLOG_ALERT 1 /* action must be taken immediately */
4d59c48d506af681afac46a88516e369495c1ae4nilgun#define APLOG_CRIT 2 /* critical conditions */
4d59c48d506af681afac46a88516e369495c1ae4nilgun#define APLOG_ERR 3 /* error conditions */
4d59c48d506af681afac46a88516e369495c1ae4nilgun#define APLOG_WARNING 4 /* warning conditions */
4d59c48d506af681afac46a88516e369495c1ae4nilgun#define APLOG_NOTICE 5 /* normal but significant condition */
4d59c48d506af681afac46a88516e369495c1ae4nilgun#define APLOG_INFO 6 /* informational */
4d59c48d506af681afac46a88516e369495c1ae4nilgun#define APLOG_DEBUG 7 /* debug-level messages */
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony#define APLOG_LEVELMASK 7 /* mask off the level value */
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony#endif
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony#define APLOG_NOERRNO (APLOG_LEVELMASK + 1)
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony#ifdef WIN32
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony/* Set to indicate that error msg should come from Win32's GetLastError(),
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * not errno. */
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony#define APLOG_WIN32ERROR ((APLOG_LEVELMASK+1) * 2)
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun#endif
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony#ifndef DEFAULT_LOGLEVEL
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony#define DEFAULT_LOGLEVEL APLOG_WARNING
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony#endif
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony#define APLOG_MARK __FILE__,__LINE__
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctonyvoid ap_open_logs (server_rec *, pool *p);
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony/* The two primary logging functions, ap_log_error and ap_log_rerror,
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * use a printf style format string to build the log message. It is
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * VERY IMPORTANT that you not include any raw data from the network,
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * such as the request-URI or request header fields, within the format
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * string. Doing so makes the server vulnerable to a denial-of-service
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * attack and other messy behavior. Instead, use a simple format string
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * like "%s", followed by the string containing the untrusted data.
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony */
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctonyAPI_EXPORT(void) ap_log_error(const char *file, int line, int level,
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony const server_rec *s, const char *fmt, ...)
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony __attribute__((format(printf,5,6)));
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctonyAPI_EXPORT(void) ap_log_rerror(const char *file, int line, int level,
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony const request_rec *s, const char *fmt, ...)
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony __attribute__((format(printf,5,6)));
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctonyAPI_EXPORT(void) ap_error_log2stderr (server_rec *);
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctonyvoid ap_log_pid (pool *p, char *fname);
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony/* These are for legacy code, new code should use ap_log_error,
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony * or ap_log_rerror.
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony */
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctonyAPI_EXPORT(void) ap_log_error_old(const char *err, server_rec *s);
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctonyAPI_EXPORT(void) ap_log_unixerr(const char *routine, const char *file,
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony const char *msg, server_rec *s);
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctonyAPI_EXPORT(void) ap_log_printf(const server_rec *s, const char *fmt, ...)
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony __attribute__((format(printf,2,3)));
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctonyAPI_EXPORT(void) ap_log_reason(const char *reason, const char *fname,
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony request_rec *r);
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctonytypedef struct piped_log {
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony pool *p;
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony#ifndef NO_RELIABLE_PIPED_LOGS
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony char *program;
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony int pid;
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony int fds[2];
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony#else
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony FILE *write_f;
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony#endif
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun} piped_log;
243722a207c664dc2c62388a2095b1cba1fea3f0nilgun
243722a207c664dc2c62388a2095b1cba1fea3f0nilgunAPI_EXPORT(piped_log *) ap_open_piped_log (pool *p, const char *program);
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctonyAPI_EXPORT(void) ap_close_piped_log (piped_log *);
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony#ifndef NO_RELIABLE_PIPED_LOGS
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony#define ap_piped_log_read_fd(pl) ((pl)->fds[0])
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony#define ap_piped_log_write_fd(pl) ((pl)->fds[1])
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony#else
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony#define ap_piped_log_read_fd(pl) (-1)
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony#define ap_piped_log_write_fd(pl) (fileno((pl)->write_f))
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony#endif
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony#ifdef __cplusplus
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony}
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony#endif
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony#endif /* !APACHE_HTTP_LOG_H */
4a7be288e6fc28a6cb940e26542dbf574bc907b9pctony