Get the declared level of the given logger.

@param loggerName logger name
@return logger level or <code>null</code> if logger is not defined or if the level of this logger is not defined.
184150
@Nullable
    public String getLoggerLevel(@Nullable String loggerName) {
        try {
            loggerName = loggerName == null ? "" : loggerName;
            if (loggerName.isEmpty()) {
                return LogManager.getRootLogger().getLevel().toString();
            }

            Logger logger = LogManager.exists(loggerName);
            if (logger == null) {
                return null;
            } else {
                Level level = logger.getLevel();
                if (level == null) {
                    return null;
                }
                return level.toString();
            }
        } catch (RuntimeException e) {
            logger.warn("Exception getting effective logger level " + loggerName, e);
            throw e;
        }
    }
489718
def getLogger(name):
    """"""
    logger = logging.getLogger(name)
    # note: the level might be adjusted via '-v' option
    logger.setLevel(logging_config['loggers']['gcdt']['level'])
    return logger
1003577
private String getLoggerName(String xrLoggerName) {

        String result = LOGGER_NAME_MAP.get(xrLoggerName);
        if (result != null) {
            return OCMS_PREFIX + result;
        } else {
            return OCMS_PREFIX + DEFAULT_LOGGER_NAME;
        }
    }
378607
@Override
    public Logger getLogger(String name) {
        // get the logger from the super impl
        Logger logger = super.getLogger(name);
        // At this point we don't know which concrete class to use until the
        // ras/logging provider is initialized enough to provide a
        // wsLogger class
        if (wsLogger == null) {
            return logger;
        }

        // The Java Logging (JSR47) spec requires that the method,
        // LogManager.getLogManager().getLogger(...) returns null if the logger
        // with the passed in name does not exist. However, the method
        // Logger.getLogger(...)
        // calls this method in order to create a new Logger object. In WAS, we
        // always want the call to Logger.getLogger(...) to return an instance
        // of WsLogger. If this method returns null to it (as the spec requires),
        // then Logger.getLogger() would return an instance of java.util.logging.Logger
        // rather than our WsLogger.
        // To account for this "issue", we need to return null when a customer
        // calls this method and passes in a non-existent logger name, but must
        // create a new WsLogger when Logger.getLogger() calls this method. As
        // such, the following code will get the current thread's stack trace
        // and look for a pattern like:
        // ...
        // at com.ibm.ws.bootstrap.WsLogManager.getLogger ...
        // at java.util.logging.Logger.getLogger ...
        // ...
        // If it identifies this pattern in the stacktrace, this method will
        // create a new logger. If not, it will return null.
        if (logger == null) {
            boolean createNewLogger = false;
            boolean foundCaller = false;

            Exception ex = new Exception();
            StackTraceElement[] ste = ex.getStackTrace();
            Class<?> caller = null;

            int i = 0;

            while (!foundCaller && i < ste.length) {
                StackTraceElement s = ste[i++];

                // A) look for com.ibm.ws.bootstrap.WsLogManager.getLogger
                if (s.getClassName().equals(CLASS_NAME) && s.getMethodName().equals("getLogger")) {
                    // B) java.util.logging.Logger.getLogger
                    while (!foundCaller && i < ste.length) {
                        s = ste[i++];
                        if (s.getClassName().equals("java.util.logging.Logger") && s.getMethodName().equals("getLogger")) {
                            createNewLogger = true;
                        } else if (createNewLogger) {
                            caller = StackFinderSingleton.instance.getCaller(i, s.getClassName());
                            foundCaller = caller != null;
                        }
                    }
                }
            }

            if (createNewLogger) {
                try {
                    logger = (Logger) wsLogger.newInstance(name, caller, null);
                    // constructing the new logger will add the logger to the log manager
                    // See the constructor com.ibm.ws.logging.internal.WsLogger.WsLogger(String, Class<?>, String)
                    // This is pretty unfortunate escaping of 'this' out of the constructor, but may be risky to try and fix that.
                    // Instead add a hack here to double check that another thread did not win in creating and adding the WsLogger instance
                    Logger checkLogger = super.getLogger(name);
                    if (checkLogger != null) {
                        // Simply reassign because checkLogger is for sure the one that got added.
                        // Not really sure what it would mean if null was returned from super.getLogger, but do nothing in that case
                        logger = checkLogger;
                    }
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        }

        return logger;
    }
561164
private static Integer getLogLevel(String tag) {
        Integer result = logLevels.get(tag);
        if (tag != null && result == null) {
            int index = tag.lastIndexOf(".");
            while (result == null && index > -1) {
                result = logLevels.get(tag.substring(0, index));
                index = tag.lastIndexOf(".", index - 1);
            }
        }
        return result;
    }
577495
public void setLevel(String logger, Level level) {
      Logger log = getLogger(logger);
      log.setLevel(level);
      for (String loggerName : getLoggerNames()) {
         if (loggerName.startsWith(logger) && !loggerName.equals(logger)) {
            getLogger(loggerName).setLevel(level);
         }
      }
   }
1168869
protected static int getLevel(String level, int defaultLogLevel) {
        try {
            return Integer.parseInt(level);
        } catch (NumberFormatException e) {
            // Try to read the string.
            if ("VERBOSE".equalsIgnoreCase(level)) {
                return Constants.VERBOSE;
            } else if ("DEBUG".equalsIgnoreCase(level)) {
                return Constants.DEBUG;
            } else if ("INFO".equalsIgnoreCase(level)) {
                return Constants.INFO;
            } else if ("WARN".equalsIgnoreCase(level)) {
                return Constants.WARN;
            } else if ("ERROR".equalsIgnoreCase(level)) {
                return Constants.ERROR;
            } else if ("ASSERT".equalsIgnoreCase(level)) {
                return Constants.ASSERT;
            }
        }

        return defaultLogLevel;
    }
669198
public synchronized Logger getLogger() {
    if (m_Logger == null) {
      m_Logger = Logger.getLogger(getClass().getName());
      m_Logger.setLevel(LoggingHelper.getLevel(getClass()));
    }
    return m_Logger;
  }
541708
def get_loglevel(level):
    
    try:
        return [logging.DEBUG, logging.INFO, logging.WARN][level]
    except IndexError:
        return logging.INFO
227772
private Level getLogLevel() {
        return isQuiet() ? Level.OFF : isVerbose() ? Level.DEBUG : Level.INFO;
    }
1262720
def get_logger(name):
    """"""
    logger = logging.getLogger(name)
    logger.setLevel(getenv('LOGLEVEL', 'INFO'))
    return logger
1343289
@Deprecated
    public int getLevel() {
        Level level = loggerProxy.getLevel();
        return level != null ? level.intValue() : 0;
    }
975381
final LoggerConfig get(String name) {
		final LoggerConfig config = new LoggerConfig();

		if (categories.isEmpty()) {
			config.merge(LoggerConfig.DEFAULT);
			return config;
		}

		if (name == null) {
			name = "";
		}

		while (true) {
			final int index = name.lastIndexOf('.');

			if (config.merge(categories.get(name)))
				return config;

			if (index != -1) {
				name = name.substring(0, index);
			} else {
				if (!config.merge(categories.get(""))) {
					config.merge(LoggerConfig.DEFAULT);
				}
				return config;
			}
		}
	}
344169
def loggerLevel(self, logger):
        
        try:
            return self._loggerLevels[logger]
        except KeyError:
            items = sorted(self._loggerLevels.items())
            for key, lvl in items:
                if logger.startswith(key):
                    return lvl
            return logging.NOTSET
387072
def getLevelInt(levelName):
    
    assert isinstance(levelName, str) and levelName in getLevelNames(), \
        "Bad debug level name"
    return  getLevelNames().index(levelName)+1
457516
@Route(method = HttpMethod.PUT, uri = "/monitor/logs/{name}")
    public Result setLevel(@Parameter("name") String loggerName, @Parameter("level") String level) {
        LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
        Logger logger = context.getLogger(loggerName);
        if (logger != null) {
            logger().info("Setting the log level of {} to {}", loggerName, level);
            ((ch.qos.logback.classic.Logger) logger).setLevel(Level.toLevel(level));
            return loggers();
        } else {
            logger().warn("Cannot set the level of logger {} - the logger does not exist", loggerName);
            return notFound();
        }
    }
1326491
def set_logger_level(logger_name, log_level='error'):
    '''
    
    '''
    logging.getLogger(logger_name).setLevel(
        LOG_LEVELS.get(log_level.lower(), logging.ERROR)
    )