0031188: Draw Harness - enable colorized messages output to console by default
[occt.git] / src / Draw / Draw.cxx
index 5f90fdb..0f83347 100644 (file)
@@ -23,6 +23,9 @@
 #include <Draw_ProgressIndicator.hxx>
 #include <Draw_Window.hxx>
 #include <gp_Pnt2d.hxx>
+#include <Message.hxx>
+#include <Message_Messenger.hxx>
+#include <Message_PrinterOStream.hxx>
 #include <OSD.hxx>
 #include <OSD_Environment.hxx>
 #include <OSD_File.hxx>
@@ -496,7 +499,20 @@ void Draw_Appli(int argc, char** argv, const FDraw_InitAppli Draw_InitAppli)
   }
 
   // read commands from file
-  if (!aRunFile.IsEmpty()) {
+  if (!aRunFile.IsEmpty())
+  {
+    if (!isInteractiveForced)
+    {
+      // disable console messages colorization to avoid spoiling log with color codes
+      for (Message_SequenceOfPrinters::Iterator aPrinterIter (Message::DefaultMessenger()->Printers());
+           aPrinterIter.More(); aPrinterIter.Next())
+      {
+        if (Handle(Message_PrinterOStream) aPrinter = Handle(Message_PrinterOStream)::DownCast (aPrinterIter.Value()))
+        {
+          aPrinter->SetToColorize (Standard_False);
+        }
+      }
+    }
     ReadInitFile (aRunFile);
     // provide a clean exit, this is useful for some analysis tools
     if ( ! isInteractiveForced )