mirror of
https://github.com/apache/httpd.git
synced 2025-08-16 17:04:42 +00:00

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