From 733f196cf67d44c0d535cf195d16f8f1289b8629 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Mon, 9 Nov 2020 19:48:22 +0100 Subject: [PATCH] GH-592 Logging improvements in SimpleFunctionRegistry --- .../catalog/SimpleFunctionRegistry.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/catalog/SimpleFunctionRegistry.java b/spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/catalog/SimpleFunctionRegistry.java index 3b6e08e5d..e2b1ecab8 100644 --- a/spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/catalog/SimpleFunctionRegistry.java +++ b/spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/catalog/SimpleFunctionRegistry.java @@ -93,7 +93,7 @@ import org.springframework.util.StringUtils; */ public class SimpleFunctionRegistry implements FunctionRegistry, FunctionInspector { - Log logger = LogFactory.getLog(SimpleFunctionRegistry.class); + Log logger = LogFactory.getLog(this.getClass()); /** * Identifies MessageConversionExceptions that happen when input can't be converted. @@ -298,16 +298,20 @@ public class SimpleFunctionRegistry implements FunctionRegistry, FunctionInspect for (String name : names) { Object function = this.locateFunction(name); if (function == null) { - logger.debug("Failed to discover function '" + definition + "' in function catalog. " - + "Function available in catalog are: " + this.getNames(null) + ". This is generally " - + "acceptable for cases where there was no intention to use functions."); + if (logger.isDebugEnabled()) { + logger.debug("Failed to discover function '" + definition + "' in function catalog. " + + "Function available in catalog are: " + this.getNames(null) + ". This is generally " + + "acceptable for cases where there was no intention to use functions."); + } + return null; } else { Type functionType = this.discoverFunctionTypeByName(name); if (functionType != null && functionType.toString().contains("org.apache.kafka.streams.")) { - logger - .debug("Kafka Streams function '" + definition + "' is not supported by spring-cloud-function."); + if (logger.isDebugEnabled()) { + logger.debug("Kafka Streams function '" + definition + "' is not supported by spring-cloud-function."); + } return null; } } @@ -564,8 +568,7 @@ public class SimpleFunctionRegistry implements FunctionRegistry, FunctionInspect } if (!(this.target instanceof Consumer) && logger.isDebugEnabled()) { - logger - .debug("Result of invocation of \"" + this.functionDefinition + "\" function is '" + invocationResult + "'"); + logger.debug("Result of invocation of \"" + this.functionDefinition + "\" function is '" + invocationResult + "'"); } if (!(invocationResult instanceof Message)) { if (incomingMessage != null && invocationResult != null && incomingMessage.getHeaders().containsKey("scf-func-name")) {