kworkflow / patch-hub

patch-hub is a TUI that streamlines the interaction of Linux developers with patches archived on lore.kernel.org
GNU General Public License v2.0
8 stars 6 forks source link

feat: logging: add log_on_error macro #62

Closed lorenzoberts closed 1 month ago

lorenzoberts commented 1 month ago

This PR creates a macro to log if a result is an error, as discussed in #47 . To exemplify its use case, I applied it to two functions: download_patchset() returns error if b4 is not installed and split_patchset() returns error if there's a problem with the patch set path. Obviously this macro can be applied to multiple existing calls, but the focus of this PR is only adding the macro, so I restricted its usage to these two examples. Below are three examples of how the logs appear in the log file. Note that in the last one I changed the LogLevel to Warning just for creating the example. Captura de tela de 2024-10-13 16-16-57 Captura de tela de 2024-10-13 16-13-52 Captura de tela de 2024-10-13 16-41-36

Besides creating the macro, this PR also reorganizes logging-related elements into separate files (and a dedicated directory) because I felt the logging.rs was getting too large and with things which, in my opinion, would fit better in different files. If you don't think this is necessary, we can simply drop the second commit.

davidbtadokoro commented 1 month ago

Really nice! As we've discussed in #47, I generally agree with the idea and am much obliged for you to go straight to "show me the code" and opening the PR :smiley:

I will review this ASAP. Thanks again :+1:

P.S.: Thanks for the detailed PR explanation with the screenshots.

davidbtadokoro commented 1 month ago

Hey @lorenzoberts, I've ended up just incorporating the comment I've made and merged it in the unstable branch :+1:

Thank you so much!