Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add-on for easily turning on/off or tail-ing the db query log #5689

Closed
2 tasks done
apotek opened this issue Jan 10, 2024 · 8 comments
Closed
2 tasks done

Add-on for easily turning on/off or tail-ing the db query log #5689

apotek opened this issue Jan 10, 2024 · 8 comments

Comments

@apotek
Copy link
Contributor

apotek commented Jan 10, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem?

When using ddev with a framework with a database abstraction layer, it can be finicky to set up being able to see the actual database queries generated by the application.

Describe your solution

A custom ddev command that allows a user to very very easily turn on or off query logging and optionally to tail that log.

Due to the noisy nature of the db log output, it would be best to exclude it from the general ddev logs output.

Describe alternatives

I considered adding configuration to the db container that would send all queries to the ddev logs. But I realized that would create a lot of noise, would slow down the application, and would make it difficult to toggle on and off. Looking at the db logs is generally something only necessary to do occasionally.

Additional context

I have written a command as described above and am using it successfully. I am posting this issue to see whether it would be considered generally worthwhile enough for it to be contributed to the ddev project as an included command.

@tyler36
Copy link
Collaborator

tyler36 commented Jan 10, 2024

@apotek Thanks for the suggestion.

Might be worth posting the command here, or sharing a gist to it so people can have a play and give feedback.
If it's something you think you might use a lot, consider creating an addon. That makes it easier to install for anyone. 😄

@apotek
Copy link
Contributor Author

apotek commented Jan 10, 2024

@apotek Thanks for the suggestion.

Might be worth posting the command here, or sharing a gist to it so people can have a play and give feedback. If it's something you think you might use a lot, consider creating an addon. That makes it easier to install for anyone. 😄

Hi @tyler36 and thank you for your reply. I just posted a merge request which should demonstrate the approach. I don't think the addon approach feels right to me since the point here is not to add an additional service but to add a command to a service that is already supported. But please correct me if I am wrong.

I can in the meantime attempt to expand this script to include pgsql support as well (or just write another for that). But this should provide a starting point.

@tyler36
Copy link
Collaborator

tyler36 commented Jan 10, 2024

You can find the template here: https://github.com/ddev/ddev-addon-template

EG. https://github.com/tyler36/ddev-vscode-devcontainer is a simple addon that adds a "code" command.

@jonaseberle
Copy link
Collaborator

I think that is a great idea and it helps me often when debugging.

I've made this command some years ago: https://gist.github.com/jonaseberle/28a675d034dfa1dbaf8e586184fd1d77 but I've not come around to upstream it as a DDEV add-on. Please feel free to take from it what you find useful. I am happy to install the add-on from you then! :)

@apotek
Copy link
Contributor Author

apotek commented Jan 11, 2024

Hi @tyler36 and @jonaseberle ! Thank you for your suggestions. I have created a rough draft for this as an add-on.

https://github.com/ChromaticHQ/ddev-dblog

@jonaseberle I like a lot of the ideas in your script and may want to incorporate some of them while keeping the command light weight.
@tyler36 I agree also with you that it would be nice to make the command db-engine agnostic.

@apotek apotek changed the title Contributed command to easily turn on/off/tail the db query log Add-on for easily turning on/off or tail-ing the db query log Jan 12, 2024
@apotek
Copy link
Contributor Author

apotek commented Jan 12, 2024

@tyler36 I have put up test-passing beta at https://github.com/ChromaticHQ/ddev-dblog and posted a feature request for postgres support here: ChromaticHQ/ddev-dblog#1

@jonaseberle I have added a feature request to maybe implement some of your gist-ideas into the UX as the add-on matures. Thank you again for your suggestions: ChromaticHQ/ddev-dblog#2

@jonaseberle
Copy link
Collaborator

Thanks, that works well.

I think we can close here and use ddev get chromatichq/ddev-dblog and ddev dblog tail :)

@rfay
Copy link
Member

rfay commented Jan 31, 2024

Yay, thanks!

@rfay rfay closed this as completed Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants