Combo.Logger (combo v0.8.0)
View SourceLogging various instrumentation events.
Events
Combo uses the :telemetry library for instrumentation. The following events
are published by Combo with the following measurements and metadata:
[:combo, :endpoint, :init]- dispatched byCombo.Endpointafter your Endpoint supervision tree successfully starts:- Measurement:
%{system_time: system_time} - Metadata:
%{pid: pid(), config: keyword(), module: module(), otp_app: atom()} - Disable logging: This event is not logged
- Measurement:
[:combo, :endpoint, :start]- dispatched byPlug.Telemetryin your endpoint:- Measurement:
%{system_time: system_time} - Metadata:
%{conn: Plug.Conn.t, options: Keyword.t} Options:
%{log: Logger.level | false}Disable logging: In your endpoint
plug Plug.Telemetry, ..., log: Logger.level | false- Configure log level dynamically:
plug Plug.Telemetry, ..., log: {Mod, Fun, Args}
- Measurement:
[:combo, :endpoint, :stop]- dispatched byPlug.Telemetryin your endpoint whenever the response is sent:- Measurement:
%{duration: native_time} - Metadata:
%{conn: Plug.Conn.t, options: Keyword.t} Options:
%{log: Logger.level | false}Disable logging: In your endpoint
plug Plug.Telemetry, ..., log: Logger.level | false- Configure log level dynamically:
plug Plug.Telemetry, ..., log: {Mod, Fun, Args}
- Measurement:
[:combo, :router_dispatch, :start]- dispatched byCombo.Routerbefore dispatching to a matched route:- Measurement:
%{system_time: System.system_time} Metadata:
%{conn: Plug.Conn.t, route: binary, plug: module, plug_opts: term, path_params: map, pipe_through: [atom], log: Logger.level | false}- Disable logging: Pass
log: falseto the router macro, for example:get("/page", PageController, :index, log: false) - Configure log level dynamically:
get("/page", PageController, :index, log: {Mod, Fun, Args})
- Measurement:
[:combo, :router_dispatch, :exception]- dispatched byCombo.Routerafter exceptions on dispatching a route:- Measurement:
%{duration: native_time} Metadata:
%{conn: Plug.Conn.t, kind: :throw | :error | :exit, reason: term(), stacktrace: Exception.stacktrace()}- Disable logging: This event is not logged
- Measurement:
[:combo, :router_dispatch, :stop]- dispatched byCombo.Routerafter successfully dispatching a matched route:- Measurement:
%{duration: native_time} Metadata:
%{conn: Plug.Conn.t, route: binary, plug: module, plug_opts: term, path_params: map, pipe_through: [atom], log: Logger.level | false}- Disable logging: This event is not logged
- Measurement:
[:combo, :error_rendered]- dispatched at the end of an error view being rendered:- Measurement:
%{duration: native_time} - Metadata:
%{conn: Plug.Conn.t, status: Plug.Conn.status, kind: Exception.kind, reason: term, stacktrace: Exception.stacktrace} - Disable logging: Set
render_errors: [log: false]on your endpoint configuration
- Measurement:
[:combo, :socket_connected]- dispatched byCombo.Socket, at the end of a socket connection:- Measurement:
%{duration: native_time} Metadata:
%{endpoint: atom, transport: atom, params: term, connect_info: map, vsn: binary, user_socket: atom, result: :ok | :error, serializer: atom, log: Logger.level | false}- Disable logging:
use Combo.Socket, log: falseorsocket "/foo", MySocket, websocket: [log: false]in your endpoint
- Measurement:
[:combo, :socket_drain]- dispatched byCombo.Socketwhen using the:draineroption:- Measurement:
%{count: integer, total: integer, index: integer, rounds: integer} Metadata:
%{endpoint: atom, socket: atom, intervasl: integer, log: Logger.level | false}- Disable logging:
use Combo.Socket, log: falsein your endpoint or pass:logoption in the:draineroption
- Measurement:
[:combo, :channel_joined]- dispatched at the end of a channel join:- Measurement:
%{duration: native_time} Metadata:
%{result: :ok | :error, params: term, socket: Combo.Socket.t}- Disable logging: This event cannot be disabled
- Measurement:
[:combo, :channel_handled_in]- dispatched at the end of a channel handle in:- Measurement:
%{duration: native_time} - Metadata:
%{event: binary, params: term, socket: Combo.Socket.t} - Disable logging: This event cannot be disabled
- Measurement:
Parameter filtering
Parameter filtering is provided by the Combo.FilteredParams module.
Check it out for more details.
Dynamic log level
In some cases you may wish to set the log level dynamically on a
per-request basis. To do so, set the :log option to a tuple,
{Mod, Fun, Args}. The Plug.Conn.t() for the request will be
prepended to the provided list of arguments.
When invoked, your function must return a
Logger.level() or false to disable logging
for the request.
For example, in your Endpoint you might do something like this:
# lib/demo/web/endpoint.ex
plug Plug.Telemetry,
event_prefix: [:combo, :endpoint],
log: {__MODULE__, :log_level, []}
# Disables logging for routes like /status/*
def log_level(%{path_info: ["status" | _]}), do: false
def log_level(_), do: :infoDisabling
When you are using custom logging system it is not always desirable to
enable Combo.Logger by default. You can disable default logging
by:
config :combo, :logger, false