Logging filter
The logging filter is now part of EWF core (before it was only available in the filter example) and can therefore be reused by others needing it. Note that this is a first implementation. It can certainly be improved in the future to support more fine grained logging.
This commit is contained in:
committed by
Jocelyn Fiat
parent
156406f9ac
commit
075ac1d628
@@ -53,7 +53,7 @@ feature {NONE} -- Initialization
|
||||
setup_filter
|
||||
-- Setup `filter'
|
||||
local
|
||||
l_logging_filter: LOGGING_FILTER
|
||||
l_logging_filter: WSF_LOGGING_FILTER
|
||||
do
|
||||
create l_logging_filter
|
||||
filter.set_next (l_logging_filter)
|
||||
|
||||
@@ -5,7 +5,7 @@ note
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
LOGGING_FILTER
|
||||
WSF_LOGGING_FILTER
|
||||
|
||||
inherit
|
||||
WSF_FILTER
|
||||
@@ -15,24 +15,31 @@ feature -- Basic operations
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Execute the filter
|
||||
local
|
||||
l_user_agent: STRING
|
||||
l_user_agent, l_referer: STRING
|
||||
l_date: DATE_TIME
|
||||
do
|
||||
if attached req.http_user_agent as ua then
|
||||
l_user_agent := ua.as_string_8
|
||||
l_user_agent := "%"" + ua.as_string_8 + "%""
|
||||
else
|
||||
l_user_agent := "-"
|
||||
end
|
||||
create l_date.make_now
|
||||
io.put_string ("[" + l_date.formatted_out (Date_time_format) + "] %"" + req.request_method + " " + req.request_uri
|
||||
+ " " + {HTTP_CONSTANTS}.http_version_1_1 + "%" " + res.status_code.out + " " + l_user_agent)
|
||||
if attached req.http_referer as r then
|
||||
l_referer := "%"" + r + "%" "
|
||||
else
|
||||
l_referer := ""
|
||||
end
|
||||
create l_date.make_now_utc
|
||||
io.put_string (req.remote_addr + " - - [" + l_date.formatted_out (Date_time_format) + " GMT] %""
|
||||
+ req.request_method + " " + req.request_uri
|
||||
+ " " + {HTTP_CONSTANTS}.http_version_1_1 + "%" " + res.status_code.out + " "
|
||||
+ res.transfered_content_length.out + " " + l_referer + l_user_agent)
|
||||
io.put_new_line
|
||||
execute_next (req, res)
|
||||
end
|
||||
|
||||
feature -- Constants
|
||||
|
||||
Date_time_format: STRING = "yyyy/[0]mm/[0]dd [0]hh:[0]mi:[0]ss.ff3"
|
||||
Date_time_format: STRING = "[0]dd/[0]mm/yyyy [0]hh:[0]mi:[0]ss"
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Olivier Ligot, Jocelyn Fiat and others"
|
||||
Reference in New Issue
Block a user