Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
ARIA-416 Providing handlers to logging_handlers only adds handles ins…
…tead of replacing
  • Loading branch information
mxmrlv authored and aviaefrat committed Dec 4, 2017
1 parent 1f5260c commit f17ae3133c50985148090c25240734abca9ceec9
Showing 1 changed file with 7 additions and 2 deletions.
@@ -114,15 +114,20 @@ def __repr__(self):
.format(name=self.__class__.__name__, self=self))

@contextmanager
def logging_handlers(self, handlers=None):
def logging_handlers(self, handlers):
original_handlers = self.logger.handlers
handlers = handlers or []
try:
for handler in handlers:
self.logger.addHandler(handler)
for handler in original_handlers:
self.logger.removeHandler(handler)
yield self.logger
finally:
for handler in handlers:
for handler in self.logger.handlers[:]:
self.logger.removeHandler(handler)
for handler in original_handlers:
self.logger.addHandler(handler)

@property
def model(self):

0 comments on commit f17ae31

Please sign in to comment.