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:
@@ -53,7 +53,7 @@ feature {NONE} -- Initialization
|
|||||||
setup_filter
|
setup_filter
|
||||||
-- Setup `filter'
|
-- Setup `filter'
|
||||||
local
|
local
|
||||||
l_logging_filter: LOGGING_FILTER
|
l_logging_filter: WSF_LOGGING_FILTER
|
||||||
do
|
do
|
||||||
create l_logging_filter
|
create l_logging_filter
|
||||||
filter.set_next (l_logging_filter)
|
filter.set_next (l_logging_filter)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ note
|
|||||||
revision: "$Revision$"
|
revision: "$Revision$"
|
||||||
|
|
||||||
class
|
class
|
||||||
LOGGING_FILTER
|
WSF_LOGGING_FILTER
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
WSF_FILTER
|
WSF_FILTER
|
||||||
@@ -15,24 +15,31 @@ feature -- Basic operations
|
|||||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||||
-- Execute the filter
|
-- Execute the filter
|
||||||
local
|
local
|
||||||
l_user_agent: STRING
|
l_user_agent, l_referer: STRING
|
||||||
l_date: DATE_TIME
|
l_date: DATE_TIME
|
||||||
do
|
do
|
||||||
if attached req.http_user_agent as ua then
|
if attached req.http_user_agent as ua then
|
||||||
l_user_agent := ua.as_string_8
|
l_user_agent := "%"" + ua.as_string_8 + "%""
|
||||||
else
|
else
|
||||||
l_user_agent := "-"
|
l_user_agent := "-"
|
||||||
end
|
end
|
||||||
create l_date.make_now
|
if attached req.http_referer as r then
|
||||||
io.put_string ("[" + l_date.formatted_out (Date_time_format) + "] %"" + req.request_method + " " + req.request_uri
|
l_referer := "%"" + r + "%" "
|
||||||
+ " " + {HTTP_CONSTANTS}.http_version_1_1 + "%" " + res.status_code.out + " " + l_user_agent)
|
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
|
io.put_new_line
|
||||||
execute_next (req, res)
|
execute_next (req, res)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Constants
|
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
|
note
|
||||||
copyright: "2011-2012, Olivier Ligot, Jocelyn Fiat and others"
|
copyright: "2011-2012, Olivier Ligot, Jocelyn Fiat and others"
|
||||||
Reference in New Issue
Block a user