[openrtm-commit:03387] r3455 - branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm

openrtm @ openrtm.org openrtm @ openrtm.org
2018年 12月 6日 (木) 18:53:23 JST


Author: miyamoto
Date: 2018-12-06 18:53:23 +0900 (Thu, 06 Dec 2018)
New Revision: 3455

Modified:
   branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/DefaultConfiguration.h
   branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/Manager.cpp
   branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/SystemLogger.cpp
   branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/SystemLogger.h
Log:
[merge] r3454 has been merged from trunk.

Modified: branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/DefaultConfiguration.h
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/DefaultConfiguration.h	2018-12-06 08:40:59 UTC (rev 3454)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/DefaultConfiguration.h	2018-12-06 09:53:23 UTC (rev 3455)
@@ -56,6 +56,7 @@
     "logger.log_level",                      "INFO",
     "logger.stream_lock",                    "NO",
     "logger.master_logger",                  "",
+	"logger.escape_sequence_enable",         "NO",
     "module.conf_path",                      "",
     "module.load_path",                      "",
     "naming.enable",                         "YES",

Modified: branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/Manager.cpp
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/Manager.cpp	2018-12-06 08:40:59 UTC (rev 3454)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/Manager.cpp	2018-12-06 09:53:23 UTC (rev 3455)
@@ -1432,6 +1432,8 @@
     // Log stream mutex locking mode
     coil::toBool(m_config["logger.stream_lock"], "enable", "disable", false) ?
       rtclog.enableLock() : rtclog.disableLock();
+    coil::toBool(m_config["logger.escape_sequence_enable"], "YES", "NO", false) ?
+      rtclog.enableEscapeSequence() : rtclog.disableEscapeSequence();
 
     // File Logstream init
     initLogstreamFile();

Modified: branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/SystemLogger.cpp
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/SystemLogger.cpp	2018-12-06 08:40:59 UTC (rev 3454)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/SystemLogger.cpp	2018-12-06 09:53:23 UTC (rev 3455)
@@ -44,7 +44,7 @@
       m_name(name),
       m_dateFormat("%b %d %H:%M:%S.%Q"),
       m_clock(&coil::ClockManager::instance().getClock("system")),
-      m_msEnable(0), m_usEnable(0)
+      m_msEnable(0), m_usEnable(0), m_esEnable(0)
   {
     setLevel(Manager::instance().getLogLevel().c_str());
     coil::Properties& prop(Manager::instance().getConfig());
@@ -56,6 +56,8 @@
       {
         setClockType(prop["logger.clock_type"]);
       }
+    coil::toBool(prop["logger.escape_sequence_enable"], "YES", "NO", false) ?
+        enableEscapeSequence() : disableEscapeSequence();
   }
 
   Logger::Logger(LogStreamBuf* streambuf)
@@ -64,7 +66,7 @@
       m_name("unknown"),
       m_dateFormat("%b %d %H:%M:%S.%Q"),
       m_clock(&coil::ClockManager::instance().getClock("system")),
-      m_msEnable(0), m_usEnable(0)
+      m_msEnable(0), m_usEnable(0), m_esEnable(0)
   {
     setDateFormat(m_dateFormat.c_str());
   }
@@ -124,21 +126,27 @@
    */
   void Logger::header(int level)
   {
-    const char* color[] =
+    if (m_esEnable)
       {
-        "\x1b[0m",         // SLILENT  (none)
-        "\x1b[0m\x1b[31m", // FATAL    (red)
-        "\x1b[0m\x1b[35m", // ERROR    (magenta)
-        "\x1b[0m\x1b[33m", // WARN     (yellow)
-        "\x1b[0m\x1b[34m", // INFO     (blue)
-        "\x1b[0m\x1b[32m", // DEBUG    (green)
-        "\x1b[0m\x1b[36m", // TRACE    (cyan)
-        "\x1b[0m\x1b[39m", // VERBOSE  (default)
-        "\x1b[0m\x1b[37m"  // PARANOID (white)
-      };
-    *this << color[level];
+        const char* color[] =
+          {
+            "\x1b[0m",         // SLILENT  (none)
+            "\x1b[0m\x1b[31m", // FATAL    (red)
+            "\x1b[0m\x1b[35m", // ERROR    (magenta)
+            "\x1b[0m\x1b[33m", // WARN     (yellow)
+            "\x1b[0m\x1b[34m", // INFO     (blue)
+            "\x1b[0m\x1b[32m", // DEBUG    (green)
+            "\x1b[0m\x1b[36m", // TRACE    (cyan)
+            "\x1b[0m\x1b[39m", // VERBOSE  (default)
+            "\x1b[0m\x1b[37m"  // PARANOID (white)
+          };
+        *this << color[level];
+      }
     *this << getDate() + m_levelString[level] + m_name + ": ";
-    *this << "\x1b[0m";
+    if (m_esEnable)
+      {
+        *this << "\x1b[0m";
+      }
   }
 
   /*!
@@ -221,4 +229,44 @@
       return RTL_SILENT;
   }
 
+  /*!
+  * @if jp
+  *
+  * @brief ¥¨¥¹¥±¡¼¥×¥·¡¼¥±¥ó¥¹¤ÎÍ­¸ú¤Ë¤¹¤ë
+  *
+  *
+  * @else
+  *
+  * @brief
+  *
+  * </pre>
+  *
+  *
+  * @endif
+  */
+  void Logger::enableEscapeSequence()
+  {
+	  m_esEnable = true;
+  }
+
+  /*!
+  * @if jp
+  *
+  * @brief ¥¨¥¹¥±¡¼¥×¥·¡¼¥±¥ó¥¹¤Î̵¸ú¤Ë¤¹¤ë
+  *
+  *
+  * @else
+  *
+  * @brief
+  *
+  * </pre>
+  *
+  *
+  * @endif
+  */
+  void Logger::disableEscapeSequence()
+  {
+	  m_esEnable = false;
+  }
+
 }; // namespace RTC

Modified: branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/SystemLogger.h
===================================================================
--- branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/SystemLogger.h	2018-12-06 08:40:59 UTC (rev 3454)
+++ branches/RELENG_1_2/OpenRTM-aist/src/lib/rtm/SystemLogger.h	2018-12-06 09:53:23 UTC (rev 3455)
@@ -318,6 +318,42 @@
      * @endif
      */
     void setName(const char* name);
+    /*!
+     * @if jp
+     *
+     * @brief ¥¨¥¹¥±¡¼¥×¥·¡¼¥±¥ó¥¹¤òÍ­¸ú¤Ë¤¹¤ë
+     *
+     * 
+     *
+     * @else
+     *
+     * @brief 
+     * 
+     * </pre>
+     *
+     * 
+     *
+     * @endif
+     */
+    void enableEscapeSequence();
+    /*!
+     * @if jp
+     *
+     * @brief ¥¨¥¹¥±¡¼¥×¥·¡¼¥±¥ó¥¹¤ò̵¸ú¤Ë¤¹¤ë
+     *
+     *
+     *
+     * @else
+     *
+     * @brief
+     *
+     * </pre>
+     *
+     *
+     *
+     * @endif
+     */
+    void disableEscapeSequence();
 
   protected:
     /*!
@@ -383,6 +419,7 @@
     static const char* m_levelString[];
     int m_msEnable;
     int m_usEnable;
+    bool m_esEnable;
   };    
 
 



openrtm-commit メーリングリストの案内