[erlang-questions] inets httpd mod_log output issue
Paul Fisher
pfisher@REDACTED
Fri May 9 16:59:58 CEST 2008
The 'compact' 'error_log_format' generates things like the following in
the
log files:
[09/May/2008:09:19:57 -0500] access to /foo/flooga.txt failed for 127.0.0.1, reason: [104,116,116,112,100,95,102,105,108,101,58,32,67,97,110,39,116,32,111,112,101,110,47,104,111,109,101,47,112,102,105,115,104,101,114,47,108,109,47,108,109,45,116,114,117,110,107,47,98,108,100,47,101,114,108,97,110,103,47,105,110,101,116,115,109,103,114,47,112,114,105,118,47,102,111,111,47,102,108,111,111,103,97,46,116,120,116]
This is caused by the following in httpd_log:do_error_entry/5 (line 108
and
119):
compact ->
io_lib:format( "[~s] access to ~s failed for ~s, reason: ~w~n",
[Date, URI, RemoteHost, Reason])
Simply changing the ~w to ~s is not sensible, since this code clearly
expects the value of Reason to be something other than a character list
at
times. I guess it would be possible to do the following:
compact when is_list(Reason), is_integer(hd(Reason)),
hd(Reason) > 0, hd(Reason) =< 255 ->
io_lib:format( "[~s] access to ~s failed for ~s, reason: ~s~n",
[Date, URI, RemoteHost, Reason]);
compact ->
io_lib:format( "[~s] access to ~s failed for ~s, reason: ~w~n",
[Date, URI, RemoteHost, Reason])
... but maybe there is a better way?
R12B-2, of course.
--
paul
Robert Virding's First Rule:
"Any sufficiently complicated concurrent program in another language
contains an ad hoc, informally-specified, bug-ridden, slow
implementation of half of Erlang."
More information about the erlang-questions
mailing list