http_log.h revision 497c60d05c62d2e4a37b0a0c002f62cd5824b4e3
458N/A/* Copyright 1999-2004 Apache Software Foundation
458N/A *
458N/A * Licensed under the Apache License, Version 2.0 (the "License");
458N/A * you may not use this file except in compliance with the License.
458N/A * You may obtain a copy of the License at
458N/A *
458N/A * http://www.apache.org/licenses/LICENSE-2.0
458N/A *
458N/A * Unless required by applicable law or agreed to in writing, software
458N/A * distributed under the License is distributed on an "AS IS" BASIS,
458N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
458N/A * See the License for the specific language governing permissions and
458N/A * limitations under the License.
458N/A */
458N/A
458N/A#ifndef APACHE_HTTP_LOG_H
458N/A#define APACHE_HTTP_LOG_H
458N/A
458N/A#ifdef __cplusplus
458N/Aextern "C" {
2833N/A#endif
458N/A
458N/A#include "apr_thread_proc.h"
458N/A
458N/A/**
458N/A * @package Apache logging library
458N/A */
458N/A
2833N/A#ifdef HAVE_SYSLOG
618N/A#include <syslog.h>
458N/A
2833N/A#ifndef LOG_PRIMASK
844N/A#define LOG_PRIMASK 7
2833N/A#endif
618N/A
1258N/A#define APLOG_EMERG LOG_EMERG /* system is unusable */
458N/A#define APLOG_ALERT LOG_ALERT /* action must be taken immediately */
458N/A#define APLOG_CRIT LOG_CRIT /* critical conditions */
458N/A#define APLOG_ERR LOG_ERR /* error conditions */
458N/A#define APLOG_WARNING LOG_WARNING /* warning conditions */
581N/A#define APLOG_NOTICE LOG_NOTICE /* normal but significant condition */
458N/A#define APLOG_INFO LOG_INFO /* informational */
1567N/A#define APLOG_DEBUG LOG_DEBUG /* debug-level messages */
1567N/A
1567N/A#define APLOG_LEVELMASK LOG_PRIMASK /* mask off the level value */
1567N/A
1567N/A#else
458N/A
458N/A#define APLOG_EMERG 0 /* system is unusable */
458N/A#define APLOG_ALERT 1 /* action must be taken immediately */
458N/A#define APLOG_CRIT 2 /* critical conditions */
969N/A#define APLOG_ERR 3 /* error conditions */
969N/A#define APLOG_WARNING 4 /* warning conditions */
969N/A#define APLOG_NOTICE 5 /* normal but significant condition */
969N/A#define APLOG_INFO 6 /* informational */
969N/A#define APLOG_DEBUG 7 /* debug-level messages */
969N/A
969N/A#define APLOG_LEVELMASK 7 /* mask off the level value */
458N/A
458N/A#endif
969N/A
969N/A/* APLOG_NOERRNO is ignored and should not be used. It will be
458N/A * removed in a future release of Apache.
458N/A */
458N/A#define APLOG_NOERRNO (APLOG_LEVELMASK + 1)
458N/A
458N/A/* Use APLOG_TOCLIENT on ap_log_rerror() to give content
458N/A * handlers the option of including the error text in the
458N/A * ErrorDocument sent back to the client. Setting APLOG_TOCLIENT
458N/A * will cause the error text to be saved in the request_rec->notes
458N/A * table, keyed to the string "error-notes", if and only if:
458N/A * - the severity level of the message is APLOG_WARNING or greater
646N/A * - there are no other "error-notes" set in request_rec->notes
646N/A * Once error-notes is set, it is up to the content handler to
646N/A * determine whether this text should be sent back to the client.
646N/A * Note: Client generated text streams sent back to the client MUST
646N/A * be escaped to prevent CSS attacks.
646N/A */
646N/A#define APLOG_TOCLIENT ((APLOG_LEVELMASK + 1) * 2)
1091N/A
646N/A/* normal but significant condition on startup, usually printed to stderr */
646N/A#define APLOG_STARTUP ((APLOG_LEVELMASK + 1) * 4)
646N/A
646N/A#ifndef DEFAULT_LOGLEVEL
458N/A#define DEFAULT_LOGLEVEL APLOG_WARNING
458N/A#endif
458N/A
458N/Aextern int AP_DECLARE_DATA ap_default_loglevel;
458N/A
581N/A#define APLOG_MARK __FILE__,__LINE__
581N/A
581N/A/**
458N/A * Set up for logging to stderr.
458N/A * @param p The pool to allocate out of
458N/A */
458N/AAP_DECLARE(void) ap_open_stderr_log(apr_pool_t *p);
458N/A
458N/A/**
458N/A * Replace logging to stderr with logging to the given file.
458N/A * @param p The pool to allocate out of
969N/A * @param file Name of the file to log stderr output
458N/A */
646N/AAP_DECLARE(apr_status_t) ap_replace_stderr_log(apr_pool_t *p,
458N/A const char *file);
458N/A
646N/A/**
458N/A * Open the error log and replace stderr with it.
458N/A * @param pconf Not used
458N/A * @param plog The pool to allocate the logs from
458N/A * @param ptemp Pool used for temporary allocations
1567N/A * @param s_main The main server
1567N/A * @tip ap_open_logs isn't expected to be used by modules, it is
1567N/A * an internal core function
1567N/A */
1567N/Aint ap_open_logs(apr_pool_t *pconf, apr_pool_t *plog,
1567N/A apr_pool_t *ptemp, server_rec *s_main);
1567N/A
1567N/A/*
1567N/A * The three primary logging functions, ap_log_error, ap_log_rerror, and
458N/A * ap_log_perror use a printf style format string to build the log message.
1699N/A * It is VERY IMPORTANT that you not include any raw data from the network,
1699N/A * such as the request-URI or request header fields, within the format
1567N/A * string. Doing so makes the server vulnerable to a denial-of-service
1567N/A * attack and other messy behavior. Instead, use a simple format string
1567N/A * like "%s", followed by the string containing the untrusted data.
458N/A */
458N/A
1567N/A/**
1567N/A * One of the primary logging routines in Apache. This uses a printf-like
1567N/A * format to log messages to the error_log.
1567N/A * @param file The file in which this function is called
1567N/A * @param line The line number on which this function is called
1567N/A * @param level The level of this error message
1567N/A * @param status The status code from the previous command
1567N/A * @param s The server on which we are logging
1567N/A * @param fmt The format string
1567N/A * @param ... The arguments to use to fill out fmt.
1567N/A * @tip Use APLOG_MARK to fill out file and line
1567N/A * @warning It is VERY IMPORTANT that you not include any raw data from
458N/A * the network, such as the request-URI or request header fields, within
458N/A * the format string. Doing so makes the server vulnerable to a
1567N/A * denial-of-service attack and other messy behavior. Instead, use a
458N/A * simple format string like "%s", followed by the string containing the
458N/A * untrusted data.
458N/A * @deffunc void ap_log_error(const char *file, int line, int level, apr_status_t status, const server_rec *s, const char *fmt, ...)
458N/A */
AP_DECLARE(void) ap_log_error(const char *file, int line, int level,
apr_status_t status, const server_rec *s,
const char *fmt, ...)
__attribute__((format(printf,6,7)));
/**
* The second of the primary logging routines in Apache. This uses
* a printf-like format to log messages to the error_log.
* @param file The file in which this function is called
* @param line The line number on which this function is called
* @param level The level of this error message
* @param status The status code from the previous command
* @param p The pool which we are logging for
* @param fmt The format string
* @param ... The arguments to use to fill out fmt.
* @tip Use APLOG_MARK to fill out file and line
* @warning 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.
* @deffunc void ap_log_perror(const char *file, int line, int level, apr_status_t status, apr_pool_t *p, const char *fmt, ...)
*/
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)));
/**
* The last of the primary logging routines in Apache. This uses
* a printf-like format to log messages to the error_log.
* @param file The file in which this function is called
* @param line The line number on which this function is called
* @param level The level of this error message
* @param status The status code from the previous command
* @param s The request which we are logging for
* @param fmt The format string
* @param ... The arguments to use to fill out fmt.
* @tip Use APLOG_MARK to fill out file and line
* @warning 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.
* @deffunc void ap_log_rerror(const char *file, int line, int level, apr_status_t status, request_rec *r, const char *fmt, ...)
*/
AP_DECLARE(void) ap_log_rerror(const char *file, int line, int level,
apr_status_t status, const request_rec *r,
const char *fmt, ...)
__attribute__((format(printf,6,7)));
/**
* Convert stderr to the error log
* @param s The current server
* @deffunc void ap_error_log2stderr(server_rec *s)
*/
AP_DECLARE(void) ap_error_log2stderr(server_rec *s);
/**
* Log the current pid of the parent process
* @param p The pool to use for logging
* @param fname The name of the file to log to
*/
AP_DECLARE(void) ap_log_pid(apr_pool_t *p, const char *fname);
/**
* Retrieve the pid from a pidfile.
* @param p The pool to use for logging
* @param filename The name of the file containing the pid
* @param mypid Pointer to pid_t (valid only if return APR_SUCCESS)
*/
AP_DECLARE(apr_status_t) ap_read_pid(apr_pool_t *p, const char *filename, pid_t *mypid);
typedef struct piped_log piped_log;
/**
* The piped logging structure. Piped logs are used to move functionality
* out of the main server. For example, log rotation is done with piped logs.
*/
struct piped_log {
/** The pool to use for the piped log */
apr_pool_t *p;
/** The pipe between the server and the logging process */
apr_file_t *fds[2];
/* XXX - an #ifdef that needs to be eliminated from public view. Shouldn't
* be hard */
#ifdef AP_HAVE_RELIABLE_PIPED_LOGS
/** The name of the program the logging process is running */
char *program;
/** The pid of the logging process */
apr_proc_t *pid;
#endif
};
/**
* Open the piped log process
* @param p The pool to allocate out of
* @param program The program to run in the logging process
* @return The piped log structure
* @deffunc piped_log *ap_open_piped_log(apr_pool_t *p, const char *program)
*/
AP_DECLARE(piped_log *) ap_open_piped_log(apr_pool_t *p, const char *program);
/**
* Close the piped log and kill the logging process
* @param pl The piped log structure
* @deffunc void ap_close_piped_log(piped_log *pl)
*/
AP_DECLARE(void) ap_close_piped_log(piped_log *pl);
/**
* A macro to access the read side of the piped log pipe
* @param pl The piped log structure
* @return The native file descriptor
* @deffunc ap_piped_log_read_fd(pl)
*/
#define ap_piped_log_read_fd(pl) ((pl)->fds[0])
/**
* A macro to access the write side of the piped log pipe
* @param pl The piped log structure
* @return The native file descriptor
* @deffunc ap_piped_log_read_fd(pl)
*/
#define ap_piped_log_write_fd(pl) ((pl)->fds[1])
AP_DECLARE_HOOK(void, error_log, (const char *file, int line, int level,
apr_status_t status, const server_rec *s,
const request_rec *r, apr_pool_t *pool,
const char *errstr))
#ifdef __cplusplus
}
#endif
#endif /* !APACHE_HTTP_LOG_H */