AydarZaynutdinov commented on a change in pull request #16120:
URL: https://github.com/apache/beam/pull/16120#discussion_r762982261
##########
File path: playground/backend/internal/preparators/python_preparators.go
##########
@@ -15,7 +15,82 @@
package preparators
+import (
+ "beam.apache.org/playground/backend/internal/logger"
+ "bufio"
+ "io"
+ "os"
+)
+
+const (
+ addLogHandlerCode = "import logging\nlogging.basicConfig(\n
level=logging.DEBUG,\n format=\"%(asctime)s [%(levelname)s] %(message)s\",\n
handlers=[\n logging.FileHandler(\"logs.log\"),\n ]\n)\n"
+)
+
// GetPythonPreparators returns preparation methods that should be applied to
Python code
func GetPythonPreparators(filePath string) *[]Preparator {
- return &[]Preparator{}
+ addLogHandler := Preparator{
+ Prepare: addToCode,
+ Args: []interface{}{filePath, addLogHandlerCode},
+ }
+ return &[]Preparator{addLogHandler}
+}
+
+// addToCode processes file by filePath and adds additional code
Review comment:
`writeToFile(to *os.File, str string)` is a method that writes some
`str` to file `to`. I need to use this function 2 times:
- write additional code that will configure the python logger.
- write all code from the original file to the temporary file.
So that's why I didn't join methods `writeToFile()` with `writeCodeToFile`
(just avoid duplication).
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]