exceptionfactory commented on code in PR #8407:
URL: https://github.com/apache/nifi/pull/8407#discussion_r1490140332


##########
nifi-nar-bundles/nifi-py4j-bundle/nifi-py4j-bridge/src/main/java/org/apache/nifi/py4j/PythonProcessLogReader.java:
##########
@@ -0,0 +1,140 @@
+/*
+ * 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.nifi.py4j;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.util.Objects;
+
+/**
+ * Runnable Command for reading a line from Process Output Stream and writing 
to a Logger
+ */
+class PythonProcessLogReader implements Runnable {
+    private static final int LOG_LEVEL_BEGIN_INDEX = 0;
+
+    private static final int LOG_LEVEL_END_INDEX = 2;
+
+    private static final int MESSAGE_BEGIN_INDEX = 3;
+
+    private static final int MINIMUM_LINE_LENGTH = 4;
+
+    private static final char NAME_MESSAGE_SEPARATOR = ':';
+
+    private static final int INDEX_NOT_FOUND = -1;
+
+    private final Logger processLogger = 
LoggerFactory.getLogger("org.apache.nifi.py4j.ProcessLog");
+
+    private final BufferedReader processReader;
+
+    PythonProcessLogReader(final BufferedReader processReader) {
+        this.processReader = Objects.requireNonNull(processReader, "Reader 
required");
+    }
+
+    @Override
+    public void run() {
+        try {
+            String line = processReader.readLine();
+            while (line != null) {
+                if (line.length() > MINIMUM_LINE_LENGTH) {
+                    processLine(line);
+                }
+                line = processReader.readLine();
+            }
+        } catch (final IOException e) {
+            processLogger.error("Read Process output failed", e);

Review Comment:
   The logger name may help, but your suggestion is definitely clearer.



-- 
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.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to