Context manager to temporarily suppress all logging for a given logger
    or the root logger if no particular logger is specified.
163534
def disable_logging(logger=None):
    
    logger = logger or logging.getLogger()
    disabled = logger.disabled
    logger.disabled = True
    yield
    logger.disabled = disabled
18815
def setLoggerLevel(self, logger, level):
        
        if logger == 'root':
            _log = logging.getLogger()
        else:
            _log = logging.getLogger(logger)
        
        _log.setLevel(level)
        
        if level == logging.NOTSET:
            self._loggerLevels.pop(logger, None)
        else:
            self._loggerLevels[logger] = level
718641
def set_logger(self, logger):
        
        self.__logger = logger
        self.session.set_logger(self.__logger)
429673
def set_root_logger(root_log_level, log_path=None):
    
    handlers = []

    console_handler = logging.StreamHandler()
    handlers.append(console_handler)
    if log_path:
        file_handler = logging.FileHandler(log_path)
        handlers.append(file_handler)

    set_logging_config(root_log_level, handlers=handlers)
    root_logger = logging.getLogger("pypyr")
    root_logger.debug(
        f"Root logger {root_logger.name} configured with level "
        f"{root_log_level}")
218130
def setLoggerLevel(self, logger, level):
        
        if level == logging.NOTSET:
            self.removeLogger(logger)
            self.handler().setLoggerLevel(logger, level)
            return
            
        if isinstance(logger, logging.Logger):
            logger = logger.name
        
        if not logger in self._loggers:
            self.addLogger(logger, level)
        else:
            self.handler().setLoggerLevel(logger, level)
315384
final void removeChildLogger(LogManager.LoggerWeakRef child) {
        synchronized (treeLock) {
            for (Iterator<LogManager.LoggerWeakRef> iter = kids.iterator(); iter.hasNext(); ) {
                LogManager.LoggerWeakRef ref = iter.next();
                if (ref == child) {
                    iter.remove();
                    return;
                }
            }
        }
    }
308890
private void closeNonexistingAsyncAppenders() {
        org.apache.log4j.Logger rootLogger = LogManager.getRootLogger();
        if (NFLockFreeLogger.class.isInstance(rootLogger)) {
            ((NFLockFreeLogger)rootLogger).reconcileAppenders();
        }
        Enumeration enums = LogManager.getCurrentLoggers();
        while (enums.hasMoreElements()) {
            Object myLogger = enums.nextElement();
            if (NFLockFreeLogger.class.isInstance(myLogger)) {
                ((NFLockFreeLogger)myLogger).reconcileAppenders();
            }
        }
    }
929151
static synchronized void clearLogContext() {
        final LogContext embeddedLogContext = Holder.LOG_CONTEXT;
        // Remove the configurator and clear the log context
        final Configurator configurator = embeddedLogContext.getLogger("").detach(Configurator.ATTACHMENT_KEY);
        // If this was a PropertyConfigurator we can use the LogContextConfiguration API to tear down the LogContext
        if (configurator instanceof PropertyConfigurator) {
            final LogContextConfiguration logContextConfiguration = ((PropertyConfigurator) configurator).getLogContextConfiguration();
            clearLogContext(logContextConfiguration);
        } else if (configurator instanceof LogContextConfiguration) {
            clearLogContext((LogContextConfiguration) configurator);
        } else {
            // Remove all the handlers and close them as well as reset the loggers
            final List<String> loggerNames = Collections.list(embeddedLogContext.getLoggerNames());
            for (String name : loggerNames) {
                final Logger logger = embeddedLogContext.getLoggerIfExists(name);
                if (logger != null) {
                    final Handler[] handlers = logger.clearHandlers();
                    if (handlers != null) {
                        for (Handler handler : handlers) {
                            handler.close();
                        }
                    }
                    logger.setFilter(null);
                    logger.setUseParentFilters(false);
                    logger.setUseParentHandlers(true);
                    logger.setLevel(Level.INFO);
                }
            }
        }
    }
733222
def addLogger(self, logger, level=logging.INFO):
        
        if isinstance(logger, logging.Logger):
            logger = logger.name
        
        if logger in self._loggers:
            return
        
        # allow the handler to determine the level for this logger
        if logger == 'root':
            _log = logging.getLogger()
        else:
            _log = logging.getLogger(logger)
        
        _log.addHandler(self.handler())
        
        self._loggers.add(logger)
        self.handler().setLoggerLevel(logger, level)
1326412
def remove_loghandler (handler):
    """"""
    logging.getLogger(LOG_ROOT).removeHandler(handler)
    logging.getLogger().removeHandler(handler)
1000659
def sanitize_logger (self):
        """"""
        if not self['output']:
            log.warn(LOG_CHECK, _("activating text logger output."))
            self['output'] = 'text'
        self['logger'] = self.logger_new(self['output'])
1008188
private static void disableHandler(final LogContextConfiguration configuration, final String handlerName) {
        final HandlerConfiguration handlerConfiguration = configuration.getHandlerConfiguration(handlerName);
        try {
            handlerConfiguration.setPropertyValueString("enabled", "false");
            return;
        } catch (IllegalArgumentException e) {
            // do nothing
        }
        final Logger root = configuration.getLogContext().getLogger(CommonAttributes.ROOT_LOGGER_NAME);
        Map<String, String> disableHandlers = root.getAttachment(DISABLED_HANDLERS_KEY);
        synchronized (HANDLER_LOCK) {
            if (disableHandlers == null) {
                disableHandlers = new HashMap<String, String>();
                final Map<String, String> current = root.attachIfAbsent(DISABLED_HANDLERS_KEY, disableHandlers);
                if (current != null) {
                    disableHandlers = current;
                }
            }
            if (!disableHandlers.containsKey(handlerName)) {
                disableHandlers.put(handlerName, handlerConfiguration.getFilter());
                handlerConfiguration.setFilter(CommonAttributes.DENY.getName());
            }
        }
    }
1312392
public static synchronized void removeLogger(@NonNull JobLogger logger) {
        for (int i = 0; i < loggers.length; i++) {
            if (logger.equals(loggers[i])) {
                loggers[i] = null;
                // continue, maybe for some reason the logger is twice in the array
            }
        }
    }
356971
def create_logger_for_context(self, logger_name, context):
        

        if self._is_instance_of(context, 'AutoLoadCommandContext'):
            reservation_id = 'Autoload'
            handler_name = context.resource.name
        elif self._is_instance_of(context, 'UnreservedResourceCommandContext'):
            reservation_id = 'DeleteArtifacts'
            handler_name = context.resource.name
        else:
            reservation_id = self._get_reservation_id(context)

            if self._is_instance_of(context, 'ResourceCommandContext'):
                handler_name = context.resource.name
            elif self._is_instance_of(context, 'ResourceRemoteCommandContext'):
                handler_name = context.remote_endpoints[0].name
            else:
                raise Exception(ContextBasedLoggerFactory.UNSUPPORTED_CONTEXT_PROVIDED, context)

        logger = get_qs_logger(log_file_prefix=handler_name,
                               log_group=reservation_id,
                               log_category=logger_name)
        return logger
1214337
def set_root_logger(config=None, **kwargs):
    
    config = config or app_config
    logging_config = config.get('logging') or {}
    kwargs.setdefault('level', logging_config.get('level'))
    kwargs.setdefault('format', logging_config.get('format'))
    logging.basicConfig(**kwargs)
1323229
public static void configureNoLogging() {
    final Logger rootLogger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    final LoggerContext context = rootLogger.getLoggerContext();

    // Clear context, removing all appenders
    context.reset();

    // Set logging level to OFF
    for (final Logger logger : context.getLoggerList()) {
      if (logger != rootLogger) {
        logger.setLevel(null);
      }
    }
    rootLogger.setLevel(OFF);
  }
939167
public static void stop() {
    final ILoggerFactory loggerFactory = org.slf4j.LoggerFactory.getILoggerFactory();
    if (loggerFactory instanceof LoggerContext) {
      final LoggerContext context = (LoggerContext) loggerFactory;
      context.stop();
    }
    setup.getAndSet(false);
  }