Apache HTTPD
Classes | Macros | Typedefs | Functions | Variables
log.c File Reference
#include "apr.h"
#include "apr_general.h"
#include "apr_strings.h"
#include "apr_errno.h"
#include "apr_thread_proc.h"
#include "apr_lib.h"
#include "apr_signal.h"
#include "apr_portable.h"
#include "apr_base64.h"
#include "apr_want.h"
#include "ap_config.h"
#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
#include "http_log.h"
#include "http_main.h"
#include "util_time.h"
#include "ap_mpm.h"
#include "ap_listen.h"

Go to the source code of this file.

Classes

struct  TRANS
 
struct  read_handle_t
 
struct  piped_log
 The piped logging structure. More...
 

Macros

#define APR_WANT_STDIO
 
#define APR_WANT_STRFUNC
 
#define APLOG_MODULE_INDEX   AP_CORE_MODULE_INDEX
 
#define DEFAULT_LOG_TID   NULL
 
#define NULL_DEVICE   "/dev/null"
 
#define BYTES_LOGGED_PER_LINE   16
 
#define LOG_BYTES_BUFFER_SIZE   (BYTES_LOGGED_PER_LINE * 3 + 2)
 

Typedefs

typedef struct read_handle_t read_handle_t
 

Functions

apr_file_tap_piped_log_read_fd (piped_log *pl)
 
apr_file_tap_piped_log_write_fd (piped_log *pl)
 
static void close_handle_in_child (apr_pool_t *p, apr_file_t *f)
 
void ap_logs_child_init (apr_pool_t *p, server_rec *s)
 
void ap_open_stderr_log (apr_pool_t *p)
 
apr_status_t ap_replace_stderr_log (apr_pool_t *p, const char *fname)
 
static void log_child_errfn (apr_pool_t *pool, apr_status_t err, const char *description)
 
static int log_child (apr_pool_t *p, const char *progname, apr_file_t **fpin, apr_cmdtype_e cmdtype, int dummy_stderr)
 
static int open_error_log (server_rec *s, int is_main, apr_pool_t *p)
 
int ap_open_logs (apr_pool_t *pconf, apr_pool_t *p, apr_pool_t *ptemp, server_rec *s_main)
 
void ap_error_log2stderr (server_rec *s)
 
static int cpystrn (char *buf, const char *arg, int buflen)
 
static int log_remote_address (const ap_errorlog_info *info, const char *arg, char *buf, int buflen)
 
static int log_local_address (const ap_errorlog_info *info, const char *arg, char *buf, int buflen)
 
static int log_pid (const ap_errorlog_info *info, const char *arg, char *buf, int buflen)
 
static int log_tid (const ap_errorlog_info *info, const char *arg, char *buf, int buflen)
 
static int log_ctime (const ap_errorlog_info *info, const char *arg, char *buf, int buflen)
 
static int log_loglevel (const ap_errorlog_info *info, const char *arg, char *buf, int buflen)
 
static int log_log_id (const ap_errorlog_info *info, const char *arg, char *buf, int buflen)
 
static int log_keepalives (const ap_errorlog_info *info, const char *arg, char *buf, int buflen)
 
static int log_module_name (const ap_errorlog_info *info, const char *arg, char *buf, int buflen)
 
static int log_file_line (const ap_errorlog_info *info, const char *arg, char *buf, int buflen)
 
static int log_apr_status (const ap_errorlog_info *info, const char *arg, char *buf, int buflen)
 
static int log_server_name (const ap_errorlog_info *info, const char *arg, char *buf, int buflen)
 
static int log_virtual_host (const ap_errorlog_info *info, const char *arg, char *buf, int buflen)
 
static int log_table_entry (const apr_table_t *table, const char *name, char *buf, int buflen)
 
static int log_header (const ap_errorlog_info *info, const char *arg, char *buf, int buflen)
 
static int log_note (const ap_errorlog_info *info, const char *arg, char *buf, int buflen)
 
static int log_env_var (const ap_errorlog_info *info, const char *arg, char *buf, int buflen)
 
static int core_generate_log_id (const conn_rec *c, const request_rec *r, const char **idstring)
 
static void add_log_id (const conn_rec *c, const request_rec *r)
 
void ap_register_log_hooks (apr_pool_t *p)
 
static int do_errorlog_default (const ap_errorlog_info *info, char *buf, int buflen, int *errstr_start, int *errstr_end, const char *errstr_fmt, va_list args)
 
static int do_errorlog_format (apr_array_header_t *fmt, ap_errorlog_info *info, char *buf, int buflen, int *errstr_start, int *errstr_end, const char *err_fmt, va_list args)
 
static void write_logline (char *errstr, apr_size_t len, apr_file_t *logf, int level)
 
static void log_error_core (const char *file, int line, int module_index, int level, apr_status_t status, const server_rec *s, const conn_rec *c, const request_rec *r, apr_pool_t *pool, const char *fmt, va_list args)
 
static void log_error_va_glue (const char *file, int line, int module_index, int level, apr_status_t status, const server_rec *s, const conn_rec *c, const request_rec *r, apr_pool_t *pool, const char *fmt,...)
 
void ap_log_error_ (const char *file, int line, int module_index, int level, apr_status_t status, const server_rec *s, const char *fmt,...)
 
void ap_log_perror_ (const char *file, int line, int module_index, int level, apr_status_t status, apr_pool_t *p, const char *fmt,...)
 
void ap_log_rerror_ (const char *file, int line, int module_index, int level, apr_status_t status, const request_rec *r, const char *fmt,...)
 
void ap_log_cserror_ (const char *file, int line, int module_index, int level, apr_status_t status, const conn_rec *c, const server_rec *s, const char *fmt,...)
 
void ap_log_cerror_ (const char *file, int line, int module_index, int level, apr_status_t status, const conn_rec *c, const char *fmt,...)
 
static void fmt_data (unsigned char *buf, const void *vdata, apr_size_t len, apr_size_t *off)
 
static void log_data_core (const char *file, int line, int module_index, int level, const server_rec *s, const conn_rec *c, const request_rec *r, const char *label, const void *data, apr_size_t len, unsigned int flags)
 
void ap_log_data_ (const char *file, int line, int module_index, int level, const server_rec *s, const char *label, const void *data, apr_size_t len, unsigned int flags)
 
void ap_log_rdata_ (const char *file, int line, int module_index, int level, const request_rec *r, const char *label, const void *data, apr_size_t len, unsigned int flags)
 
void ap_log_cdata_ (const char *file, int line, int module_index, int level, const conn_rec *c, const char *label, const void *data, apr_size_t len, unsigned int flags)
 
void ap_log_csdata_ (const char *file, int line, int module_index, int level, const conn_rec *c, const server_rec *s, const char *label, const void *data, apr_size_t len, unsigned int flags)
 
void ap_log_command_line (apr_pool_t *plog, server_rec *s)
 
void ap_log_mpm_common (server_rec *s)
 
void ap_remove_pid (apr_pool_t *p, const char *rel_fname)
 
void ap_log_pid (apr_pool_t *p, const char *filename)
 
apr_status_t ap_read_pid (apr_pool_t *p, const char *filename, pid_t *mypid)
 
void ap_log_assert (const char *szExp, const char *szFile, int nLine)
 
static apr_status_t piped_log_cleanup (void *data)
 
piped_logap_open_piped_log_ex (apr_pool_t *p, const char *program, apr_cmdtype_e cmdtype)
 
piped_logap_open_piped_log (apr_pool_t *p, const char *program)
 
void ap_close_piped_log (piped_log *pl)
 
const charap_parse_log_level (const char *str, int *val)
 
void ap_hook_error_log (ap_HOOK_error_log_t *pf, const char *const *aszPre, const char *const *aszSucc, int nOrder)
 
apr_array_header_tap_hook_get_error_log (void)
 
void ap_run_error_log (const ap_errorlog_info *info, const char *errstr)
 
void ap_hook_generate_log_id (ap_HOOK_generate_log_id_t *pf, const char *const *aszPre, const char *const *aszSucc, int nOrder)
 
apr_array_header_tap_hook_get_generate_log_id (void)
 
int ap_run_generate_log_id (const conn_rec *c, const request_rec *r, const char **id)
 

Variables

struct { 
 
   apr_array_header_t *   link_error_log 
 
   apr_array_header_t *   link_generate_log_id 
 
_hooks 
 
int ap_default_loglevel = 4
 
static const TRANS priorities []
 
static apr_pool_tstderr_pool = NULL
 
static apr_file_tstderr_log = NULL
 
static read_handle_tread_handles
 

Macro Definition Documentation

◆ APLOG_MODULE_INDEX

#define APLOG_MODULE_INDEX   AP_CORE_MODULE_INDEX

Definition at line 65 of file log.c.

◆ APR_WANT_STDIO

#define APR_WANT_STDIO

Definition at line 34 of file log.c.

◆ APR_WANT_STRFUNC

#define APR_WANT_STRFUNC

Definition at line 35 of file log.c.

◆ BYTES_LOGGED_PER_LINE

#define BYTES_LOGGED_PER_LINE   16

Definition at line 1452 of file log.c.

◆ DEFAULT_LOG_TID

#define DEFAULT_LOG_TID   NULL

Definition at line 68 of file log.c.

◆ LOG_BYTES_BUFFER_SIZE

#define LOG_BYTES_BUFFER_SIZE   (BYTES_LOGGED_PER_LINE * 3 + 2)

Definition at line 1453 of file log.c.

◆ NULL_DEVICE

#define NULL_DEVICE   "/dev/null"

Typedef Documentation

◆ read_handle_t

Function Documentation

◆ add_log_id()

static void add_log_id ( const conn_rec c,
const request_rec r 
)
static

Definition at line 927 of file log.c.

◆ ap_log_cerror_()

void ap_log_cerror_ ( const char file,
int  line,
int  module_index,
int  level,
apr_status_t  status,
const conn_rec c,
const char fmt,
  ... 
)

Definition at line 1440 of file log.c.

◆ ap_log_cserror_()

void ap_log_cserror_ ( const char file,
int  line,
int  module_index,
int  level,
apr_status_t  status,
const conn_rec c,
const server_rec s,
const char fmt,
  ... 
)

Definition at line 1427 of file log.c.

◆ ap_log_error_()

void ap_log_error_ ( const char file,
int  line,
int  module_index,
int  level,
apr_status_t  status,
const server_rec s,
const char fmt,
  ... 
)

Definition at line 1374 of file log.c.

◆ ap_log_perror_()

void ap_log_perror_ ( const char file,
int  line,
int  module_index,
int  level,
apr_status_t  status,
apr_pool_t p,
const char fmt,
  ... 
)

Definition at line 1386 of file log.c.

◆ ap_log_rerror_()

void ap_log_rerror_ ( const char file,
int  line,
int  module_index,
int  level,
apr_status_t  status,
const request_rec r,
const char fmt,
  ... 
)

Definition at line 1398 of file log.c.

◆ close_handle_in_child()

static void close_handle_in_child ( apr_pool_t p,
apr_file_t f 
)
static

Definition at line 221 of file log.c.

◆ core_generate_log_id()

static int core_generate_log_id ( const conn_rec c,
const request_rec r,
const char **  idstring 
)
static

< Module has handled this stage.

Definition at line 876 of file log.c.

◆ cpystrn()

static int cpystrn ( char buf,
const char arg,
int  buflen 
)
static

Definition at line 588 of file log.c.

◆ do_errorlog_default()

static int do_errorlog_default ( const ap_errorlog_info info,
char buf,
int  buflen,
int errstr_start,
int errstr_end,
const char errstr_fmt,
va_list  args 
)
static

Definition at line 968 of file log.c.

◆ do_errorlog_format()

static int do_errorlog_format ( apr_array_header_t fmt,
ap_errorlog_info info,
char buf,
int  buflen,
int errstr_start,
int errstr_end,
const char err_fmt,
va_list  args 
)
static

Definition at line 1064 of file log.c.

◆ fmt_data()

static void fmt_data ( unsigned char buf,
const void *  vdata,
apr_size_t  len,
apr_size_t off 
)
static

Definition at line 1455 of file log.c.

◆ log_apr_status()

static int log_apr_status ( const ap_errorlog_info info,
const char arg,
char buf,
int  buflen 
)
static

Definition at line 783 of file log.c.

◆ log_child()

static int log_child ( apr_pool_t p,
const char progname,
apr_file_t **  fpin,
apr_cmdtype_e  cmdtype,
int  dummy_stderr 
)
static

Definition at line 314 of file log.c.

◆ log_child_errfn()

static void log_child_errfn ( apr_pool_t pool,
apr_status_t  err,
const char description 
)
static

Definition at line 302 of file log.c.

◆ log_ctime()

static int log_ctime ( const ap_errorlog_info info,
const char arg,
char buf,
int  buflen 
)
static

Definition at line 657 of file log.c.

◆ log_data_core()

static void log_data_core ( const char file,
int  line,
int  module_index,
int  level,
const server_rec s,
const conn_rec c,
const request_rec r,
const char label,
const void *  data,
apr_size_t  len,
unsigned int  flags 
)
static

Definition at line 1501 of file log.c.

◆ log_env_var()

static int log_env_var ( const ap_errorlog_info info,
const char arg,
char buf,
int  buflen 
)
static

Definition at line 867 of file log.c.

◆ log_error_core()

static void log_error_core ( const char file,
int  line,
int  module_index,
int  level,
apr_status_t  status,
const server_rec s,
const conn_rec c,
const request_rec r,
apr_pool_t pool,
const char fmt,
va_list  args 
)
static

Definition at line 1156 of file log.c.

◆ log_error_va_glue()

static void log_error_va_glue ( const char file,
int  line,
int  module_index,
int  level,
apr_status_t  status,
const server_rec s,
const conn_rec c,
const request_rec r,
apr_pool_t pool,
const char fmt,
  ... 
)
static

Definition at line 1360 of file log.c.

◆ log_file_line()

static int log_file_line ( const ap_errorlog_info info,
const char arg,
char buf,
int  buflen 
)
static

Definition at line 740 of file log.c.

◆ log_header()

static int log_header ( const ap_errorlog_info info,
const char arg,
char buf,
int  buflen 
)
static

Definition at line 848 of file log.c.

◆ log_keepalives()

static int log_keepalives ( const ap_errorlog_info info,
const char arg,
char buf,
int  buflen 
)
static

Definition at line 725 of file log.c.

◆ log_local_address()

static int log_local_address ( const ap_errorlog_info info,
const char arg,
char buf,
int  buflen 
)
static

Definition at line 611 of file log.c.

◆ log_log_id()

static int log_log_id ( const ap_errorlog_info info,
const char arg,
char buf,
int  buflen 
)
static

Definition at line 706 of file log.c.

◆ log_loglevel()

static int log_loglevel ( const ap_errorlog_info info,
const char arg,
char buf,
int  buflen 
)
static

Definition at line 697 of file log.c.

◆ log_module_name()

static int log_module_name ( const ap_errorlog_info info,
const char arg,
char buf,
int  buflen 
)
static

Definition at line 734 of file log.c.

◆ log_note()

static int log_note ( const ap_errorlog_info info,
const char arg,
char buf,
int  buflen 
)
static

Definition at line 857 of file log.c.

◆ log_pid()

static int log_pid ( const ap_errorlog_info info,
const char arg,
char buf,
int  buflen 
)
static

Definition at line 621 of file log.c.

◆ log_remote_address()

static int log_remote_address ( const ap_errorlog_info info,
const char arg,
char buf,
int  buflen 
)
static

Definition at line 598 of file log.c.

◆ log_server_name()

static int log_server_name ( const ap_errorlog_info info,
const char arg,
char buf,
int  buflen 
)
static

Definition at line 811 of file log.c.

◆ log_table_entry()

static int log_table_entry ( const apr_table_t table,
const char name,
char buf,
int  buflen 
)
static

Definition at line 830 of file log.c.

◆ log_tid()

static int log_tid ( const ap_errorlog_info info,
const char arg,
char buf,
int  buflen 
)
static

Definition at line 628 of file log.c.

◆ log_virtual_host()

static int log_virtual_host ( const ap_errorlog_info info,
const char arg,
char buf,
int  buflen 
)
static

Definition at line 820 of file log.c.

◆ open_error_log()

static int open_error_log ( server_rec s,
int  is_main,
apr_pool_t p 
)
static

< Module has served the response completely * - it's safe to die() with no more output

< Module has served the response completely * - it's safe to die() with no more output

< Append to the end of the file

<

Deprecated:
See also
APR_FOPEN_APPEND

< Open the file for writing

<

Deprecated:
See also
APR_FOPEN_WRITE

< Create the file if not there

<

Deprecated:
See also
APR_FOPEN_CREATE

< Platform dependent flag to enable * large file support, see WARNING below

<

Deprecated:
See also
APR_FOPEN_LARGEFILE

< use OS's default permissions

<

Deprecated:
See also
APR_FPROT_OS_DEFAULT

< Module has served the response completely * - it's safe to die() with no more output

< Module has handled this stage.

Definition at line 367 of file log.c.

◆ piped_log_cleanup()

static apr_status_t piped_log_cleanup ( void *  data)
static

Definition at line 1923 of file log.c.

◆ write_logline()

static void write_logline ( char errstr,
apr_size_t  len,
apr_file_t logf,
int  level 
)
static

Definition at line 1135 of file log.c.

Variable Documentation

◆ [struct]

struct { ... } _hooks

◆ link_error_log

apr_array_header_t* link_error_log

Definition at line 79 of file log.c.

◆ link_generate_log_id

apr_array_header_t* link_generate_log_id

Definition at line 79 of file log.c.

◆ priorities

const TRANS priorities[]
static
Initial value:
= {
{"emerg", 0 },
{"alert", 1 },
{"crit", 2 },
{"error", 3 },
{"warn", 4 },
{"notice", 5 },
{"info", 6 },
{"debug", 7 },
{"trace1", 8 },
{"trace2", 9 },
{"trace3", 10 },
{"trace4", 11 },
{"trace5", 12 },
{"trace6", 13 },
{"trace7", 14 },
{"trace8", 15 },
{NULL, -1},
}
return NULL
Definition mod_so.c:359

Definition at line 148 of file log.c.

◆ read_handles

read_handle_t* read_handles
static

Definition at line 178 of file log.c.

◆ stderr_log

apr_file_t* stderr_log = NULL
static

Definition at line 170 of file log.c.

◆ stderr_pool

apr_pool_t* stderr_pool = NULL
static

Definition at line 168 of file log.c.