diff options
author | Anjum Fatima | 2017-04-26 21:24:48 +0000 |
---|---|---|
committer | Thomas Watson | 2017-06-16 12:38:08 +0000 |
commit | 5bfcf92c80bd0a88f702c5c61e644db3144da53b (patch) | |
tree | 7006ca150e0a677eeb940eee786cd8df082f3e9e | |
parent | 627f7ad131b415ed7d9d39740c4615246273b805 (diff) | |
download | rt.equinox.framework-5bfcf92c80bd0a88f702c5c61e644db3144da53b.tar.gz rt.equinox.framework-5bfcf92c80bd0a88f702c5c61e644db3144da53b.tar.xz rt.equinox.framework-5bfcf92c80bd0a88f702c5c61e644db3144da53b.zip |
Bug 515869 - [osgi R7] Clarification on what a null value means for
LoggerAdmin
Change-Id: I2ecf6bc6e10296728e45cda1005d19d055e92f6d
Signed-off-by: Anjum Fatima <anjum.eclipse@gmail.com>
-rw-r--r-- | bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogServiceFactory.java | 74 |
1 files changed, 55 insertions, 19 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogServiceFactory.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogServiceFactory.java index a33f86c38..e6719a109 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogServiceFactory.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogServiceFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2016 Cognos Incorporated, IBM Corporation and others + * Copyright (c) 2006, 2017 Cognos Incorporated, IBM Corporation and others * All rights reserved. This program and the accompanying materials are made * available under the terms of the Eclipse Public License v1.0 which * accompanies this distribution, and is available at @@ -129,29 +129,36 @@ public class ExtendedLogServiceFactory implements ServiceFactory<ExtendedLogServ contextsLock.readLock().lock(); try { LogLevel level = null; - String lookupName = name; - while ((level = contextLogLevels.get(lookupName)) == null) { - int lastDot = lookupName.lastIndexOf('.'); - if (lastDot >= 0) { - lookupName = lookupName.substring(0, lastDot); - } else { - break; + String loggerName = name; + loggerName = isLoggerNamePresent(loggerName); + + if (loggerName != null) { + level = contextLogLevels.get(loggerName); + if (level == null && contextName != null) { + // non-null context name is a non-root context; + // must check the root context for non-root contexts + EquinoxLoggerContext rootContext = loggerContextTargetMap.getRootLoggerContext(); + if (rootContext != null) { + level = rootContext.getEffectiveLogLevel(loggerName); + } } + } - if (level == null) { - level = contextLogLevels.get(Logger.ROOT_LOGGER_NAME); - } - if (level == null && contextName != null) { - // non-null context name is a non-root context; - // must check the root context for non-root contexts - EquinoxLoggerContext rootContext = loggerContextTargetMap.getRootLoggerContext(); - if (rootContext != null) { - level = rootContext.getEffectiveLogLevel(name); + + else { + if (contextName != null) { + EquinoxLoggerContext rootContext = loggerContextTargetMap.getRootLoggerContext(); + if (rootContext != null) { + level = rootContext.getEffectiveLogLevel(name); + } + } } + if (level == null) { level = LogLevel.WARN; } + return level; } finally { contextsLock.readLock().unlock(); @@ -204,6 +211,35 @@ public class ExtendedLogServiceFactory implements ServiceFactory<ExtendedLogServ contextsLock.readLock().unlock(); } } - } -} + /* + * Purpose : To check whether lookupName is present in the contextLogLevels map or not + * and return the lookupName accordingly. + * + */ + public String isLoggerNamePresent(String lookupName) { + + String loggerName = lookupName; + while (!contextLogLevels.containsKey(loggerName)) { + int lastDot = loggerName.lastIndexOf('.'); + if (lastDot >= 0) { + loggerName = loggerName.substring(0, lastDot); + } else { + break; + } + } + + if (!contextLogLevels.containsKey(loggerName)) { + + if (contextLogLevels.containsKey(Logger.ROOT_LOGGER_NAME)) { + loggerName = Logger.ROOT_LOGGER_NAME; + } else { + loggerName = null; + } + } + + return loggerName; + } + + } +}
\ No newline at end of file |