blob: 9ef2562223640fe06565a6cae5bf426d75a0eaa9 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.felix.scr.impl.logger;
import org.apache.felix.scr.impl.manager.ScrConfiguration;
import org.osgi.framework.BundleContext;
import org.osgi.service.log.LoggerFactory;
import org.osgi.util.tracker.ServiceTracker;
/**
* This is the "global" logger used by the implementation for all logging
* not directly related to an extended bundle (and its components)
*/
public class ScrLogger extends LogServiceEnabledLogger
{
private final ScrConfiguration config;
public ScrLogger(final ScrConfiguration config, BundleContext context)
{
super(context.getBundle(), getTracker(context));
this.config = config;
}
@Override
InternalLogger getDefaultLogger()
{
return new StdOutLogger(config);
}
private static ServiceTracker<LoggerFactory, LoggerFactory> getTracker(
BundleContext context)
{
ServiceTracker<LoggerFactory, LoggerFactory> tracker = new ServiceTracker<>(
context, "org.osgi.service.log.LoggerFactory", null);
tracker.open();
return tracker;
}
public void closeTracker()
{
getLoggerFactoryTracker().close();
}
}