Apache HTTPD
Classes | Macros | Functions | Variables
mod_log_config.c File Reference
#include "apr_strings.h"
#include "apr_lib.h"
#include "apr_hash.h"
#include "apr_optional.h"
#include "apr_anylock.h"
#include "apr_want.h"
#include "ap_config.h"
#include "mod_log_config.h"
#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
#include "http_log.h"
#include "http_protocol.h"
#include "util_time.h"
#include "ap_mpm.h"

Go to the source code of this file.

Classes

struct  multi_log_state
 
struct  buffered_log
 
struct  config_log_state
 
struct  log_request_state
 
struct  log_format_item
 
struct  cached_request_time
 

Macros

#define APR_WANT_STRFUNC
 
#define DEFAULT_LOG_FORMAT   "%h %l %u %t \"%r\" %>s %b"
 
#define LOG_BUFSIZE   (512)
 
#define DEFAULT_REQUEST_TIME_SIZE   32
 
#define TIME_FMT_CUSTOM   0
 
#define TIME_FMT_CLF   1
 
#define TIME_FMT_ABS_SEC   2
 
#define TIME_FMT_ABS_MSEC   3
 
#define TIME_FMT_ABS_USEC   4
 
#define TIME_FMT_ABS_MSEC_FRAC   5
 
#define TIME_FMT_ABS_USEC_FRAC   6
 
#define TIME_CACHE_SIZE   4
 
#define TIME_CACHE_MASK   3
 

Functions

static apr_status_t ap_default_log_writer (request_rec *r, void *handle, const char **strs, int *strl, int nelts, apr_size_t len)
 
static apr_status_t ap_buffered_log_writer (request_rec *r, void *handle, const char **strs, int *strl, int nelts, apr_size_t len)
 
static void * ap_default_log_writer_init (apr_pool_t *p, server_rec *s, const char *name)
 
static void * ap_buffered_log_writer_init (apr_pool_t *p, server_rec *s, const char *name)
 
static ap_log_writer_initap_log_set_writer_init (ap_log_writer_init *handle)
 
static ap_log_writerap_log_set_writer (ap_log_writer *handle)
 
static charpfmt (apr_pool_t *p, int i)
 
static const charconstant_item (request_rec *dummy, char *stuff)
 
static const charlog_remote_host (request_rec *r, char *a)
 
static const charlog_remote_address (request_rec *r, char *a)
 
static const charlog_local_address (request_rec *r, char *a)
 
static const charlog_remote_logname (request_rec *r, char *a)
 
static const charlog_remote_user (request_rec *r, char *a)
 
static const charlog_request_line (request_rec *r, char *a)
 
static const charlog_request_file (request_rec *r, char *a)
 
static const charlog_request_uri (request_rec *r, char *a)
 
static const charlog_request_method (request_rec *r, char *a)
 
static const charlog_log_id (request_rec *r, char *a)
 
static const charlog_request_protocol (request_rec *r, char *a)
 
static const charlog_request_query (request_rec *r, char *a)
 
static const charlog_status (request_rec *r, char *a)
 
static const charlog_handler (request_rec *r, char *a)
 
static const charclf_log_bytes_sent (request_rec *r, char *a)
 
static const charlog_bytes_sent (request_rec *r, char *a)
 
static const charlog_header_in (request_rec *r, char *a)
 
static const charlog_trailer_in (request_rec *r, char *a)
 
static APR_INLINE charfind_multiple_headers (apr_pool_t *pool, const apr_table_t *table, const char *key)
 
static const charlog_header_out (request_rec *r, char *a)
 
static const charlog_trailer_out (request_rec *r, char *a)
 
static const charlog_note (request_rec *r, char *a)
 
static const charlog_env_var (request_rec *r, char *a)
 
static const charlog_cookie (request_rec *r, char *a)
 
static const charlog_request_time_custom (request_rec *r, char *a, apr_time_exp_t *xt)
 
static apr_time_t get_request_end_time (request_rec *r)
 
static const charlog_request_time (request_rec *r, char *a)
 
static const charlog_request_duration_microseconds (request_rec *r, char *a)
 
static const charlog_request_duration_scaled (request_rec *r, char *a)
 
static const charlog_virtual_host (request_rec *r, char *a)
 
static const charlog_server_port (request_rec *r, char *a)
 
static const charlog_server_name (request_rec *r, char *a)
 
static const charlog_pid_tid (request_rec *r, char *a)
 
static const charlog_connection_status (request_rec *r, char *a)
 
static const charlog_requests_on_connection (request_rec *r, char *a)
 
static charparse_log_misc_string (apr_pool_t *p, log_format_item *it, const char **sa)
 
static charparse_log_item (apr_pool_t *p, log_format_item *it, const char **sa)
 
static apr_array_header_tparse_log_string (apr_pool_t *p, const char *s, const char **err)
 
static const charprocess_item (request_rec *r, request_rec *orig, log_format_item *item)
 
static void flush_log (buffered_log *buf)
 
static int config_log_transaction (request_rec *r, config_log_state *cls, apr_array_header_t *default_format)
 
static int multi_log_transaction (request_rec *r)
 
static void * make_config_log_state (apr_pool_t *p, server_rec *s)
 
static void * merge_config_log_state (apr_pool_t *p, void *basev, void *addv)
 
static const charlog_format (cmd_parms *cmd, void *dummy, const char *fmt, const char *name)
 
static const charadd_custom_log (cmd_parms *cmd, void *dummy, const char *fn, const char *fmt, const char *envclause)
 
static const charadd_global_log (cmd_parms *cmd, void *dummy, const char *fn, const char *fmt, const char *envclause)
 
static const charset_transfer_log (cmd_parms *cmd, void *dummy, const char *fn)
 
static const charset_buffered_logs_on (cmd_parms *parms, void *dummy, int flag)
 
static config_log_stateopen_config_log (server_rec *s, apr_pool_t *p, config_log_state *cls, apr_array_header_t *default_format)
 
static int open_multi_logs (server_rec *s, apr_pool_t *p)
 
static apr_status_t flush_all_logs (void *data)
 
static int init_config_log (apr_pool_t *pc, apr_pool_t *p, apr_pool_t *pt, server_rec *s)
 
static void init_child (apr_pool_t *p, server_rec *s)
 
static void ap_register_log_handler (apr_pool_t *p, char *tag, ap_log_handler_fn_t *handler, int def)
 
static int log_pre_config (apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp)
 
static int check_log_dir (apr_pool_t *p, server_rec *s, config_log_state *cls)
 
static int log_check_config (apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
 
static void register_hooks (apr_pool_t *p)
 

Variables

static int xfer_flags = ( 0x00002 | 0x00008 | 0x00004 | 0x04000 )
 
static apr_fileperms_t xfer_perms = 0x0FFF
 
static apr_hash_tlog_hash
 
static ap_log_writerlog_writer = ap_default_log_writer
 
static ap_log_writer_initlog_writer_init = ap_default_log_writer_init
 
static int buffered_logs = 0
 
static apr_array_header_tall_buffered_logs = NULL
 
static cached_request_time request_time_cache [4]
 
static const command_rec config_log_cmds []
 
static int *const aplog_module_index = &( log_config_module.module_index)
 

Macro Definition Documentation

◆ APR_WANT_STRFUNC

#define APR_WANT_STRFUNC

Definition at line 155 of file mod_log_config.c.

◆ DEFAULT_LOG_FORMAT

#define DEFAULT_LOG_FORMAT   "%h %l %u %t \"%r\" %>s %b"

Definition at line 175 of file mod_log_config.c.

◆ DEFAULT_REQUEST_TIME_SIZE

#define DEFAULT_REQUEST_TIME_SIZE   32

Definition at line 609 of file mod_log_config.c.

◆ LOG_BUFSIZE

#define LOG_BUFSIZE   (512)

Definition at line 219 of file mod_log_config.c.

◆ TIME_CACHE_MASK

#define TIME_CACHE_MASK   3

Definition at line 625 of file mod_log_config.c.

◆ TIME_CACHE_SIZE

#define TIME_CACHE_SIZE   4

Definition at line 624 of file mod_log_config.c.

◆ TIME_FMT_ABS_MSEC

#define TIME_FMT_ABS_MSEC   3

Definition at line 619 of file mod_log_config.c.

◆ TIME_FMT_ABS_MSEC_FRAC

#define TIME_FMT_ABS_MSEC_FRAC   5

Definition at line 621 of file mod_log_config.c.

◆ TIME_FMT_ABS_SEC

#define TIME_FMT_ABS_SEC   2

Definition at line 618 of file mod_log_config.c.

◆ TIME_FMT_ABS_USEC

#define TIME_FMT_ABS_USEC   4

Definition at line 620 of file mod_log_config.c.

◆ TIME_FMT_ABS_USEC_FRAC

#define TIME_FMT_ABS_USEC_FRAC   6

Definition at line 622 of file mod_log_config.c.

◆ TIME_FMT_CLF

#define TIME_FMT_CLF   1

Definition at line 617 of file mod_log_config.c.

◆ TIME_FMT_CUSTOM

#define TIME_FMT_CUSTOM   0

Definition at line 616 of file mod_log_config.c.

Function Documentation

◆ add_custom_log()

static const char * add_custom_log ( cmd_parms cmd,
void *  dummy,
const char fn,
const char fmt,
const char envclause 
)
static

Definition at line 1294 of file mod_log_config.c.

◆ add_global_log()

static const char * add_global_log ( cmd_parms cmd,
void *  dummy,
const char fn,
const char fmt,
const char envclause 
)
static

< Forbidden in <VirtualHost>

< Forbidden in <Limit>

< Forbidden in <Directory>

< Forbidden in <Location>

< Forbidden in <Files> or <If>

< Forbidden in <Proxy>

Definition at line 1342 of file mod_log_config.c.

◆ ap_buffered_log_writer()

static apr_status_t ap_buffered_log_writer ( request_rec r,
void *  handle,
const char **  strs,
int strl,
int  nelts,
apr_size_t  len 
)
static

Definition at line 1678 of file mod_log_config.c.

◆ ap_buffered_log_writer_init()

static void * ap_buffered_log_writer_init ( apr_pool_t p,
server_rec s,
const char name 
)
static

Definition at line 1664 of file mod_log_config.c.

◆ ap_default_log_writer()

static apr_status_t ap_default_log_writer ( request_rec r,
void *  handle,
const char **  strs,
int strl,
int  nelts,
apr_size_t  len 
)
static

Definition at line 1605 of file mod_log_config.c.

◆ ap_default_log_writer_init()

static void * ap_default_log_writer_init ( apr_pool_t p,
server_rec s,
const char name 
)
static

Definition at line 1633 of file mod_log_config.c.

◆ ap_log_set_writer()

static ap_log_writer * ap_log_set_writer ( ap_log_writer handle)
static

Definition at line 1597 of file mod_log_config.c.

◆ ap_log_set_writer_init()

static ap_log_writer_init * ap_log_set_writer_init ( ap_log_writer_init handle)
static

Definition at line 1589 of file mod_log_config.c.

◆ ap_register_log_handler()

static void ap_register_log_handler ( apr_pool_t p,
char tag,
ap_log_handler_fn_t handler,
int  def 
)
static

Definition at line 1580 of file mod_log_config.c.

◆ check_log_dir()

static int check_log_dir ( apr_pool_t p,
server_rec s,
config_log_state cls 
)
static

< Module has handled this stage.

< Type

< Module has handled this stage.

< Module has handled this stage.

Definition at line 1778 of file mod_log_config.c.

◆ clf_log_bytes_sent()

static const char * clf_log_bytes_sent ( request_rec r,
char a 
)
static

Definition at line 418 of file mod_log_config.c.

◆ config_log_transaction()

static int config_log_transaction ( request_rec r,
config_log_state cls,
apr_array_header_t default_format 
)
static

< Module declines to handle

< Module declines to handle

< Module declines to handle

< Module declines to handle

< Module has handled this stage.

Definition at line 1109 of file mod_log_config.c.

◆ constant_item()

static const char * constant_item ( request_rec dummy,
char stuff 
)
static

Definition at line 305 of file mod_log_config.c.

◆ find_multiple_headers()

static APR_INLINE char * find_multiple_headers ( apr_pool_t pool,
const apr_table_t table,
const char key 
)
static

Definition at line 450 of file mod_log_config.c.

◆ flush_all_logs()

static apr_status_t flush_all_logs ( void *  data)
static

Definition at line 1484 of file mod_log_config.c.

◆ flush_log()

static void flush_log ( buffered_log buf)
static

Definition at line 1099 of file mod_log_config.c.

◆ get_request_end_time()

static apr_time_t get_request_end_time ( request_rec r)
static

Definition at line 628 of file mod_log_config.c.

◆ init_child()

static void init_child ( apr_pool_t p,
server_rec s 
)
static

Definition at line 1540 of file mod_log_config.c.

◆ init_config_log()

static int init_config_log ( apr_pool_t pc,
apr_pool_t p,
apr_pool_t pt,
server_rec s 
)
static

< Module has handled this stage.

Definition at line 1517 of file mod_log_config.c.

◆ log_bytes_sent()

static const char * log_bytes_sent ( request_rec r,
char a 
)
static

Definition at line 428 of file mod_log_config.c.

◆ log_check_config()

static int log_check_config ( apr_pool_t pconf,
apr_pool_t plog,
apr_pool_t ptemp,
server_rec s 
)
static

< Module has handled this stage.

< Module has handled this stage.

< Module has handled this stage.

Definition at line 1804 of file mod_log_config.c.

◆ log_connection_status()

static const char * log_connection_status ( request_rec r,
char a 
)
static

Definition at line 857 of file mod_log_config.c.

◆ log_cookie()

static const char * log_cookie ( request_rec r,
char a 
)
static

Definition at line 547 of file mod_log_config.c.

◆ log_env_var()

static const char * log_env_var ( request_rec r,
char a 
)
static

Definition at line 542 of file mod_log_config.c.

◆ log_format()

static const char * log_format ( cmd_parms cmd,
void *  dummy,
const char fmt,
const char name 
)
static

Definition at line 1268 of file mod_log_config.c.

◆ log_handler()

static const char * log_handler ( request_rec r,
char a 
)
static

Definition at line 413 of file mod_log_config.c.

◆ log_header_in()

static const char * log_header_in ( request_rec r,
char a 
)
static

Definition at line 439 of file mod_log_config.c.

◆ log_header_out()

static const char * log_header_out ( request_rec r,
char a 
)
static

Definition at line 516 of file mod_log_config.c.

◆ log_local_address()

static const char * log_local_address ( request_rec r,
char a 
)
static

Definition at line 333 of file mod_log_config.c.

◆ log_log_id()

static const char * log_log_id ( request_rec r,
char a 
)
static

Definition at line 389 of file mod_log_config.c.

◆ log_note()

static const char * log_note ( request_rec r,
char a 
)
static

Definition at line 538 of file mod_log_config.c.

◆ log_pid_tid()

static const char * log_pid_tid ( request_rec r,
char a 
)
static

Definition at line 838 of file mod_log_config.c.

◆ log_pre_config()

static int log_pre_config ( apr_pool_t p,
apr_pool_t plog,
apr_pool_t ptemp 
)
static

< Module has handled this stage.

Definition at line 1728 of file mod_log_config.c.

◆ log_remote_address()

static const char * log_remote_address ( request_rec r,
char a 
)
static

Definition at line 323 of file mod_log_config.c.

◆ log_remote_host()

static const char * log_remote_host ( request_rec r,
char a 
)
static

Definition at line 310 of file mod_log_config.c.

◆ log_remote_logname()

static const char * log_remote_logname ( request_rec r,
char a 
)
static

Definition at line 338 of file mod_log_config.c.

◆ log_remote_user()

static const char * log_remote_user ( request_rec r,
char a 
)
static

Definition at line 343 of file mod_log_config.c.

◆ log_request_duration_microseconds()

static const char * log_request_duration_microseconds ( request_rec r,
char a 
)
static

Definition at line 778 of file mod_log_config.c.

◆ log_request_duration_scaled()

static const char * log_request_duration_scaled ( request_rec r,
char a 
)
static

Definition at line 784 of file mod_log_config.c.

◆ log_request_file()

static const char * log_request_file ( request_rec r,
char a 
)
static

Definition at line 377 of file mod_log_config.c.

◆ log_request_line()

static const char * log_request_line ( request_rec r,
char a 
)
static

Definition at line 360 of file mod_log_config.c.

◆ log_request_method()

static const char * log_request_method ( request_rec r,
char a 
)
static

Definition at line 385 of file mod_log_config.c.

◆ log_request_protocol()

static const char * log_request_protocol ( request_rec r,
char a 
)
static

Definition at line 398 of file mod_log_config.c.

◆ log_request_query()

static const char * log_request_query ( request_rec r,
char a 
)
static

Definition at line 402 of file mod_log_config.c.

◆ log_request_time()

static const char * log_request_time ( request_rec r,
char a 
)
static

Definition at line 643 of file mod_log_config.c.

◆ log_request_time_custom()

static const char * log_request_time_custom ( request_rec r,
char a,
apr_time_exp_t xt 
)
static

Definition at line 600 of file mod_log_config.c.

◆ log_request_uri()

static const char * log_request_uri ( request_rec r,
char a 
)
static

Definition at line 381 of file mod_log_config.c.

◆ log_requests_on_connection()

static const char * log_requests_on_connection ( request_rec r,
char a 
)
static

Definition at line 870 of file mod_log_config.c.

◆ log_server_name()

static const char * log_server_name ( request_rec r,
char a 
)
static

Definition at line 833 of file mod_log_config.c.

◆ log_server_port()

static const char * log_server_port ( request_rec r,
char a 
)
static

Definition at line 810 of file mod_log_config.c.

◆ log_status()

static const char * log_status ( request_rec r,
char a 
)
static

Definition at line 408 of file mod_log_config.c.

◆ log_trailer_in()

static const char * log_trailer_in ( request_rec r,
char a 
)
static

Definition at line 444 of file mod_log_config.c.

◆ log_trailer_out()

static const char * log_trailer_out ( request_rec r,
char a 
)
static

Definition at line 533 of file mod_log_config.c.

◆ log_virtual_host()

static const char * log_virtual_host ( request_rec r,
char a 
)
static

Definition at line 805 of file mod_log_config.c.

◆ make_config_log_state()

static void * make_config_log_state ( apr_pool_t p,
server_rec s 
)
static

Definition at line 1229 of file mod_log_config.c.

◆ merge_config_log_state()

static void * merge_config_log_state ( apr_pool_t p,
void *  basev,
void *  addv 
)
static

Definition at line 1250 of file mod_log_config.c.

◆ multi_log_transaction()

static int multi_log_transaction ( request_rec r)
static

< Module has handled this stage.

Definition at line 1185 of file mod_log_config.c.

◆ open_config_log()

static config_log_state * open_config_log ( server_rec s,
apr_pool_t p,
config_log_state cls,
apr_array_header_t default_format 
)
static

Definition at line 1404 of file mod_log_config.c.

◆ open_multi_logs()

static int open_multi_logs ( server_rec s,
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

< Module has handled this stage.

Definition at line 1423 of file mod_log_config.c.

◆ parse_log_item()

static char * parse_log_item ( apr_pool_t p,
log_format_item it,
const char **  sa 
)
static

Definition at line 943 of file mod_log_config.c.

◆ parse_log_misc_string()

static char * parse_log_misc_string ( apr_pool_t p,
log_format_item it,
const char **  sa 
)
static

Definition at line 881 of file mod_log_config.c.

◆ parse_log_string()

static apr_array_header_t * parse_log_string ( apr_pool_t p,
const char s,
const char **  err 
)
static

Definition at line 1046 of file mod_log_config.c.

◆ pfmt()

static char * pfmt ( apr_pool_t p,
int  i 
)
static

Definition at line 295 of file mod_log_config.c.

◆ process_item()

static const char * process_item ( request_rec r,
request_rec orig,
log_format_item item 
)
static

Definition at line 1068 of file mod_log_config.c.

◆ register_hooks()

static void register_hooks ( apr_pool_t p)
static

Definition at line 1827 of file mod_log_config.c.

◆ set_buffered_logs_on()

static const char * set_buffered_logs_on ( cmd_parms parms,
void *  dummy,
int  flag 
)
static

Definition at line 1375 of file mod_log_config.c.

◆ set_transfer_log()

static const char * set_transfer_log ( cmd_parms cmd,
void *  dummy,
const char fn 
)
static

Definition at line 1369 of file mod_log_config.c.

Variable Documentation

◆ all_buffered_logs

apr_array_header_t* all_buffered_logs = NULL
static

Definition at line 205 of file mod_log_config.c.

◆ aplog_module_index

int* const aplog_module_index = &( log_config_module.module_index)
static

Definition at line 1847 of file mod_log_config.c.

◆ buffered_logs

int buffered_logs = 0
static

Definition at line 204 of file mod_log_config.c.

◆ config_log_cmds

const command_rec config_log_cmds[]
static
Initial value:
=
{
{ "CustomLog" , add_custom_log , NULL , 128 , TAKE23, "a file name, a custom log format string or format name, " "and an optional \"env=\" or \"expr=\" clause (see docs)" },
{ "GlobalLog" , add_global_log , NULL , 128 , TAKE23, "Same as CustomLog, but forces virtualhosts to inherit the log" },
{ "TransferLog" , set_transfer_log , NULL , 128 , TAKE1, "the filename of the access log" },
{ "LogFormat" , log_format , NULL , 128 , TAKE12, "a log format string (see docs) and an optional format name" },
{ "BufferedLogs" , set_buffered_logs_on , NULL , 128 , FLAG, "Enable Buffered Logging (experimental)" },
{NULL}
}
@ TAKE12
Definition http_config.h:61
@ TAKE1
Definition http_config.h:51
@ TAKE23
Definition http_config.h:63
@ FLAG
Definition http_config.h:59
static const char * log_format(cmd_parms *cmd, void *dummy, const char *fmt, const char *name)
static const char * set_transfer_log(cmd_parms *cmd, void *dummy, const char *fn)
static const char * set_buffered_logs_on(cmd_parms *parms, void *dummy, int flag)
static const char * add_global_log(cmd_parms *cmd, void *dummy, const char *fn, const char *fmt, const char *envclause)
static const char * add_custom_log(cmd_parms *cmd, void *dummy, const char *fn, const char *fmt, const char *envclause)
return NULL
Definition mod_so.c:359

Definition at line 1388 of file mod_log_config.c.

◆ log_hash

apr_hash_t* log_hash
static

Definition at line 182 of file mod_log_config.c.

◆ log_writer

ap_log_writer* log_writer = ap_default_log_writer
static

Definition at line 202 of file mod_log_config.c.

◆ log_writer_init

Definition at line 203 of file mod_log_config.c.

◆ request_time_cache

cached_request_time request_time_cache[4]
static

Definition at line 626 of file mod_log_config.c.

◆ xfer_flags

int xfer_flags = ( 0x00002 | 0x00008 | 0x00004 | 0x04000 )
static

Definition at line 180 of file mod_log_config.c.

◆ xfer_perms

apr_fileperms_t xfer_perms = 0x0FFF
static

use OS's default permissions

Deprecated:
See also
APR_FPROT_OS_DEFAULT

Definition at line 181 of file mod_log_config.c.