fvaleri commented on a change in pull request #193:
URL:
https://github.com/apache/camel-kafka-connector/pull/193#discussion_r428256345
##########
File path:
core/src/main/java/org/apache/camel/kafkaconnector/utils/TaskHelper.java
##########
@@ -93,4 +101,40 @@ private static Boolean stringStartWithOneOfPrefixes(String
s, Set<String> prefix
}
return false;
}
+
+ public static <CFG extends AbstractConfig> void logRecordContent(Logger
logger, ConnectRecord<?> record, CFG config) {
+ if (logger != null && record != null && config != null) {
+ // do not log record's content by default, as it may contain
sensitive information
+ LoggingLevel level = LoggingLevel.OFF;
+ try {
+ final String key = (record instanceof SourceRecord)
+ ?
CamelSourceConnectorConfig.CAMEL_SOURCE_CONTENT_LOG_LEVEL_CONF
+ :
CamelSinkConnectorConfig.CAMEL_SINK_CONTENT_LOG_LEVEL_CONF;
+ level =
LoggingLevel.valueOf(config.getString(key).trim().toUpperCase());
+ } catch (Throwable e) {
+ }
+ if (level != LoggingLevel.OFF &&
Arrays.asList(LoggingLevel.values()).contains(level)) {
Review comment:
Conflicts fixed.
> is this `Arrays.asList(LoggingLevel.values()).contains(level)` check
needed? or you can just log a warning in the `default` clasue of the `switch
case`?
Added a warning message in case of invalid level, thanks.
> In the end have you decided to not use `CamelLogger`? I am not implying is
wrong, I am just asking.
We can use it, but, unless I'm missing something, it seems that it does not
support string substitution, so we would be back to unnecessary object creation.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]