vsavchenko created this revision.
vsavchenko added reviewers: NoQ, dcoughlin.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun.
Herald added a project: clang.

It generalizes the way the output looks across any -jN.
Additionally it solves the buffering problems.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81601

Files:
  clang/utils/analyzer/SATestBuild.py


Index: clang/utils/analyzer/SATestBuild.py
===================================================================
--- clang/utils/analyzer/SATestBuild.py
+++ clang/utils/analyzer/SATestBuild.py
@@ -70,9 +70,27 @@
 # Helper functions.
 ###############################################################################
 
+class StreamToLogger:
+    def __init__(self, logger: logging.Logger,
+                 log_level: int = logging.INFO):
+        self.logger = logger
+        self.log_level = log_level
+
+    def write(self, message: str):
+        # Rstrip in order not to write an extra newline.
+        self.logger.log(self.log_level, message.rstrip())
+
+    def flush(self):
+        pass
+
+    def fileno(self) -> int:
+        return 0
+
+
+Logger = logging.getLogger("main")
 LOCAL = threading.local()
-LOCAL.stdout = sys.stdout
-LOCAL.stderr = sys.stderr
+LOCAL.stdout = StreamToLogger(Logger, logging.INFO)
+LOCAL.stderr = StreamToLogger(Logger, logging.ERROR)
 
 
 def stderr(message: str):
@@ -164,23 +182,6 @@
 VERBOSE = 0
 
 
-class StreamToLogger:
-    def __init__(self, logger: logging.Logger,
-                 log_level: int = logging.INFO):
-        self.logger = logger
-        self.log_level = log_level
-
-    def write(self, message: str):
-        # Rstrip in order not to write an extra newline.
-        self.logger.log(self.log_level, message.rstrip())
-
-    def flush(self):
-        pass
-
-    def fileno(self) -> int:
-        return 0
-
-
 ###############################################################################
 # Test harness logic.
 ###############################################################################


Index: clang/utils/analyzer/SATestBuild.py
===================================================================
--- clang/utils/analyzer/SATestBuild.py
+++ clang/utils/analyzer/SATestBuild.py
@@ -70,9 +70,27 @@
 # Helper functions.
 ###############################################################################
 
+class StreamToLogger:
+    def __init__(self, logger: logging.Logger,
+                 log_level: int = logging.INFO):
+        self.logger = logger
+        self.log_level = log_level
+
+    def write(self, message: str):
+        # Rstrip in order not to write an extra newline.
+        self.logger.log(self.log_level, message.rstrip())
+
+    def flush(self):
+        pass
+
+    def fileno(self) -> int:
+        return 0
+
+
+Logger = logging.getLogger("main")
 LOCAL = threading.local()
-LOCAL.stdout = sys.stdout
-LOCAL.stderr = sys.stderr
+LOCAL.stdout = StreamToLogger(Logger, logging.INFO)
+LOCAL.stderr = StreamToLogger(Logger, logging.ERROR)
 
 
 def stderr(message: str):
@@ -164,23 +182,6 @@
 VERBOSE = 0
 
 
-class StreamToLogger:
-    def __init__(self, logger: logging.Logger,
-                 log_level: int = logging.INFO):
-        self.logger = logger
-        self.log_level = log_level
-
-    def write(self, message: str):
-        # Rstrip in order not to write an extra newline.
-        self.logger.log(self.log_level, message.rstrip())
-
-    def flush(self):
-        pass
-
-    def fileno(self) -> int:
-        return 0
-
-
 ###############################################################################
 # Test harness logic.
 ###############################################################################
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to