From apache-cvs-return-2888-apmail-apache-cvs-archive=apache.org@apache.org Tue Sep 26 19:38:54 2000
Return-Path:
Delivered-To: apmail-apache-cvs-archive@apache.org
Received: (qmail 56843 invoked by uid 500); 26 Sep 2000 19:38:50 -0000
Mailing-List: contact apache-cvs-help@apache.org; run by ezmlm
Precedence: bulk
Reply-To: new-httpd@apache.org
list-help:
list-unsubscribe:
list-post:
Delivered-To: mailing list apache-cvs@apache.org
Received: (qmail 56818 invoked by uid 500); 26 Sep 2000 19:38:46 -0000
Delivered-To: apmail-apache-2.0-cvs@apache.org
Date: 26 Sep 2000 19:38:44 -0000
Message-ID: <20000926193844.56806.qmail@locus.apache.org>
From: trawick@locus.apache.org
To: apache-2.0-cvs@apache.org
Subject: cvs commit: apache-2.0/src/modules/experimental mod_charset_lite.c
trawick 00/09/26 12:38:43
Modified: htdocs/manual/mod directives.html mod_charset_lite.html
src/modules/experimental mod_charset_lite.c
Log:
Debug messages in mod_charset_lite are now controlled by
CharsetOptions DebugLevel=n instead of CharsetDebug on/off. Use the debug
level to decide which debug messages to issue (if any). Use ap_log_rerror()
instead of ap_log_error() when appropriate.
Describe CharsetOptions in the doc.
Revision Changes Path
1.67 +1 -1 httpd-docs-2.0/htdocs/manual/mod/directives.html
Index: directives.html
===================================================================
RCS file: /home/cvs/httpd-docs-2.0/htdocs/manual/mod/directives.html,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -r1.66 -r1.67
--- directives.html 2000/09/12 15:16:51 1.66
+++ directives.html 2000/09/26 19:38:34 1.67
@@ -81,9 +81,9 @@
CacheNegotiatedDocs
CacheRoot
CacheSize
-CharsetDebug
CharsetDefault
CharsetSourceEnc
+CharsetOptions
CheckSpelling
ClearModuleList
ContentDigest
1.3 +25 -8 httpd-docs-2.0/htdocs/manual/mod/mod_charset_lite.html
Index: mod_charset_lite.html
===================================================================
RCS file: /home/cvs/httpd-docs-2.0/htdocs/manual/mod/mod_charset_lite.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- mod_charset_lite.html 2000/06/03 00:17:19 1.2
+++ mod_charset_lite.html 2000/09/26 19:38:35 1.3
@@ -52,7 +52,7 @@
@@ -178,17 +178,17 @@
-
+
Syntax: CharsetDebug on/off
+ >Syntax: CharsetOptions option option ...
Default: off
+ >Default: DebugLevel=0 NoImplicitAdd
Compatibility: Only available in Apache 2.0 or later
- The CharsetDebug directive specifies whether or not
- verbose logging should be performed by mod_charset_lite.
- Such logging is written to the Apache error log with level
- debug.
+ The CharsetOptions directive configures certain behaviors
+ of mod_charset_lite. Option can be one of
+
+ - DebugLevel=n
+
-
+ The DebugLevel keyword allows you to specify the level of
+ debug messages generated by
mod_charset_lite. By default, no
+ messages are generated. This is equivalent to DebugLevel=0.
+ With higher numbers, more debug messages are generated, and server
+ performance will be degraded. The actual meanings of the numeric values
+ are described with the definitions of the DBGLVL_ constants near the
+ beginning of mod_charset_lite.c.
+ - ImplicitAdd | NoImplicitAdd
+
-
+ The ImplicitAdd keyword specifies that
+
mod_charset_lite should implicitly insert its filter when
+ the configuration specifies that the character set of content should be
+ translated. If the filter chain is explicitly configured using the
+ AddOutputFilter directive, NoImplicitAdd should be specified so
+ that mod_charset_lite doesn't add its filter.
+
Common Problems
1.21 +66 -73 apache-2.0/src/modules/experimental/mod_charset_lite.c
Index: mod_charset_lite.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/modules/experimental/mod_charset_lite.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- mod_charset_lite.c 2000/09/26 15:08:26 1.20
+++ mod_charset_lite.c 2000/09/26 19:38:41 1.21
@@ -105,8 +105,8 @@
#define XLATEOUT_FILTER_NAME "XLATEOUT" /* registered name of the translation filter */
typedef struct charset_dir_t {
- enum {NO_DEBUG = 1, DEBUG} debug; /* whether or not verbose logging is enabled; 0
- means uninitialized */
+ /** debug level; -1 means uninitialized, 0 means no debug */
+ int debug;
const char *charset_source; /* source encoding */
const char *charset_default; /* how to ship on wire */
enum {IA_INIT, IA_IMPADD, IA_NOIMPADD} implicit_add; /* tmp hack! module does ap_add_filter()? */
@@ -135,11 +135,20 @@
charset_filter_ctx_t *output_ctx, *input_ctx;
} charset_req_t;
+/* debug level definitions */
+#define DBGLVL_GORY 9 /* gory details */
+#define DBGLVL_FLOW 4 /* enough messages to see what happens on
+ * each request */
+#define DBGLVL_PMC 2 /* messages about possible misconfiguration */
+
module charset_lite_module;
static void *create_charset_dir_conf(apr_pool_t *p,char *dummy)
{
- return apr_pcalloc(p,sizeof(charset_dir_t));
+ charset_dir_t *dc = (charset_dir_t *)apr_pcalloc(p,sizeof(charset_dir_t));
+
+ dc->debug = -1;
+ return dc;
}
static void *merge_charset_dir_conf(apr_pool_t *p, void *basev, void *overridesv)
@@ -153,7 +162,7 @@
*/
a->debug =
- over->debug ? over->debug : base->debug;
+ over->debug != -1 ? over->debug : base->debug;
a->charset_default =
over->charset_default ? over->charset_default : base->charset_default;
a->charset_source =
@@ -185,22 +194,6 @@
return NULL;
}
-/* CharsetDebug on/off
- */
-static const char *add_charset_debug(cmd_parms *cmd, void *in_dc, int arg)
-{
- charset_dir_t *dc = in_dc;
-
- if (arg) {
- dc->debug = DEBUG;
- }
- else {
- dc->debug = NO_DEBUG;
- }
-
- return NULL;
-}
-
/* CharsetOptions optionflag...
*/
static const char *add_charset_options(cmd_parms *cmd, void *in_dc,
@@ -214,6 +207,9 @@
else if (!strcasecmp(flag, "NoImplicitAdd")) {
dc->implicit_add = IA_NOIMPADD;
}
+ else if (!strncasecmp(flag, "DebugLevel=", 11)) {
+ dc->debug = atoi(flag + 11);
+ }
else {
return apr_pstrcat(cmd->temp_pool,
"Invalid CharsetOptions option: ",
@@ -236,27 +232,27 @@
charset_filter_ctx_t *input_ctx, *output_ctx;
apr_status_t rv;
const char *mime_type;
- int debug = dc->debug == DEBUG;
- if (debug) {
- ap_log_error(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO, 0, r->server,
- "Entering handler, URI: %s FILENAME: %s METHOD: %d ARGS: %s PATH_INFO: %s "
- "MIMETYPE: %s FLAGS: %d SUBREQ: %s, REDIR: %s, PROXY: %s",
- r->uri, r->filename, r->method_number, r->args, r->path_info,
- r->content_type ? r->content_type : "(unknown)",
- r->rrx ? 1 : 0,
- r->main?"YES":"NO",r->prev?"YES":"NO",
- r->proxyreq ? "YES" : "NO");
+ if (dc->debug >= DBGLVL_FLOW) {
+ ap_log_rerror(APLOG_MARK,APLOG_DEBUG|APLOG_NOERRNO, 0, r,
+ "uri: %s file: %s method: %d "
+ "imt: %s flags: %s%s%s %s->%s",
+ r->uri, r->filename, r->method_number,
+ r->content_type ? r->content_type : "(unknown)",
+ r->main ? "S" : "", /* S if subrequest */
+ r->prev ? "R" : "", /* R if redirect */
+ r->proxyreq ? "P" : "", /* P if proxy */
+ dc->charset_source, dc->charset_default);
}
/* If we don't have a full directory configuration, bail out.
*/
if (!dc->charset_source || !dc->charset_default) {
- if (debug) {
- ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server,
- "incomplete configuration: src %s, dst %s",
- dc->charset_source ? dc->charset_source : "unspecified",
- dc->charset_default ? dc->charset_default : "unspecified");
+ if (dc->debug >= DBGLVL_PMC) {
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r,
+ "incomplete configuration: src %s, dst %s",
+ dc->charset_source ? dc->charset_source : "unspecified",
+ dc->charset_default ? dc->charset_default : "unspecified");
}
return DECLINED;
}
@@ -275,20 +271,20 @@
*/
if (strncasecmp(mime_type, "text/", 5) &&
strncasecmp(mime_type, "message/", 8)) {
- if (debug) {
- ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server,
- "mime type is %s; no translation selected",
- mime_type);
+ if (dc->debug >= DBGLVL_GORY) {
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r,
+ "mime type is %s; no translation selected",
+ mime_type);
}
return DECLINED;
}
- if (debug) {
- ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server,
- "dc: %X charset_source: %s charset_default: %s",
- (unsigned)dc,
- dc && dc->charset_source ? dc->charset_source : "(none)",
- dc && dc->charset_default ? dc->charset_default : "(none)");
+ if (dc->debug >= DBGLVL_GORY) {
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r,
+ "dc: %X charset_source: %s charset_default: %s",
+ (unsigned)dc,
+ dc && dc->charset_source ? dc->charset_source : "(none)",
+ dc && dc->charset_default ? dc->charset_default : "(none)");
}
/* Get storage for the request data and the output filter context.
@@ -307,9 +303,9 @@
rv = apr_xlate_open(&output_ctx->xlate,
dc->charset_default, dc->charset_source, r->pool);
if (rv != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
- "can't open translation %s->%s",
- dc->charset_source, dc->charset_default);
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
+ "can't open translation %s->%s",
+ dc->charset_source, dc->charset_default);
return HTTP_INTERNAL_SERVER_ERROR;
}
@@ -326,17 +322,17 @@
rv = apr_xlate_open(&input_ctx->xlate, dc->charset_source,
dc->charset_default, r->pool);
if (rv != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
- "can't open translation %s->%s",
- dc->charset_default, dc->charset_source);
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
+ "can't open translation %s->%s",
+ dc->charset_default, dc->charset_source);
return HTTP_INTERNAL_SERVER_ERROR;
}
/* Can't delete this yet :( #ifdef OLD */
rv = ap_set_content_xlate(r, 0, input_ctx->xlate);
if (rv != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
- "can't set content input translation");
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
+ "can't set content input translation");
return HTTP_INTERNAL_SERVER_ERROR;
}
/* #endif */
@@ -355,15 +351,16 @@
&charset_lite_module);
charset_dir_t *dc = ap_get_module_config(r->per_dir_config,
&charset_lite_module);
- int debug = dc->debug == DEBUG;
- if (debug) {
- ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server,
- "xlate_insert_filter() - "
- "dc: %X charset_source: %s charset_default: %s",
- (unsigned)dc,
- dc && dc->charset_source ? dc->charset_source : "(none)",
- dc && dc->charset_default ? dc->charset_default : "(none)");
+ if (dc->debug >= DBGLVL_GORY) {
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r,
+ "xlate_insert_filter() - "
+ "dc: %X charset_source: %s charset_default: %s "
+ "reqinfo %p impadd %d",
+ (unsigned)dc,
+ dc && dc->charset_source ? dc->charset_source : "(none)",
+ dc && dc->charset_default ? dc->charset_default : "(none)",
+ reqinfo, (int)dc->implicit_add);
}
if (reqinfo &&
@@ -549,7 +546,7 @@
{
ap_filter_t *curf;
charset_filter_ctx_t *curctx, *last_xlate_ctx = NULL;
- int debug = ((charset_filter_ctx_t *)f->ctx)->dc->debug == DEBUG;
+ int debug = ((charset_filter_ctx_t *)f->ctx)->dc->debug;
/* walk the filter chain; see if it makes sense for our filter to
* do any translation
@@ -578,12 +575,14 @@
*/
if (last_xlate_ctx == f->ctx) {
last_xlate_ctx->noop = 1;
- if (debug) {
+ if (debug >= DBGLVL_PMC) {
ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO,
0, f->r,
- "chk_filter_chain() - disabling "
+ "%s %s - disabling "
"translation %s->%s; existing "
"translation %s->%s",
+ f->r->uri ? "uri" : "file",
+ f->r->uri ? f->r->uri : f->r->filename,
last_xlate_ctx->dc->charset_source,
last_xlate_ctx->dc->charset_default,
curctx->dc->charset_source,
@@ -621,7 +620,6 @@
&charset_lite_module);
charset_dir_t *dc = reqinfo->dc;
charset_filter_ctx_t *ctx = f->ctx;
- int debug = dc->debug == DEBUG;
ap_bucket *dptr, *consumed_bucket;
const char *cur_str;
apr_ssize_t cur_len, cur_avail;
@@ -640,8 +638,8 @@
}
}
- if (debug) {
- ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, f->r->server,
+ if (dc->debug >= DBGLVL_GORY) {
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, f->r,
"xlate_filter() - "
"dc: %X charset_source: %s charset_default: %s",
(unsigned)dc,
@@ -780,16 +778,11 @@
NULL,
OR_FILEINFO,
"name of default charset"),
- AP_INIT_FLAG("CharsetDebug",
- add_charset_debug,
- NULL,
- OR_FILEINFO,
- "mod_charset_lite debug flag"),
AP_INIT_ITERATE("CharsetOptions",
add_charset_options,
NULL,
OR_FILEINFO,
- "valid options: ImplicitAdd, NoImplicitAdd"),
+ "valid options: ImplicitAdd, NoImplicitAdd, DebugLevel=n"),
{NULL}
};