1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-01 07:26:57 +03:00

Replace DumpIOLogLevel with trace log levels

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@951902 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stefan Fritsch
2010-06-06 17:08:57 +00:00
parent 41057afadc
commit 8f1e26cc21
2 changed files with 17 additions and 63 deletions

View File

@ -43,9 +43,16 @@
<section id="enable"> <section id="enable">
<title>Enabling dumpio Support</title> <title>Enabling dumpio Support</title>
<p>To enable the module, it should be compiled and <p>To enable the module, it should be compiled and loaded
loaded in to your running Apache configuration. Logging in to your running Apache configuration. Logging can then
can then be enabled or disabled via the below directives.</p> be enabled or disabled seperately for input and output via
the below directives. Additionally, <module>mod_dumpio</module>
needs to be configured to <directive
module="core">LogLevel</directive> <code>trace7</code>:
</p>
<example>
LogLevel dumpio:trace7
</example>
</section> </section>
<directivesynopsis> <directivesynopsis>
@ -88,28 +95,4 @@ later.</compatibility>
</directivesynopsis> </directivesynopsis>
<directivesynopsis>
<name>DumpIOLogLevel</name>
<description>Controls the logging level of the DumpIO output</description>
<syntax>DumpIOLogLevel <var>level</var></syntax>
<default>DumpIOLogLevel debug</default>
<contextlist><context>server config</context></contextlist>
<compatibility>DumpIOLogLevel is only available in Apache 2.2.4 and
later.</compatibility>
<usage>
<p>Enable dumping of all output at a specific <directive
module="core">LogLevel</directive> level.</p>
<example><title>Example</title>
DumpIOLogLevel notice
</example>
<note><title>Compatibility</title>Prior to 2.2.4 <module>mod_dumpio</module>
would only dump to the log when <directive
module="core">LogLevel</directive> was set to <code>debug</code></note>
</usage>
</directivesynopsis>
</modulesynopsis> </modulesynopsis>

View File

@ -39,7 +39,6 @@ module AP_MODULE_DECLARE_DATA dumpio_module ;
typedef struct dumpio_conf_t { typedef struct dumpio_conf_t {
int enable_input; int enable_input;
int enable_output; int enable_output;
int loglevel;
} dumpio_conf_t; } dumpio_conf_t;
/* consider up to 80 additional characters, and factor the longest /* consider up to 80 additional characters, and factor the longest
@ -56,7 +55,7 @@ static void dumpit(ap_filter_t *f, apr_bucket *b, dumpio_conf_t *ptr)
{ {
conn_rec *c = f->c; conn_rec *c = f->c;
ap_log_error(APLOG_MARK, ptr->loglevel, 0, c->base_server, ap_log_error(APLOG_MARK, APLOG_TRACE7, 0, c->base_server,
"mod_dumpio: %s (%s-%s): %" APR_SIZE_T_FMT " bytes", "mod_dumpio: %s (%s-%s): %" APR_SIZE_T_FMT " bytes",
f->frec->name, f->frec->name,
(APR_BUCKET_IS_METADATA(b)) ? "metadata" : "data", (APR_BUCKET_IS_METADATA(b)) ? "metadata" : "data",
@ -86,7 +85,7 @@ static void dumpit(ap_filter_t *f, apr_bucket *b, dumpio_conf_t *ptr)
memcpy(xlatebuf, buf, logbytes); memcpy(xlatebuf, buf, logbytes);
ap_xlate_proto_from_ascii(xlatebuf, logbytes); ap_xlate_proto_from_ascii(xlatebuf, logbytes);
xlatebuf[logbytes] = '\0'; xlatebuf[logbytes] = '\0';
ap_log_error(APLOG_MARK, ptr->loglevel, 0, c->base_server, ap_log_error(APLOG_MARK, APLOG_TRACE7, 0, c->base_server,
"mod_dumpio: %s (%s-%s): %s", f->frec->name, "mod_dumpio: %s (%s-%s): %s", f->frec->name,
(APR_BUCKET_IS_METADATA(b)) ? "metadata" : "data", (APR_BUCKET_IS_METADATA(b)) ? "metadata" : "data",
b->type->name, xlatebuf); b->type->name, xlatebuf);
@ -99,14 +98,14 @@ static void dumpit(ap_filter_t *f, apr_bucket *b, dumpio_conf_t *ptr)
* within ap_log_error, and introduce new vformatter %-escapes * within ap_log_error, and introduce new vformatter %-escapes
* for escaping text, and for binary text (fixed len strings). * for escaping text, and for binary text (fixed len strings).
*/ */
ap_log_error(APLOG_MARK | APLOG_NOERRNO, ptr->loglevel, 0, c->base_server, ap_log_error(APLOG_MARK | APLOG_NOERRNO, APLOG_TRACE7, 0, c->base_server,
"mod_dumpio: %s (%s-%s): %.*s", f->frec->name, "mod_dumpio: %s (%s-%s): %.*s", f->frec->name,
(APR_BUCKET_IS_METADATA(b)) ? "metadata" : "data", (APR_BUCKET_IS_METADATA(b)) ? "metadata" : "data",
b->type->name, (int)logbytes, buf); b->type->name, (int)logbytes, buf);
#endif #endif
} }
} else { } else {
ap_log_error(APLOG_MARK, ptr->loglevel, rv, c->base_server, ap_log_error(APLOG_MARK, APLOG_TRACE7, rv, c->base_server,
"mod_dumpio: %s (%s-%s): %s", f->frec->name, "mod_dumpio: %s (%s-%s): %s", f->frec->name,
(APR_BUCKET_IS_METADATA(b)) ? "metadata" : "data", (APR_BUCKET_IS_METADATA(b)) ? "metadata" : "data",
b->type->name, "error reading data"); b->type->name, "error reading data");
@ -132,7 +131,7 @@ static int dumpio_input_filter (ap_filter_t *f, apr_bucket_brigade *bb,
conn_rec *c = f->c; conn_rec *c = f->c;
dumpio_conf_t *ptr = f->ctx; dumpio_conf_t *ptr = f->ctx;
ap_log_error(APLOG_MARK, ptr->loglevel, 0, c->base_server, ap_log_error(APLOG_MARK, APLOG_TRACE7, 0, c->base_server,
"mod_dumpio: %s [%s-%s] %" APR_OFF_T_FMT " readbytes", "mod_dumpio: %s [%s-%s] %" APR_OFF_T_FMT " readbytes",
f->frec->name, f->frec->name,
whichmode(mode), whichmode(mode),
@ -146,7 +145,7 @@ static int dumpio_input_filter (ap_filter_t *f, apr_bucket_brigade *bb,
dumpit(f, b, ptr); dumpit(f, b, ptr);
} }
} else { } else {
ap_log_error(APLOG_MARK, ptr->loglevel, 0, c->base_server, ap_log_error(APLOG_MARK, APLOG_TRACE7, 0, c->base_server,
"mod_dumpio: %s - %d", f->frec->name, ret) ; "mod_dumpio: %s - %d", f->frec->name, ret) ;
} }
@ -159,7 +158,7 @@ static int dumpio_output_filter (ap_filter_t *f, apr_bucket_brigade *bb)
conn_rec *c = f->c; conn_rec *c = f->c;
dumpio_conf_t *ptr = f->ctx; dumpio_conf_t *ptr = f->ctx;
ap_log_error(APLOG_MARK, ptr->loglevel, 0, c->base_server, "mod_dumpio: %s", f->frec->name) ; ap_log_error(APLOG_MARK, APLOG_TRACE7, 0, c->base_server, "mod_dumpio: %s", f->frec->name) ;
for (b = APR_BRIGADE_FIRST(bb); b != APR_BRIGADE_SENTINEL(bb); b = APR_BUCKET_NEXT(b)) { for (b = APR_BRIGADE_FIRST(bb); b != APR_BRIGADE_SENTINEL(bb); b = APR_BUCKET_NEXT(b)) {
/* /*
@ -207,7 +206,6 @@ static void *dumpio_create_sconfig(apr_pool_t *p, server_rec *s)
{ {
dumpio_conf_t *ptr = apr_pcalloc(p, sizeof *ptr); dumpio_conf_t *ptr = apr_pcalloc(p, sizeof *ptr);
ptr->enable_input = ptr->enable_output = 0; ptr->enable_input = ptr->enable_output = 0;
ptr->loglevel = APLOG_DEBUG;
return ptr; return ptr;
} }
@ -231,38 +229,11 @@ static const char *dumpio_enable_output(cmd_parms *cmd, void *dummy, int arg)
return NULL; return NULL;
} }
static const char *set_loglevel(cmd_parms *cmd, void *dummy, const char *arg)
{
char *str;
dumpio_conf_t *ptr =
(dumpio_conf_t *) ap_get_module_config(cmd->server->module_config,
&dumpio_module);
const char *err = ap_check_cmd_context(cmd,
NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
if (err != NULL) {
return err;
}
if ((str = ap_getword_conf(cmd->pool, &arg))) {
err = ap_parse_log_level(str, &ptr->loglevel);
if (err != NULL)
return apr_psprintf(cmd->pool, "DumpIOLogLevel: %s", err);
}
else {
return "DumpIOLogLevel requires level keyword";
}
return NULL;
}
static const command_rec dumpio_cmds[] = { static const command_rec dumpio_cmds[] = {
AP_INIT_FLAG("DumpIOInput", dumpio_enable_input, NULL, AP_INIT_FLAG("DumpIOInput", dumpio_enable_input, NULL,
RSRC_CONF, "Enable I/O Dump on Input Data"), RSRC_CONF, "Enable I/O Dump on Input Data"),
AP_INIT_FLAG("DumpIOOutput", dumpio_enable_output, NULL, AP_INIT_FLAG("DumpIOOutput", dumpio_enable_output, NULL,
RSRC_CONF, "Enable I/O Dump on Output Data"), RSRC_CONF, "Enable I/O Dump on Output Data"),
AP_INIT_TAKE1("DumpIOLogLevel", set_loglevel, NULL, RSRC_CONF,
"Level at which DumpIO info is logged"),
{ NULL } { NULL }
}; };