diff options
Diffstat (limited to 'bundles/org.eclipse.osgi')
5 files changed, 34 insertions, 19 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ConfigAdminListener.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ConfigAdminListener.java index 3c3fbb2ab..5c96d3abd 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ConfigAdminListener.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ConfigAdminListener.java @@ -39,7 +39,6 @@ class ConfigAdminListener implements ServiceTrackerCustomizer<Object, ServiceReg private static final String METHOD_CONFIG_GET_FACTORY_PID = "getFactoryPid"; //$NON-NLS-1$ private static final String PID_PREFIX_LOG_ADMIN = "org.osgi.service.log.admin"; //$NON-NLS-1$ - private static final String NULL_LEVEL = "NULL"; //$NON-NLS-1$ // using String constructor here to avoid interning private static final String PID_FILTER = '(' + Constants.SERVICE_PID + '=' + PID_PREFIX_LOG_ADMIN + '*' + ')'; @@ -225,14 +224,10 @@ class ConfigAdminListener implements ServiceTrackerCustomizer<Object, ServiceReg String key = keys.nextElement(); Object v = configDictionary.get(key); if (v instanceof String) { - if (NULL_LEVEL.equals(v)) { - result.put(key, null); - } else { - try { - result.put(key, LogLevel.valueOf((String) v)); - } catch (IllegalArgumentException e) { - // ignore invalid values - } + try { + result.put(key, LogLevel.valueOf((String) v)); + } catch (IllegalArgumentException e) { + // ignore invalid values } } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogServices.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogServices.java index 985356d35..a84617d79 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogServices.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/EquinoxLogServices.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2016 IBM Corporation and others. + * Copyright (c) 2006, 2017 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 @@ -22,6 +22,8 @@ import org.eclipse.osgi.internal.framework.EquinoxConfiguration; import org.eclipse.osgi.service.datalocation.Location; import org.eclipse.osgi.storage.StorageUtil; import org.osgi.framework.*; +import org.osgi.service.log.LogLevel; +import org.osgi.service.log.admin.LoggerContext; public class EquinoxLogServices { static final String EQUINOX_LOGGER_NAME = "org.eclipse.equinox.logger"; //$NON-NLS-1$ @@ -81,7 +83,18 @@ public class EquinoxLogServices { // ignore and use 0 } } - logServiceManager = new LogServiceManager(logHistoryMax, logWriter, perfWriter); + + LogLevel defaultLevel = LogLevel.WARN; + try { + String defaultLevelConfig = environmentInfo.getConfiguration(LoggerContext.LOGGER_CONTEXT_DEFAULT_LOGLEVEL); + if (defaultLevelConfig != null) { + defaultLevel = LogLevel.valueOf(defaultLevelConfig); + } + } catch (IllegalArgumentException e) { + //ignore and use LogLevel.WARN + } + + logServiceManager = new LogServiceManager(logHistoryMax, defaultLevel, logWriter, perfWriter); eclipseLogFactory = new EquinoxLogFactory(logWriter, logServiceManager); rootFrameworkLog = eclipseLogFactory.createFrameworkLog(null, logWriter); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogReaderServiceFactory.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogReaderServiceFactory.java index bebcf7bc2..18a62cc11 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogReaderServiceFactory.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/ExtendedLogReaderServiceFactory.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 @@ -54,6 +54,7 @@ public class ExtendedLogReaderServiceFactory implements ServiceFactory<ExtendedL private final ThreadLocal<int[]> nestedCallCount = new ThreadLocal<>(); private final LinkedList<LogEntry> history; private final int maxHistory; + private final LogLevel defaultLevel; static boolean safeIsLoggable(LogFilter filter, Bundle bundle, String name, int level) { try { @@ -97,7 +98,8 @@ public class ExtendedLogReaderServiceFactory implements ServiceFactory<ExtendedL } } - public ExtendedLogReaderServiceFactory(int maxHistory) { + public ExtendedLogReaderServiceFactory(int maxHistory, LogLevel defaultLevel) { + this.defaultLevel = defaultLevel; this.maxHistory = maxHistory; if (maxHistory > 0) { history = new LinkedList<>(); @@ -106,6 +108,10 @@ public class ExtendedLogReaderServiceFactory implements ServiceFactory<ExtendedL } } + public LogLevel getDefaultLogLevel() { + return defaultLevel; + } + public ExtendedLogReaderServiceImpl getService(Bundle bundle, ServiceRegistration<ExtendedLogReaderServiceImpl> registration) { return new ExtendedLogReaderServiceImpl(this); } @@ -293,4 +299,5 @@ public class ExtendedLogReaderServiceFactory implements ServiceFactory<ExtendedL return Collections.enumeration(new ArrayList<>(history)); } } + } 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..e20994355 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 @@ -25,7 +25,7 @@ public class ExtendedLogServiceFactory implements ServiceFactory<ExtendedLogServ final ReentrantReadWriteLock contextsLock = new ReentrantReadWriteLock(); final LoggerContextTargetMap loggerContextTargetMap = new LoggerContextTargetMap(); private final Permission logPermission = new LogPermission("*", LogPermission.LOG); //$NON-NLS-1$ - private final ExtendedLogReaderServiceFactory logReaderServiceFactory; + final ExtendedLogReaderServiceFactory logReaderServiceFactory; private final LoggerAdmin loggerAdmin = new EquinoxLoggerAdmin(); public ExtendedLogServiceFactory(ExtendedLogReaderServiceFactory logReaderServiceFactory) { @@ -150,7 +150,7 @@ public class ExtendedLogServiceFactory implements ServiceFactory<ExtendedLogServ } } if (level == null) { - level = LogLevel.WARN; + level = logReaderServiceFactory.getDefaultLogLevel(); } return level; } finally { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/LogServiceManager.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/LogServiceManager.java index 98baab7fd..8ee51d9dc 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/LogServiceManager.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/log/LogServiceManager.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 @@ -35,8 +35,8 @@ public class LogServiceManager implements BundleListener, FrameworkListener, Ser private EventAdminAdapter eventAdminAdapter; private ConfigAdminListener configAdminListener; - public LogServiceManager(int maxHistory, LogListener... systemListeners) { - logReaderServiceFactory = new ExtendedLogReaderServiceFactory(maxHistory); + public LogServiceManager(int maxHistory, LogLevel defaultLevel, LogListener... systemListeners) { + logReaderServiceFactory = new ExtendedLogReaderServiceFactory(maxHistory, defaultLevel); logServiceFactory = new ExtendedLogServiceFactory(logReaderServiceFactory); systemBundleLog = logServiceFactory.getLogService(new MockSystemBundle()); for (LogListener logListener : systemListeners) { |