An Ecto query logger that inlines bindings into SQL for easy copy-paste debugging and highlights database time.
Ecto.DevLogger is an alternative logger for Ecto queries that transforms logged SQL by directly inlining parameter bindings, converting Elixir values like UUIDs, DateTimes, and Decimals into SQL literals. It produces copy-pasteable SQL that can be run directly in database IDEs, improving the debugging experience for developers. The logger also highlights database execution time and source tables to quickly identify slow queries.
Elixir developers using Ecto for database interactions who need to debug SQL queries in development environments, particularly those who frequently copy queries into database management tools for analysis.
Developers choose Ecto.DevLogger because it eliminates the manual conversion of Elixir data types to SQL, saving time and reducing errors during debugging. Its unique selling point is generating immediately executable SQL with inline bindings and highlighting for readability, unlike default Ecto logging which leaves parameters separate.
An alternative logger for Ecto queries
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Automatically converts Elixir values like UUIDs, DateTimes, and Decimals into SQL literals, producing copy-pasteable SQL for direct use in database IDEs without manual conversion, as demonstrated in the screenshot.
Can be installed only in the :dev Mix environment, preventing accidental production use and aligning with secure development practices, as detailed in the 'Development Only Installation' section.
Supports suppressing logs for specific Repo operations via telemetry_options: [log: false], allowing fine-grained control over what gets logged without disabling the logger entirely.
Uses the PrintableParameter protocol for custom type rendering, enabling developers to define how their Elixir types are logged as SQL, as shown with Postgrex structs and optional geo library support.
Operates below Ecto's type casting layer, so it may not match schema types exactly; for example, maps are always rendered as JSON even if stored as hstore, requiring manual intervention for accuracy.
Installing only in development requires additional boilerplate code in the application start function, such as conditional module checks, which adds complexity compared to standard logging setup.
Many rendering examples and features are tailored for PostgreSQL (e.g., Postgrex structs, geo types), which might not seamlessly work with other databases like MySQL or SQLite without custom implementations.