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)
Set log level by string.
static std::string getLevelColor(int level)
Definition: SystemLogger.h:449
void setClockType(const std::string &clocktype)
Specifying clock type to be used for logging.
Definition: SystemLogger.h:113
Definition: SystemLogger.h:110
Definition: SystemLogger.h:109
Logger(const char *name="")
Constructor.
std::string getDate()
Get the current formatted date/time string Get the current datetime described by specified format...
static int strToLevel(const char *level)
Set the log level Set the log level corresponding to the given string.
::coil::LogStreamBuffer LogStreamBuf
Definition: SystemLogger.h:34
Definition: SystemLogger.h:105
Definition: SystemLogger.h:106
void setDateFormat(const char *format)
Set date/time format for adding the header.
Definition: SystemLogger.h:108
Definition: SystemLogger.h:112
Logger class.
Definition: SystemLogger.h:99
static std::string getLevelOutputString(int level)
Definition: SystemLogger.h:421
~Logger() override
Virtual destructor.
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
log output
coil::Properties Properties
Definition: RTC.h:72
void setName(const char *name)
Set suffix of date/time string of header.
::coil::LogStream LogStream
Definition: SystemLogger.h:35