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

Improve logging and debugging #38

Merged
merged 7 commits into from
Nov 19, 2021

Conversation

mjeffrey18
Copy link
Contributor

@mjeffrey18 mjeffrey18 commented Nov 6, 2021

Fixes: #19

  • There was a lot of spec logic around logging, I guess it seemed like it made sense to remove that?
  • Provided developers was an example of how they can change the logging level.
  • Refactored a bunch of rescue statements around the code to log the rescued errors.
  • Refactored the base connection class type mounting method.
  • Added a debug_json method which can be exposed on any rest endpoint to ping and get stats on the current state of the server

Let me know what you guys think?

Copy link
Collaborator

@jwoertink jwoertink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it! You can just leave the version update off, and we can get everything merged in and updated all at once. The rest looks great to me! Thanks so much for doing this

src/cable.cr Outdated Show resolved Hide resolved
src/cable/server.cr Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
Copy link
Collaborator

@jwoertink jwoertink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet!

@mjeffrey18
Copy link
Contributor Author

Hey @russ / @jwoertink whenever you're ready, we can go ahead and start merging the other branches, except this PR.
Once everything else has been merged I'll need to clean up everything on this PR to finalise the new release.

@jwoertink
Copy link
Collaborator

Thanks for the heads up @mjeffrey18. Right now @fernandes is on vacation, but once he gets back, we should be good to start merging stuff in. 👍 Thanks so much for tackling this, it's huge!

@jwoertink jwoertink changed the title Improve logging and debugging [DO NOT MERGE] Improve logging and debugging Nov 11, 2021
…elpers

Signed-off-by: Marc Jeffrey <mjeffrey18@gmail.com>
Signed-off-by: Marc Jeffrey <mjeffrey18@gmail.com>
Signed-off-by: Marc Jeffrey <mjeffrey18@gmail.com>
Signed-off-by: Marc Jeffrey <mjeffrey18@gmail.com>
Signed-off-by: Marc Jeffrey <mjeffrey18@gmail.com>
Signed-off-by: Marc Jeffrey <mjeffrey18@gmail.com>
Signed-off-by: Marc Jeffrey <mjeffrey18@gmail.com>
@mjeffrey18 mjeffrey18 changed the title [DO NOT MERGE] Improve logging and debugging Improve logging and debugging Nov 19, 2021
@mjeffrey18
Copy link
Contributor Author

@fernandes this one is ready for final review/merge

Big shout out again to @jgaskins as a lot of the inspiration for the cleanup came from his fork 💪

Copy link
Collaborator

@jwoertink jwoertink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for this!

@jwoertink jwoertink merged commit e41bbb2 into cable-cr:master Nov 19, 2021
@fernandes
Copy link
Collaborator

@mjeffrey18 what's the rational behind removing these messages? I'm asking because it helped me in the past to catch a few bugs lol

There was a lot of spec logic around logging, I guess it seemed like it made sense to remove that?

maybe my first comment answers this one on description 😉

if this is just because now we are using a bare crystal log class, it supports capturing the logs for testing, like I did here

@mjeffrey18
Copy link
Contributor Author

Hey @fernandes, your right, logging can absolutely catch bugs. I've always found solid specs are way better at catching bugs and logs are better for debugging/monitoring.

Taking some lessons I've learned from heavy use of Rspec over the years;

  • Testing if methods are called can leads to false positives and/or flaky specs.
  • Use mutations/results should be tested where possible. This avoids flaky specs and focuses on outcomes over implementation.
  • Logging is amazing for debugging, so unless the specs are weak (which they're not, you've done a pretty solid job!) we will catch bugs with specs.

However, I'm open to other alternative approaches (as your suggested) if we feel testing the logs is worth it for this particular case.

@fernandes
Copy link
Collaborator

I agree, I tried to test the behavior as much as possible

you've done a pretty solid job!

thank you! 🙇

my final thought is if we should handle log messages as part as the software behavior/functionality, because if so, it's good to have it tested, once users will get the correct messages in the tested scenario

comments? 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clean ups?
4 participants