Normalized instantiation of loggers (#1138)

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
Christoph Weitkamp 2019-10-18 22:29:27 +02:00 committed by Wouter Born
parent 0fdd691c22
commit 21744d22b1
15 changed files with 19 additions and 21 deletions

View File

@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory;
@NonNullByDefault
public abstract class AbstractScriptEngineFactory implements ScriptEngineFactory {
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
protected final Logger logger = LoggerFactory.getLogger(AbstractScriptEngineFactory.class);
@Override
public List<String> getScriptTypes() {

View File

@ -43,10 +43,10 @@ import org.slf4j.LoggerFactory;
@Component(service = ScriptEngineManager.class)
public class ScriptEngineManagerImpl implements ScriptEngineManager {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private Map<String, @Nullable ScriptEngineContainer> loadedScriptEngineInstances = new HashMap<>();
private Map<String, @Nullable ScriptEngineFactory> customSupport = new HashMap<>();
private Map<String, @Nullable ScriptEngineFactory> genericSupport = new HashMap<>();
private final Logger logger = LoggerFactory.getLogger(ScriptEngineManagerImpl.class);
private final Map<String, @Nullable ScriptEngineContainer> loadedScriptEngineInstances = new HashMap<>();
private final Map<String, @Nullable ScriptEngineFactory> customSupport = new HashMap<>();
private final Map<String, @Nullable ScriptEngineFactory> genericSupport = new HashMap<>();
private @NonNullByDefault({}) ScriptExtensionManager scriptExtensionManager;
@Reference

View File

@ -41,7 +41,7 @@ import org.slf4j.LoggerFactory;
@NonNullByDefault
public abstract class AbstractScriptModuleHandler<T extends Module> extends BaseModuleHandler<T> {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private final Logger logger = LoggerFactory.getLogger(AbstractScriptModuleHandler.class);
/** Constant defining the configuration parameter of modules that specifies the mime type of a script */
protected static final String SCRIPT_TYPE = "type";

View File

@ -52,7 +52,7 @@ import org.slf4j.LoggerFactory;
@Component
public class ScriptModuleTypeProvider implements ModuleTypeProvider {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final Logger logger = LoggerFactory.getLogger(ScriptModuleTypeProvider.class);
private final List<ParameterOption> parameterOptions = new CopyOnWriteArrayList<>();
@SuppressWarnings("unchecked")

View File

@ -47,7 +47,7 @@ import org.slf4j.LoggerFactory;
@SuppressWarnings("rawtypes")
public abstract class AbstractCommandProvider<E> implements ServiceTrackerCustomizer {
protected Logger logger;
protected final Logger logger = LoggerFactory.getLogger(AbstractCommandProvider.class);
/**
* A bundle's execution context within the Framework.
@ -91,7 +91,6 @@ public abstract class AbstractCommandProvider<E> implements ServiceTrackerCustom
@SuppressWarnings("unchecked")
public AbstractCommandProvider(BundleContext context) {
this.bc = context;
logger = LoggerFactory.getLogger(AbstractCommandProvider.this.getClass());
parserTracker = new ServiceTracker(context, Parser.class.getName(), this);
parserTracker.open();
}

View File

@ -57,7 +57,7 @@ public class CompositeModuleHandlerFactory extends BaseModuleHandlerFactory impl
private final ModuleTypeRegistry mtRegistry;
private final RuleEngineImpl ruleEngine;
private final Logger logger = LoggerFactory.getLogger(getClass());
private final Logger logger = LoggerFactory.getLogger(CompositeModuleHandlerFactory.class);
/**
* The constructor of system handler factory for composite module types.

View File

@ -70,7 +70,6 @@ import org.slf4j.LoggerFactory;
public abstract class AbstractResourceBundleProvider<E> {
public AbstractResourceBundleProvider() {
logger = LoggerFactory.getLogger(this.getClass());
providedObjectsHolder = new ConcurrentHashMap<>();
providerPortfolio = new ConcurrentHashMap<>();
queue = new AutomationResourceBundlesEventQueue<>(this);
@ -92,7 +91,7 @@ public abstract class AbstractResourceBundleProvider<E> {
/**
* This field keeps instance of {@link Logger} that is used for logging.
*/
protected Logger logger = LoggerFactory.getLogger(this.getClass());
protected final Logger logger = LoggerFactory.getLogger(AbstractResourceBundleProvider.class);
/**
* A bundle's execution context within the Framework.

View File

@ -38,7 +38,7 @@ public class AutomationResourceBundlesEventQueue<E> implements Runnable {
/**
* This field keeps instance of {@link Logger} that is used for logging.
*/
protected Logger logger = LoggerFactory.getLogger(this.getClass());
protected final Logger logger = LoggerFactory.getLogger(AutomationResourceBundlesEventQueue.class);
/**
* This field serves for saving the BundleEvents for the bundles providing automation resources until their

View File

@ -50,7 +50,7 @@ import org.slf4j.LoggerFactory;
public abstract class AbstractFileProvider<E> implements Provider<E> {
protected static final String CONFIG_PROPERTY_ROOTS = "roots";
protected Logger logger = LoggerFactory.getLogger(this.getClass());
protected final Logger logger = LoggerFactory.getLogger(AbstractFileProvider.class);
protected String rootSubdirectory;
protected String[] configurationRoots;

View File

@ -40,7 +40,7 @@ public class ReferenceResolverUtilTest {
private static final Map<String, String> COMPOSITE_CHILD_MODULE_INPUTS_REFERENCES = new HashMap<>();
private static final Map<String, Object> EXPECTED_COMPOSITE_CHILD_MODULE_CONTEXT = new HashMap<>();
private final Logger logger = LoggerFactory.getLogger(getClass());
private final Logger logger = LoggerFactory.getLogger(ReferenceResolverUtilTest.class);
static {
// context from where references will be taken

View File

@ -23,7 +23,7 @@ import org.slf4j.LoggerFactory;
*/
abstract class AbstractNormalizer implements Normalizer {
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
protected final Logger logger = LoggerFactory.getLogger(AbstractNormalizer.class);
@Override
public final Object normalize(Object value) {

View File

@ -35,7 +35,7 @@ public abstract class BaseSmartHomeServlet extends HttpServlet {
/**
* Logger bound to child class.
*/
protected final Logger logger = LoggerFactory.getLogger(getClass());
protected final Logger logger = LoggerFactory.getLogger(BaseSmartHomeServlet.class);
/**
* Http service.

View File

@ -139,7 +139,7 @@ public interface ItemRegistry extends Registry<Item, String> {
*/
@Deprecated
default ItemBuilder newItemBuilder(Item item) {
LoggerFactory.getLogger(getClass())
LoggerFactory.getLogger(ItemRegistry.class)
.warn("Deprecation: You are using a deprecated API. Please use the ItemBuilder OSGi service instead.");
return new ItemBuilderImpl(Collections.singleton(new CoreItemFactory()), item);
}
@ -155,7 +155,7 @@ public interface ItemRegistry extends Registry<Item, String> {
*/
@Deprecated
default ItemBuilder newItemBuilder(String itemType, String itemName) {
LoggerFactory.getLogger(getClass())
LoggerFactory.getLogger(ItemRegistry.class)
.warn("Deprecation: You are using a deprecated API. Please use the ItemBuilder OSGi service instead.");
return new ItemBuilderImpl(Collections.singleton(new CoreItemFactory()), itemType, itemName);
}

View File

@ -38,7 +38,7 @@ public abstract class AbstractWatchService {
/**
* Default logger for ESH Watch Services
*/
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
protected final Logger logger = LoggerFactory.getLogger(AbstractWatchService.class);
protected String pathToWatch;

View File

@ -275,7 +275,7 @@ public class QueueingThreadPoolExecutorTest {
private static abstract class AbstractRunnable implements Runnable {
private static AtomicInteger runs = new AtomicInteger(0);
protected Logger logger = LoggerFactory.getLogger(this.getClass());
protected final Logger logger = LoggerFactory.getLogger(AbstractRunnable.class);
protected void sleep(int milliseconds) {
try {