On Apr 16, 2008, at 9:57 PM, Christoph Dorn wrote:
I was wondering if it would be useful for a lot of mod_rewrite users
to
be able to view the rewrite log in their Firebug console instead of
...
There could be a new configuration directive for mod_rewrite that
enables the sending of the rewrite log for specific IP's for instance.
This would also be useful in that rewrite logging would not need to be
turned on for all users.
...
Is this something that would be useful to have for mod_rewrite users?
...
Could this be added to the default mod_rewrite module? A separate
module?
Couple of issues/thoughts here
- We right now have the '/file..' and '|to a pipe' construct
in use for logging in quite a few places. One could
add an extra ':json-header' or similar 'alert'.
- But we do not readily allow multiple outputs (depending on
how it is configured, quite confusing - your next Log directive
will overwrite or be in parallel with a previous/higher one).
So rationalizing this and adding an extra option would be goodness.
However:
- Right now -most- logging is done at the very end - and the firebug
method assumes that it is all ready when/prior to the header
going out. Not sure how to solve this. Though with Chunked and
multipart replies you can perhaps post-append the header in a way
acceptable to both firebug and the http guru's.
- While there is an ap_log_write sort of thing in mod_log_config
and the other loggers/* are fairly sane - mod_rewrite
does its own open_rewritelog(). So that would have to be
sanitized as well. But that would be goodness.
However this makes it a fairly big project.
Could this be added to the default mod_rewrite module? A separate
module?
In the current setup you'd have to add it into mod_rewrite; and it
would just work
for mod_rewrite. I'd directly attack do_rewritelog() by putting a line
in which
adds to the header (see outline below which is adapted from a similar
feature
for the oracle IDE). Dirty like hell.
Dw.
Index: mod_rewrite.c
===================================================================
--- mod_rewrite.c (revision 648690)
+++ mod_rewrite.c (working copy)
@@ -294,6 +294,7 @@
apr_array_header_t *rewriteconds; /* the RewriteCond entries
(temp.) */
apr_array_header_t *rewriterules; /* the RewriteRule
entries */
server_rec *server; /* the corresponding server
indicator */
+ int firebug;
} rewrite_server_conf;
typedef struct {
@@ -537,6 +538,20 @@
/* XXX: Maybe this should be fatal? */
}
+ /* Add current logline to a (to be created firebug line) */
+ if (conf->firebug) {
+ char * p = apr_table_get(r->headers_out,"X-FirePHP-Data");
+#define FB_PREFIX ("{ \"FirePHP.Firebug.Console\":[ ")
+#define FB_POSTFIX ("]}")
+ if (p) {
+ p = p + sizeof(FB_PREFIX);
+ p[ strlen(p) - sizeof(FB_POSTFIX) ] = '\0';
+ }
+ p = apr_pstrcat(r->pool, FB_PREFIX, "[\"LOG\",[\"rewrite\",\"",
logline, "\"]]"
+ p ? "," : "" , p ? p : "", FB_POSTFIX, NULL);
+ apr_table_setn(r->headers_out, "X-FirePHP-Data", p);
+ };
return;
}
#endif /* !REWRITELOG_DISABLED */
@@ -2726,6 +2741,7 @@
a->rewritelogfile = NULL;
a->rewritelogfp = NULL;
a->rewriteloglevel = 0;
+ a->firebug = 0;
#endif
a->rewritemaps = apr_hash_make(p);
a->rewriteconds = apr_array_make(p, 2,
sizeof(rewritecond_entry));
@@ -4963,6 +4979,8 @@
AP_INIT_TAKE1( "RewriteLogLevel", cmd_rewriteloglevel, NULL,
RSRC_CONF,
"the level of the rewriting logfile verbosity "
"(0=none, 1=std, .., 9=max)"),
+ AP_INIT_FLAG( "RewriteLogFirebug", cmd_firebugenable, NULL,
RSRC_CONF,
+ "Enable or disable firebug support"),
#else
AP_INIT_TAKE1( "RewriteLog", fake_rewritelog, NULL, RSRC_CONF,
"[DISABLED] the filename of the rewriting
logfile"),