leptus_router module

Table of Contents

leptus_logger module

This module is used for adding/removing log handlers and sending log events.

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()

Types:

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()}

Types:

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

Type:

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()
		    }

format/2

Produces a log line with a given format.

format(Fmt, LogData) -> string()

Types:

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()
		    }

Example:

> format("~h ~l ~u ~t \"~r\" ~s ~B", LogData).
"127.0.0.1 - - [11/Jun/2014:03:07:25 +0450] \"GET /b?p=2 HTTP/1.1\" 200 83"

Author: Sina Samavati

Created: 2026-04-17 Fri 11:09

Validate