Package org.apache.felix.scr.impl.logger
Class ScrLogManager
- All Implemented Interfaces:
EventListener,org.osgi.framework.BundleListener,org.osgi.util.tracker.ServiceTrackerCustomizer<Object,Object>
Implements a SCR based log manager. This class was needed to not change the
whole codebase. It looks very similar to the old logging but leverages the
LogManager. This class implements the existing behavior and the
ExtLogManager implements the extension behavior. The scr()
method makes this distinction based on the configuration.-
Field Summary
Fields inherited from class org.osgi.util.tracker.ServiceTracker
context, filter -
Method Summary
Modifier and TypeMethodDescriptionaddingService(org.osgi.framework.ServiceReference<Object> reference) bundle(org.osgi.framework.Bundle bundle) This logger is used for the logging on a per bundle basis.voidbundleChanged(org.osgi.framework.BundleEvent event) voidclose()This logger is used for the logging on a per bundle basis.voidinit()Initializes the log manager.voidremovedService(org.osgi.framework.ServiceReference<Object> reference, Object service) scr()This logger is used for the main code of SCR.Methods inherited from class org.osgi.util.tracker.ServiceTracker
getService, getService, getServiceReference, getServiceReferences, getServices, getServices, getTracked, getTrackingCount, isEmpty, modifiedService, open, open, remove, size, waitForService
-
Method Details
-
scr
This logger is used for the main code of SCR. This will use the SCR bundle invalid input: '&' theLogger.ROOT_LOGGER_NAME- Returns:
- scr logger.
-
bundle
This logger is used for the logging on a per bundle basis. This will use the target bundle invalid input: '&' theLogger.ROOT_LOGGER_NAME- Parameters:
bundle- the target bundle- Returns:
- a logger suitable to log bundle entries
-
component
public ComponentLogger component(org.osgi.framework.Bundle bundle, String implementationClass, String name) This logger is used for the logging on a per bundle basis. This will use the target bundle invalid input: '&' the implementation class as logger name.- Parameters:
bundle- the target bundle- Returns:
- a logger suitable to log bundle entries
-
init
public void init()Initializes the log manager. This internally executes the following:-
Track all bundles for retrieving the log levels of each bundles if the log extension
is (
ds.log.extension) not set or set tofalse(log extension disabled) - Don't track any bundles if log extension is enabled since we don't need the log levels of the respective bundles. For log extension, we use the log level of the SCR bundle itself.
- Start the service tracker to track the OSGi LoggerFactory service
-
Track all bundles for retrieving the log levels of each bundles if the log extension
is (
-
addingService
-
removedService
-
bundleChanged
public void bundleChanged(org.osgi.framework.BundleEvent event) - Specified by:
bundleChangedin interfaceorg.osgi.framework.BundleListener
-
close
public void close()
-