Working on a project that requires that I am able to pickle the container object at any point, since we expect it to fail on external conditions quite frequently and be able to
You could also create a class that implements a property which returns the needed logger. Every class which inherits from this "LoggerMixin" is now able to use the logger in the same way you were using it before.
class LoggerMixin():
@property
def logger(self):
component = "{}.{}".format(type(self).__module__, type(self).__name__)
return logging.getLogger(component)
class Foo(LoggerMixin):
def __init__(self):
self.logger.info("initialize class")
def bar(self):
self.logger.info("execute bar")