Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogServiceFactory.java74
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

Back to the top