leptus_logger
Functions
add_handler/2
Adds a new log handler to the gen_event manager leptus_log_man.
add_handler(Handler, Args) ->
ok | {'EXIT', any()} | any()
Handler = atom() | {atom(), any()}
Args = any()
delete_handler/2
Removes a log handler from the gen_event manager leptus_log_man.
delete_handler(Handler, Args) ->
any() | {error, module_not_found} | {'EXIT', any()}
Handler = atom() | {atom(), any()}
Args = any()
access_log/1
Sends the event notification {access_log, LogData} to the event manager
leptus_log_man.
access_log(LogData) -> ok
LogData = #log_data {
request_time :: calendar:datetime(),
response_time :: undefined | calendar:datetime(),
request_line :: string(),
ip :: inet:ip_address(),
version :: atom(),
method :: binary(),
uri :: binary(),
headers :: [{binary(), iodata()}],
status :: non_neg_integer(),
content_length :: non_neg_integer()
}
The #log_data record is defined in ~include/leptus_logger.hrl".
format/2
Produces a log line with a given format.
format(Fmt, LogData) -> string()
Fmt = string()
LogData = #log_data {
request_time :: calendar:datetime(),
response_time :: undefined | calendar:datetime(),
request_line :: string(),
ip :: inet:ip_address(),
version :: atom(),
method :: binary(),
uri :: binary(),
headers :: [{binary(), iodata()}],
status :: non_neg_integer(),
content_length :: non_neg_integer()
}
The #log_data record is defined in ~include/leptus_logger.hrl".
Example:
> format("~h ~l ~u ~t \"~r\" ~s ~B", LogData).
"127.0.0.1 - - [11/Jun/2014:03:07:25 +0200] \"GET /b?p=2 HTTP/1.1\" 200 8-3"