@contextmanager
def disable_logger(logger=None):
    "context manager to temporarily disable logging\n\n    This is to provide one of swallow_logs' purposes without unnecessarily\n    creating temp files (see gh-1865)\n\n    Parameters\n    ----------\n    logger: Logger\n        Logger whose handlers will be ordered to not log anything.\n        Default: datalad's topmost Logger ('datalad')\n    "

    class NullFilter(logging.Filter):
        'Filter class to reject all records\n        '

        def filter(self, record):
            return 0
    if (logger is None):
        logger = logging.getLogger('datalad')
    filter_ = NullFilter(logger.name)
    [h.addFilter(filter_) for h in logger.handlers]
    try:
        (yield logger)
    finally:
        [h.removeFilter(filter_) for h in logger.handlers]
context manager to temporarily disable logging

This is to provide one of swallow_logs' purposes without unnecessarily
creating temp files (see gh-1865)

Parameters
----------
logger: Logger
    Logger whose handlers will be ordered to not log anything.
    Default: datalad's topmost Logger ('datalad')
@contextmanager
def disable_logger(logger=None):
    "context manager to temporarily disable logging\n\n    This is to provide one of swallow_logs' purposes without unnecessarily\n    creating temp files (see gh-1865)\n\n    Parameters\n    ----------\n    logger: Logger\n        Logger whose handlers will be ordered to not log anything.\n        Default: datalad's topmost Logger ('datalad')\n    "

    class NullFilter(logging.Filter):
        'Filter class to reject all records\n        '

        def filter(self, record):
            return 0
    if (logger is None):
        logger = logging.getLogger('datalad')
    filter_ = NullFilter(logger.name)
    [h.addFilter(filter_) for h in logger.handlers]
    try:
        (yield logger)
    finally:
        [h.removeFilter(filter_) for h in logger.handlers]