19 #ifndef RTC_SYSTEMLOGGER_H 20 #define RTC_SYSTEMLOGGER_H 22 #include <rtm/config_rtc.h> 24 #include <coil/ClockManager.h> 25 #include <coil/Logger.h> 27 #include <coil/stringutil.h> 28 #include <coil/Properties.h> 135 explicit Logger(
const char* name =
"");
321 void setName(
const char* name);
346 void write(
int level,
const std::string &mes)
override;
396 return m_levelString[level];
423 return m_levelOutputString[level];
451 return m_levelColor[level];
497 std::string m_name =
"unknown";
498 std::string m_dateFormat =
"%b %d %H:%M:%S.%Q";
499 coil::IClock* m_clock{&coil::ClockManager::instance().getClock(
"system")};
501 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) 502 #ifdef LIBRARY_EXPORTS 503 static __declspec(dllexport)
const char*
const m_levelString[];
504 static __declspec(dllexport)
const char*
const m_levelOutputString[];
505 static __declspec(dllexport)
const char*
const m_levelColor[];
507 static __declspec(dllimport)
const char*
const m_levelString[];
508 static __declspec(dllimport)
const char*
const m_levelOutputString[];
509 static __declspec(dllimport)
const char*
const m_levelColor[];
512 static const char*
const m_levelString[];
513 static const char*
const m_levelOutputString[];
514 static const char*
const m_levelColor[];
516 bool m_msEnable{
false};
517 bool m_usEnable{
false};
537 #define RTC_LOG(LV, fmt) \ 539 if (rtclog.isValid(LV)) \ 541 std::string str = ::coil::sprintf fmt; \ 543 rtclog.write(LV, str); \ 548 #define RTC_LOG_STR(LV, str) \ 550 if (rtclog.isValid(LV)) \ 553 rtclog.write(LV, str); \ 577 #define RTC_FATAL(fmt) RTC_LOG(::RTC::Logger::RTL_FATAL, fmt) 578 #define RTC_FATAL_STR(str) RTC_LOG_STR(::RTC::Logger::RTL_FATAL, str) 599 #define RTC_ERROR(fmt) RTC_LOG(::RTC::Logger::RTL_ERROR, fmt) 600 #define RTC_ERROR_STR(str) RTC_LOG_STR(::RTC::Logger::RTL_ERROR, str) 621 #define RTC_WARN(fmt) RTC_LOG(::RTC::Logger::RTL_WARN, fmt) 622 #define RTC_WARN_STR(str) RTC_LOG_STR(::RTC::Logger::RTL_WARN, str) 643 #define RTC_INFO(fmt) RTC_LOG(::RTC::Logger::RTL_INFO, fmt) 644 #define RTC_INFO_STR(str) RTC_LOG_STR(::RTC::Logger::RTL_INFO, str) 665 #define RTC_DEBUG(fmt) RTC_LOG(::RTC::Logger::RTL_DEBUG, fmt) 666 #define RTC_DEBUG_STR(str) RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, str) 687 #define RTC_TRACE(fmt) RTC_LOG(::RTC::Logger::RTL_TRACE, fmt) 688 #define RTC_TRACE_STR(str) RTC_LOG_STR(::RTC::Logger::RTL_TRACE, str) 710 #define RTC_VERBOSE(fmt) RTC_LOG(::RTC::Logger::RTL_VERBOSE, fmt) 711 #define RTC_VERBOSE_STR(str) RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, str) 732 #define RTC_PARANOID(fmt) RTC_LOG(::RTC::Logger::RTL_PARANOID, fmt) 733 #define RTC_PARANOID_STR(str) RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, str) 736 #define RTC_FATAL(fmt) 737 #define RTC_FATAL_STR(str) 738 #define RTC_ERROR(fmt) 739 #define RTC_ERROR_STR(str) 740 #define RTC_WARN(fmt) 741 #define RTC_WARN_STR(str) 742 #define RTC_INFO(fmt) 743 #define RTC_INFO_STR(str) 744 #define RTC_DEBUG(fmt) 745 #define RTC_DEBUG_STR(str) 746 #define RTC_TRACE(fmt) 747 #define RTC_TRACE_STR(str) 748 #define RTC_VERBOSE(fmt) 749 #define RTC_VERBOSE_STR(str) 750 #define RTC_PARANOID(fmt) 751 #define RTC_PARANOID_STR(str) 752 #define RTC_FATAL(fmt) 753 #define RTC_FATAL_STR(str) 758 #endif // RTC_SYSTEMLOGGER_H bool setLevel(const char *level)
ログレベルを文字列で設定する
static std::string getLevelColor(int level)
ログレベルを対応したエスケープシケーンスに変換
Definition: SystemLogger.h:449
void setClockType(const std::string &clocktype)
ログ記録時に使用するクロックを指定する
Definition: SystemLogger.h:113
Definition: SystemLogger.h:110
Definition: SystemLogger.h:109
Logger(const char *name="")
コンストラクタ
std::string getDate()
フォーマットされた現在日時文字列を取得する。 指定された書式で記述しã...
static int strToLevel(const char *level)
ログレベル設定 与えられた文字列に対応したログレベルを設定する。 ...
::coil::LogStreamBuffer LogStreamBuf
Definition: SystemLogger.h:34
Definition: SystemLogger.h:105
Definition: SystemLogger.h:106
void setDateFormat(const char *format)
ヘッダに付加する日時フォーマットを指定する。
Definition: SystemLogger.h:108
Definition: SystemLogger.h:112
Logger クラス
Definition: SystemLogger.h:99
static std::string getLevelOutputString(int level)
ログレベルを対応した出力用の文字列に変換
Definition: SystemLogger.h:421
~Logger() override
仮想デストラクタ
static std::string getLevelString(int level)
ログレベルを数値から文字列に変換
Definition: SystemLogger.h:394
Definition: SystemLogger.h:111
Definition: SystemLogger.h:107
void write(int level, const std::string &mes) override
ログの出力
coil::Properties Properties
Definition: RTC.h:72
void setName(const char *name)
ヘッダの日時の後に付加する文字列を設定する。
::coil::LogStream LogStream
Definition: SystemLogger.h:35