-
Notifications
You must be signed in to change notification settings - Fork 14
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
Use structured logging #105
Conversation
5d920e7
to
fd44b97
Compare
NOTE: Resolved merge conflicts, but am currently running into an error and board ends up crashing. Need to explore and mitigate the issue |
…n errors but managed to get past them with the work done here. A lot more work to be done
…hat will later be removed as I decide on one of the formats. still very early on in process
…ew function calls to the log functions in main.py
…logger from functions.py can be passed into the cdh functions and that logger can be used.
…modified debug_print so it ends up calling the logger.
…rameter. changed debug_print function calls to logger function calls
…bove importing cdh
…call parameters in time since I added this line of code
…columns of Device andStatus
Thank you for the feedback in #109 Regarding the filenames, I am with you. It didn't feel quite right regarding the 'filename=' at the top of different files and felt kinda clumsy or awkward. I am definitely supportive of getting rid of the filename parameter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You made quick work of that review yesterday! Awesome! I've left a few comments and suggestions on calls to the logger that could be implemented in more places the themes for the call outs are:
- Remove the
message=
key from the first argument in each logger call - Ensure that every call to the logger has a non-empty message
- Move all variables injected into message strings to use key/value pairs (kwargs) that you feed to the logger
- Add tests for all of the public functions you've created in
logger.py
Because of the conflicts with this large change, I want to make sure this is the next thing that goes in if we can so thank you for the quick follow up.
What do you think of the proposed changes?
Co-authored-by: Nate Gay <[email protected]>
Co-authored-by: Nate Gay <[email protected]>
Co-authored-by: Nate Gay <[email protected]>
Co-authored-by: Nate Gay <[email protected]>
… their own key/value pairs instead
…was already used by first argument to function call
@@ -4,42 +4,38 @@ | |||
Authors: Nicole Maggard, Michael Pham, and Rachel Sarmiento | |||
""" | |||
|
|||
import traceback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noting for the future that we talked about removing traceback and we couldn't find a reason to keep it. We tried both in repl and found that reporting back the exception var e
gave the same output but maybe we missed something. 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a few final comments. What are your thoughts?
Not directed at you or this PR but oof @ that big try/except block in cdh.py
. Cleaning that up could make logging nicer but that makes sense to do in another PR.
Co-authored-by: Nate Gay <[email protected]>
…cket_sender to construct using a Logger
Co-authored-by: Nate Gay <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented the beginning stages of a Logger class
The logger is used in replace of the debug_print and print statements.
Regarding the error_print statements, I have currently refactored the error_print function to use the logger internally. The error_print has an increment to self.c_error_count, so refactoring wasn't a simple switch to the logger error message and required some thought to approach a refactor. I am following Nate's guidance to refactor this section after his and Taylor's merge to the change counters (#93 #95).
This logger class currently has the functionality to format key, value pairs into a json string, which can be printed to standard output.
Currently, there IS NOT the ability to save these logs to a file. This functionality is a longer-term objective.
I tested this code by running it on a v4b board, and the output shows similar to the main branch, the only difference of course seeing the output in json