-
Notifications
You must be signed in to change notification settings - Fork 70
Implement LoggerAdapter to provide extended paths in the output. Improve #571 #572
Conversation
I know it's a pain, but is it possible to revert the changes made from the IDE? We can make the PEP8 changes after in a separate commit. This will make the commit history a lot cleaner. Also, any reason why it's reporting the compiled files (.pyc) rather than .py? Otherwise, unit + integration tests pass. I'll comment on the code after the commit is updated :) |
e0c4915
to
7b52749
Compare
@cdrage And as for .pyc files, I'm not sure. It sometimes shows .pyc and the other times .py (see image above), but should it matter since these are debug messages and we get the file names just fine? |
class Logging: | ||
class AtomicappLoggingAdapter(logging.LoggerAdapter): | ||
""" | ||
A class to pass contextual information to logs. |
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.
Instead of "A class". Maybe "A logging adapter?" Bit more descriptive :)
@cdrage Thanks for the pointers. I'll work on the comments. |
@containscafeine this all looks good to me 👍 feel free to work on the other stuff. I'll await for @dustymabe for secondary review |
@containscafeine - can you look at dustymabe@e2c57cc and give me your input? I think solving this in a way that uses the facilities of the logging library (i.e. creating a custom formatter) is a better way. |
@dustymabe I knew I was unnecessarily complicating stuff 🤦, but on another note, at the moment we have to modify just the pathname, which we can deal with using |
@containscafeine I would like to not modify our logging structure unless we have a need to do so. If you think having the longer filename is something you want in right now then I say we go with something like dustymabe@e2c57cc for now. What do you think? |
+1 for dustymabe@e2c57cc |
A logger adapter has been created in applogging.py, and the logging instance created by it is the same which is being used by other files, unlike before when each file created their own instance.
This is done so that additional contextual output can be outputted in the logging messages, which is currently only the filename which is making the logging calls.
In the other files, only one import (
from atomicapp.applogging import Logging
) and one initialization (logger = Logging.global_logger(__file__)
), and it's done.The code is poor, but it would be great if I could get some feedback on the approach and where can it be improved.
Also, I have not touched the cockpit logger and not included the check for --verbose, will do once this is reviewed.
P.S. Sorry for the changes around imports, the IDE rearranged them according to PEP8.