You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As discussed earlier, here's the code snippet I was talking about to make logging easier project-wide:
# logger.pyimportloggingclassLogMixin:
""" Use this mixin to do logging: self.logger.debug("My debugging message") """__logger=None@propertydeflogger(self) ->logging.Logger:
ifself.__logger:
returnself.__loggerself.__logger=logging.getLogger(self.__class__.__module__)
returnself.logger
To use it, just do this:
fromloggerimportLogMixinclassMyClass(LogMixin, AnyOtherParent):
...
defmy_method(self):
self.logger.debug("This is my debug message with %s", some_variable)
This will produce log entries attached to the class and file path rather than the root.
The text was updated successfully, but these errors were encountered:
As discussed earlier, here's the code snippet I was talking about to make logging easier project-wide:
To use it, just do this:
This will produce log entries attached to the class and file path rather than the root.
The text was updated successfully, but these errors were encountered: