0031188: Draw Harness - enable colorized messages output to console by default
authorkgv <kgv@opencascade.com>
Fri, 22 Nov 2019 21:08:22 +0000 (00:08 +0300)
committerbugmaster <bugmaster@opencascade.com>
Tue, 26 Nov 2019 15:35:38 +0000 (18:35 +0300)
Message_PrinterOStream now uses colorized output by default.
DRAWEXE has been corrected to disabled colorized output
when it is called with -f argument to avoid spoiling testgrid HTML logs.

src/Draw/Draw.cxx
src/Message/Message_PrinterOStream.cxx
src/Message/Message_PrinterOStream.hxx

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 )
index 5028d67..e28b239 100644 (file)
@@ -37,7 +37,7 @@ Message_PrinterOStream::Message_PrinterOStream (const Message_Gravity theTraceLe
 : myStream  (&std::cout),
   myIsFile  (Standard_False),
   myUseUtf8 (Standard_False),
-  myToColorize (Standard_False)
+  myToColorize (Standard_True)
 {
   myTraceLevel = theTraceLevel;
 }
@@ -53,7 +53,7 @@ Message_PrinterOStream::Message_PrinterOStream (const Standard_CString theFileNa
 : myStream (&std::cout),
   myIsFile (Standard_False),
   myUseUtf8 (Standard_False),
-  myToColorize (Standard_False)
+  myToColorize (Standard_True)
 {
   myTraceLevel = theTraceLevel;
   if (strcasecmp(theFileName, "cerr") == 0)
@@ -78,6 +78,7 @@ Message_PrinterOStream::Message_PrinterOStream (const Standard_CString theFileNa
   {
     myStream = (Standard_OStream* )aFile;
     myIsFile = Standard_True;
+    myToColorize = Standard_False;
   }
   else
   {
index ca10fdd..163a2ac 100644 (file)
@@ -74,7 +74,7 @@ public:
   //! Returns reference to the output stream
   Standard_OStream& GetStream() const { return *(Standard_OStream*)myStream; }
 
-  //! Returns TRUE if text output into console should be colorized depending on message gravity.
+  //! Returns TRUE if text output into console should be colorized depending on message gravity; TRUE by default.
   Standard_Boolean ToColorize() const { return myToColorize; }
 
   //! Set if text output into console should be colorized depending on message gravity.