Ecto.DevLogger (ecto_dev_logger v0.15.0)
View SourceAn alternative logger for Ecto queries.
It inlines bindings into the query, so it is easy to copy-paste logged SQL and run it in any IDE for debugging without manual transformation of common Elixir terms to string representations (binary UUID, DateTime, Decimal, JSON, etc.). It also highlights DB time to make slow queries noticeable. The source table and inlined bindings are highlighted as well.
Summary
Functions
Gets the handler_id for a given Repo.
Attaches telemetry_handler/4 to the application.
Telemetry handler which logs queries.
Detaches a previously attached handler for a given Repo.
Types
Functions
Gets the handler_id for a given Repo.
Attaches telemetry_handler/4 to the application.
Returns the result from the call to :telemetry.attach/4 or :ok if the repo has default logging enabled.
Options
:log_repo_name- when truthy, adds the repo name to the log output.:ignore_event- a callback that allows skipping specific telemetry events, thus suppressing logs. By default, the library ignores events fromObanand events related to migration queries. These checks are not overridable by the:ignore_eventcallback and have priority over it.:before_inline_callback- a callback that allows modifying the query before inlining bindings. You can use this option to format the query using an external utility, likepgformatter, etc.
To ignore logging for a single Repo operation, pass log: false via telemetry_options to that call; for example:
Repo.query!("SELECT 1", [], telemetry_options: [log: false])
Repo.insert!(changeset, telemetry_options: [log: false])
@spec telemetry_handler( :telemetry.event_name(), :telemetry.event_measurements(), :telemetry.event_metadata(), [option()] ) :: :ok
Telemetry handler which logs queries.
@spec uninstall(repo_module :: module()) :: :ok | {:error, :not_found}
Detaches a previously attached handler for a given Repo.
Returns the result from the call to :telemetry.detach/1