mod_logio.c revision 006f13373cf0f653b41e98c8f7d2671a2010abc1
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Written by Bojan Smojver <bojan rexursive.com>.
*/
#include "apr_strings.h"
#include "apr_lib.h"
#include "apr_hash.h"
#include "apr_optional.h"
#define APR_WANT_STRFUNC
#include "apr_want.h"
#include "ap_config.h"
#include "mod_log_config.h"
#include "httpd.h"
#include "http_core.h"
#include "http_config.h"
#include "http_connection.h"
#include "http_protocol.h"
#include "http_request.h"
static const char logio_filter_name[] = "LOG_INPUT_OUTPUT";
/*
* Logging of input and output config...
*/
typedef struct logio_config_t {
request_rec *r; /* Use for TTFB only */
unsigned int first_byte_seen:1;
typedef struct logio_dirconf_t {
unsigned int track_ttfb:1;
/*
* Optional function for the core to add to bytes_out
*/
{
if (!cf->first_byte_seen) {
/* cleared during log_transaction, after mod_log_config */
if (cf->r) {
}
}
}
}
/*
* Optional function for modules to adjust bytes_in
*/
{
}
/*
* Optional function to get total byte count of last request for
* ap_increment_counts.
*/
{
return cf->bytes_last_request;
}
/*
* Format items...
*/
static const char *log_bytes_in(request_rec *r, char *a)
{
&logio_module);
}
static const char *log_bytes_out(request_rec *r, char *a)
{
&logio_module);
}
static const char *log_bytes_combined(request_rec *r, char *a)
{
&logio_module);
}
static const char *log_ttfb(request_rec *r, char *a)
{
&logio_module);
return "-";
}
}
/*
* Reset counters after logging...
*/
static int logio_transaction(request_rec *r)
{
&logio_module);
/* need to save byte count of last request for ap_increment_counts */
cf->first_byte_seen = 0;
return OK;
}
static int logio_post_read_request(request_rec *r)
{
&logio_module);
if (cf) {
cf->r = r;
}
return OK;
}
/*
* Logging of input filter...
*/
{
if (length > 0)
return status;
}
/*
* The hooks...
*/
{
return OK;
}
{
if (log_pfn_register) {
}
return OK;
}
{
return NULL;
}
{
return (void *) new;
}
static const command_rec logio_cmds[] = {
"Set to 'ON' to enable tracking time to first byte"),
{NULL}
};
static void register_hooks(apr_pool_t *p)
{
AP_FTYPE_NETWORK - 1);
}
{
create_logio_dirconf, /* create per-dir config */
NULL, /* merge per-dir config */
NULL, /* server config */
NULL, /* merge server config */
logio_cmds, /* command apr_table_t */
register_hooks /* register hooks */
};