[openrtm-commit:03386] r3454 - trunk/OpenRTM-aist/src/lib/rtm
openrtm @ openrtm.org
openrtm @ openrtm.org
2018年 12月 6日 (木) 17:40:59 JST
Author: miyamoto
Date: 2018-12-06 17:40:59 +0900 (Thu, 06 Dec 2018)
New Revision: 3454
Modified:
trunk/OpenRTM-aist/src/lib/rtm/DefaultConfiguration.h
trunk/OpenRTM-aist/src/lib/rtm/Manager.cpp
trunk/OpenRTM-aist/src/lib/rtm/SystemLogger.cpp
trunk/OpenRTM-aist/src/lib/rtm/SystemLogger.h
Log:
[incompat]
Modified: trunk/OpenRTM-aist/src/lib/rtm/DefaultConfiguration.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/DefaultConfiguration.h 2018-12-06 07:11:46 UTC (rev 3453)
+++ trunk/OpenRTM-aist/src/lib/rtm/DefaultConfiguration.h 2018-12-06 08:40:59 UTC (rev 3454)
@@ -57,6 +57,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: trunk/OpenRTM-aist/src/lib/rtm/Manager.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/Manager.cpp 2018-12-06 07:11:46 UTC (rev 3453)
+++ trunk/OpenRTM-aist/src/lib/rtm/Manager.cpp 2018-12-06 08:40:59 UTC (rev 3454)
@@ -1467,6 +1467,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: trunk/OpenRTM-aist/src/lib/rtm/SystemLogger.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/SystemLogger.cpp 2018-12-06 07:11:46 UTC (rev 3453)
+++ trunk/OpenRTM-aist/src/lib/rtm/SystemLogger.cpp 2018-12-06 08:40:59 UTC (rev 3454)
@@ -48,7 +48,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());
@@ -60,6 +60,8 @@
{
setClockType(prop["logger.clock_type"]);
}
+ coil::toBool(prop["logger.escape_sequence_enable"], "YES", "NO", false) ?
+ enableEscapeSequence() : disableEscapeSequence();
}
Logger::Logger(LogStreamBuf* streambuf)
@@ -68,7 +70,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());
}
@@ -127,23 +129,29 @@
* @endif
*/
void Logger::header(int 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)
+ {
+ 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 + ": ";
+ if (m_esEnable)
+ {
+ *this << "\x1b[0m";
+ }
+ }
/*!
* @if jp
@@ -216,4 +224,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: trunk/OpenRTM-aist/src/lib/rtm/SystemLogger.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/SystemLogger.h 2018-12-06 07:11:46 UTC (rev 3453)
+++ trunk/OpenRTM-aist/src/lib/rtm/SystemLogger.h 2018-12-06 08:40:59 UTC (rev 3454)
@@ -321,6 +321,43 @@
*/
void setName(const char* name);
+ /*!
+ * @if jp
+ *
+ * @brief エスケープシーケンスを有効にする
+ *
+ *
+ *
+ * @else
+ *
+ * @brief
+ *
+ * </pre>
+ *
+ *
+ *
+ * @endif
+ */
+ void enableEscapeSequence();
+ /*!
+ * @if jp
+ *
+ * @brief エスケープシーケンスを無効にする
+ *
+ *
+ *
+ * @else
+ *
+ * @brief
+ *
+ * </pre>
+ *
+ *
+ *
+ * @endif
+ */
+ void disableEscapeSequence();
+
protected:
/*!
* @if jp
@@ -378,6 +415,8 @@
*/
int strToLevel(const char* level);
+
+
private:
std::string m_name;
std::string m_dateFormat;
@@ -385,6 +424,7 @@
static const char* m_levelString[];
int m_msEnable;
int m_usEnable;
+ bool m_esEnable;
};
openrtm-commit メーリングリストの案内