added default NullHandler support for py26
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/d6458c03 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/d6458c03 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/d6458c03 Branch: refs/heads/cli-tests Commit: d6458c0391877f531471fec5764ee2d2dec21ec8 Parents: 207cc09 Author: max-orlov <ma...@gigaspaces.com> Authored: Thu Apr 13 17:05:57 2017 +0300 Committer: max-orlov <ma...@gigaspaces.com> Committed: Thu Apr 13 17:05:57 2017 +0300 ---------------------------------------------------------------------- aria/logger.py | 9 +++++++++ aria/storage/core.py | 5 ++--- 2 files changed, 11 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d6458c03/aria/logger.py ---------------------------------------------------------------------- diff --git a/aria/logger.py b/aria/logger.py index bbb6c7a..41e1ac8 100644 --- a/aria/logger.py +++ b/aria/logger.py @@ -21,6 +21,15 @@ import logging from logging import handlers as logging_handlers from datetime import datetime +# NullHandler doesn't exist in < 27. this workaround is from +# http://docs.python.org/release/2.6/library/logging.html#configuring-logging-for-a-library +try: + from logging import NullHandler +except ImportError: + class NullHandler(logging.Handler): + def emit(self, record): + pass + TASK_LOGGER_NAME = 'aria.executions.task' http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d6458c03/aria/storage/core.py ---------------------------------------------------------------------- diff --git a/aria/storage/core.py b/aria/storage/core.py index 0e900bb..8caca66 100644 --- a/aria/storage/core.py +++ b/aria/storage/core.py @@ -37,9 +37,8 @@ API: * drivers - module, a pool of ARIA standard drivers. * StorageDriver - class, abstract model implementation. """ -import logging -from aria.logger import LoggerMixin +from aria.logger import LoggerMixin, NullHandler from . import sql_mapi __all__ = ( @@ -75,7 +74,7 @@ class Storage(LoggerMixin): # Set the logger handler of any storage object to NullHandler. # This is since the absence of a handler shows up while using the CLI in the form of: # `No handlers could be found for logger "aria.ResourceStorage"`. - self.logger.addHandler(logging.NullHandler()) + self.logger.addHandler(NullHandler()) self.api = api_cls self.registered = {} self._initiator = initiator