View Source Ecto.DevLogger (ecto_dev_logger v0.10.0)

An 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 representation (binary UUID, DateTime, Decimal, json, etc). Also, it highlights db time to make slow queries noticeable. Source table and inlined bindings are highlighted as well.

Link to this section Summary

Functions

Gets the handler_id for a given Repo.

Detaches a previously attached handler for a given Repo.

Link to this section Types

@type option() ::
  {:log_repo_name, boolean()}
  | {:ignore_event, (metadata :: map() -> boolean())}

Link to this section Functions

@spec handler_id(repo_module :: module()) :: list()

Gets the handler_id for a given Repo.

Link to this function

install(repo_module, opts \\ [])

View Source
@spec install(repo_module :: module(), opts :: [option()]) ::
  :ok | {:error, :already_exists}

Attaches telemetry_handler/4 to application.

Returns the result from the call to :telemetry.attach/4 or :ok if the repo has default logging enabled.

options

Options

  • :log_repo_name - when truthy will add the repo name into the log.
  • :ignore_event - a callback which allows to skip some telemetry events thus skip printing logs. By default, the library ignores events from Oban and events related to migration queries. These checks are not overridable by :ignore_event callback and have priority over it.
Link to this function

telemetry_handler(event_name, measurements, metadata, config)

View Source

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