fuelen / ecto_dev_logger

An alternative logger for Ecto queries
Apache License 2.0
147 stars 14 forks source link

Alternative Configuration #28

Closed halostatue closed 7 months ago

halostatue commented 7 months ago

Your installation / configuration steps suggest making ecto_dev_logger available to all environments, but with a couple of small changes, we can eliminate it from the release bundle:

## Installation

The package can be installed by adding `ecto_dev_logger` to your list of dependencies in `mix.exs`:

```elixir
def deps do
  [
    {:ecto_dev_logger, "~> 0.10", only: :dev}
  ]
end

Then disable default logger for your repo in config file for dev mode:

if config_env() == :dev do
  config :my_app, MyApp.Repo, log: false
end

And install telemetry handler in MyApp.Application:

if Code.ensure_loaded?(Ecto.DevLogger), do: Ecto.DevLogger.install(MyApp.Repo)

Telemetry handler will be installed only if log configuration value is set to false.

That's it.

fuelen commented 7 months ago

Nice improvement! Could you send a PR? :slightly_smiling_face:

halostatue commented 7 months ago

Sure. There is a slight difference to it that works vs what doesn’t, but I think it’s an acceptable difference.