This is an automated email from the ASF dual-hosted git repository.

mxmrlv pushed a commit to branch 
ARIA-416-Providing-handlers-to-logging_handlers-only-adds-handles-instead-of-replacing
in repository https://gitbox.apache.org/repos/asf/incubator-ariatosca.git

commit fab0709fd2d42fab14781aece9771dbd2dc4c8ab
Author: max-orlov <[email protected]>
AuthorDate: Tue Nov 28 17:20:12 2017 +0200

    CFY-416 Providing handlers to logging_handlers only adds handles instead of 
replacing
---
 aria/orchestrator/context/common.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/aria/orchestrator/context/common.py 
b/aria/orchestrator/context/common.py
index 3c5f618..87444a9 100644
--- a/aria/orchestrator/context/common.py
+++ b/aria/orchestrator/context/common.py
@@ -115,14 +115,19 @@ class BaseContext(object):
 
     @contextmanager
     def logging_handlers(self, handlers=None):
+        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:
                 self.logger.removeHandler(handler)
+            for handler in original_handlers:
+                self.logger.addHandler(handler)
 
     @property
     def model(self):

-- 
To stop receiving notification emails like this one, please contact
"[email protected]" <[email protected]>.

Reply via email to