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 @NonNullByDefault
public abstract class AbstractScriptEngineFactory implements ScriptEngineFactory { public abstract class AbstractScriptEngineFactory implements ScriptEngineFactory {
protected final Logger logger = LoggerFactory.getLogger(this.getClass()); protected final Logger logger = LoggerFactory.getLogger(AbstractScriptEngineFactory.class);
@Override @Override
public List<String> getScriptTypes() { public List<String> getScriptTypes() {

View File

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

View File

@ -41,7 +41,7 @@ import org.slf4j.LoggerFactory;
@NonNullByDefault @NonNullByDefault
public abstract class AbstractScriptModuleHandler<T extends Module> extends BaseModuleHandler<T> { 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 */ /** Constant defining the configuration parameter of modules that specifies the mime type of a script */
protected static final String SCRIPT_TYPE = "type"; protected static final String SCRIPT_TYPE = "type";

View File

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

View File

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

View File

@ -57,7 +57,7 @@ public class CompositeModuleHandlerFactory extends BaseModuleHandlerFactory impl
private final ModuleTypeRegistry mtRegistry; private final ModuleTypeRegistry mtRegistry;
private final RuleEngineImpl ruleEngine; 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. * 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 abstract class AbstractResourceBundleProvider<E> {
public AbstractResourceBundleProvider() { public AbstractResourceBundleProvider() {
logger = LoggerFactory.getLogger(this.getClass());
providedObjectsHolder = new ConcurrentHashMap<>(); providedObjectsHolder = new ConcurrentHashMap<>();
providerPortfolio = new ConcurrentHashMap<>(); providerPortfolio = new ConcurrentHashMap<>();
queue = new AutomationResourceBundlesEventQueue<>(this); 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. * 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. * 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. * 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 * 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> { public abstract class AbstractFileProvider<E> implements Provider<E> {
protected static final String CONFIG_PROPERTY_ROOTS = "roots"; 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 rootSubdirectory;
protected String[] configurationRoots; 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, String> COMPOSITE_CHILD_MODULE_INPUTS_REFERENCES = new HashMap<>();
private static final Map<String, Object> EXPECTED_COMPOSITE_CHILD_MODULE_CONTEXT = 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 { static {
// context from where references will be taken // context from where references will be taken

View File

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

View File

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

View File

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

View File

@ -275,7 +275,7 @@ public class QueueingThreadPoolExecutorTest {
private static abstract class AbstractRunnable implements Runnable { private static abstract class AbstractRunnable implements Runnable {
private static AtomicInteger runs = new AtomicInteger(0); 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) { protected void sleep(int milliseconds) {
try { try {