SystemLoggerTests.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
11 /*
12  * $Log: SystemLoggerTests.cpp,v $
13  * Revision 1.2 2008/05/12 03:58:45 arafune
14  * Added some tests.
15  * Rearranged tests in a different order.
16  *
17  * Revision 1.1 2008/05/09 12:01:44 arafune
18  * The first commitment.
19  *
20  *
21  */
22 
23 #ifndef SystemLoggerTests_cpp
24 #define SystemLoggerTests_cpp
25 
26 #include <cppunit/ui/text/TestRunner.h>
27 #include <cppunit/TextOutputter.h>
28 #include <cppunit/extensions/TestFactoryRegistry.h>
29 #include <cppunit/extensions/HelperMacros.h>
30 #include <cppunit/TestAssert.h>
31 
32 #include <coil/Task.h>
33 #include <coil/DynamicLib.h>
34 
35 #include <rtm/SystemLogger.h>
36 #include <coil/TimeMeasure.h>
37 #include <rtm/Manager.h>
38 
43 namespace Tests
44 {
45  // protected: 関数のテスト用 class LoggerMock : public RTC::Logger { public: // コンストラクタ LoggerMock(RTC::LogStreamBuf* streambuf) : RTC::Logger(streambuf) {} virtual ~LoggerMock(void) {} void setDateFormat(const char* format) { // std::cout << "LoggerMock::setDateFormat() IN" << std::endl; RTC::Logger::setDateFormat(format); mock_m_dateFormat = std::string(format); // std::cout << "LoggerMock::setDateFormat() OUT" << std::endl; } void setName(const char* name) { // std::cout << "LoggerMock::setName() IN" << std::endl; RTC::Logger::setName(name); mock_m_name = name; // std::cout << "LoggerMock::setName() OUT" << std::endl; } void header(int level) { // std::cout << "LoggerMock::header() IN" << std::endl; RTC::Logger::header(level); // std::cout << "LoggerMock::header() OUT" << std::endl; } std::string getDate(void) { // std::cout << "LoggerMock::getDate() IN" << std::endl; return RTC::Logger::getDate(); } int strToLevel(const char* level) { // std::cout << "LoggerMock::strToLevel() IN" << std::endl; return RTC::Logger::strToLevel(level); } // デッドロック確認用 std::string test_string(void) { // std::cout << "LoggerMock::test_string() IN" << std::endl; this->lock(); this->level(RTC::Logger::RTL_TRACE) << "RTC_TRACE2 test_string()" << std::endl; this->unlock(); // std::cout << "LoggerMock::test_string() OUT" << std::endl; return std::string("TestString"); } std::string mock_m_name; std::string mock_m_dateFormat; }; /*! * * * */ class SystemLoggerTests : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(SystemLoggerTests); CPPUNIT_TEST(test_setLevel); CPPUNIT_TEST(test_setDateFormat); CPPUNIT_TEST(test_setName); CPPUNIT_TEST(test_header); CPPUNIT_TEST(test_getDate); CPPUNIT_TEST(test_strToLevel); CPPUNIT_TEST(test_logfile_PARANOID); CPPUNIT_TEST(test_logfile_VERBOSE); CPPUNIT_TEST(test_logfile_TRACE); CPPUNIT_TEST(test_logfile_DEBUG); CPPUNIT_TEST(test_logfile_INFO); CPPUNIT_TEST(test_logfile_WARNING); CPPUNIT_TEST(test_logfile_ERROR); CPPUNIT_TEST(test_logfile_FATAL); CPPUNIT_TEST(test_logfile_SILENT); CPPUNIT_TEST(test_constract_name); CPPUNIT_TEST(test_deadlock); CPPUNIT_TEST_SUITE_END(); private: protected: public: /*! * @brief Constructor */ SystemLoggerTests() { } /*! * @brief Destructor */ virtual ~SystemLoggerTests() { } /*! * @brief Test initialization */ virtual void setUp() { } /*! * @brief Test finalization */ virtual void tearDown() { } /*! * @brief setLevel()メソッドのテスト * * - ログレベルの文字列を正しく設定できるか? */ void test_setLevel(void) { // std::cout << "test_setLevel() IN" << std::endl; coil::LogStreamBuffer logger; std::stringstream s0; logger.addStream(s0.rdbuf()); LoggerMock rtclog(&logger); // ログレベル設定で、引数に規定値・規定外を設定して正しく動作するか? CPPUNIT_ASSERT(rtclog.setLevel("SILENT")); //規定値 CPPUNIT_ASSERT(rtclog.setLevel("FATAL")); CPPUNIT_ASSERT(rtclog.setLevel("ERROR")); CPPUNIT_ASSERT(rtclog.setLevel("WARN")); CPPUNIT_ASSERT(rtclog.setLevel("INFO")); CPPUNIT_ASSERT(rtclog.setLevel("DEBUG")); CPPUNIT_ASSERT(rtclog.setLevel("TRACE")); CPPUNIT_ASSERT(rtclog.setLevel("VERBOSE")); CPPUNIT_ASSERT(rtclog.setLevel("PARANOID")); CPPUNIT_ASSERT(rtclog.setLevel("other")); //規定外 // std::cout << "test_setLevel() OUT" << std::endl; } /*! * @brief setDateFormat()メソッドのテスト * * - ヘッダに付加する日時フォーマットを正しく指定できるか? */ void test_setDateFormat(void) { // std::cout << "test_setDateFormat() IN" << std::endl; coil::LogStreamBuffer logger; std::stringstream s0; std::string rstr; logger.addStream(s0.rdbuf()); LoggerMock rtclog(&logger); // ヘッダに付加する日時フォーマットを正しく指定できるか? rtclog.setDateFormat(""); rstr = rtclog.getDate(); CPPUNIT_ASSERT(rstr.size() == 0); CPPUNIT_ASSERT_EQUAL(std::string(""), rtclog.mock_m_dateFormat); rtclog.setDateFormat("%b %d %H:%M:%S"); rstr = rtclog.getDate(); CPPUNIT_ASSERT(rstr.size() > 0); CPPUNIT_ASSERT_EQUAL(std::string("%b %d %H:%M:%S"), rtclog.mock_m_dateFormat); // std::cout << "test_setDateFormat() OUT" << std::endl; } /*! * @brief setName()メソッドのテスト * * - ヘッダの日時の後に付加する文字列を正しく設定できるか? */ void test_setName(void) { // std::cout << "test_setName() IN" << std::endl; coil::LogStreamBuffer logger; std::stringstream s0; logger.addStream(s0.rdbuf()); LoggerMock rtclog(&logger); rtclog.setDateFormat(""); // ヘッダの日時の後に付加する文字列を正しく設定できるか? rtclog.setName(""); // 付加文字列:なし rtclog.header(rtclog.RTL_DEBUG); CPPUNIT_ASSERT_EQUAL(std::string(""), rtclog.mock_m_name); CPPUNIT_ASSERT_EQUAL(std::string(" DEBUG: : "), s0.str()); s0.str(""); rtclog.setName("TestName"); // 付加文字列:あり rtclog.header(rtclog.RTL_DEBUG); CPPUNIT_ASSERT_EQUAL(std::string("TestName"), rtclog.mock_m_name); CPPUNIT_ASSERT_EQUAL(std::string(" DEBUG: TestName: "), s0.str()); // std::cout << "test_setName() OUT" << std::endl; } /*! * @brief header()メソッドのテスト * * - メッセージのプリフィックス追加を正しく設定できるか? */ void test_header(void) { // std::cout << "test_header() IN" << std::endl; coil::LogStreamBuffer logger; std::stringstream s0; logger.addStream(s0.rdbuf()); LoggerMock rtclog(&logger); // メッセージのプリフィックス追加を正しく設定できるか? rtclog.setDateFormat(""); rtclog.setName(""); rtclog.header(rtclog.RTL_SILENT); CPPUNIT_ASSERT_EQUAL(std::string(" SILENT: : "), s0.str()); s0.str(""); rtclog.header(rtclog.RTL_FATAL); CPPUNIT_ASSERT_EQUAL(std::string(" FATAL: : "), s0.str()); s0.str(""); rtclog.header(rtclog.RTL_ERROR); CPPUNIT_ASSERT_EQUAL(std::string(" ERROR: : "), s0.str()); s0.str(""); rtclog.header(rtclog.RTL_WARN); CPPUNIT_ASSERT_EQUAL(std::string(" WARNING: : "), s0.str()); s0.str(""); rtclog.header(rtclog.RTL_INFO); CPPUNIT_ASSERT_EQUAL(std::string(" INFO: : "), s0.str()); s0.str(""); rtclog.header(rtclog.RTL_DEBUG); CPPUNIT_ASSERT_EQUAL(std::string(" DEBUG: : "), s0.str()); s0.str(""); rtclog.header(rtclog.RTL_TRACE); CPPUNIT_ASSERT_EQUAL(std::string(" TRACE: : "), s0.str()); s0.str(""); rtclog.header(rtclog.RTL_VERBOSE); CPPUNIT_ASSERT_EQUAL(std::string(" VERBOSE: : "), s0.str()); s0.str(""); rtclog.header(rtclog.RTL_PARANOID); CPPUNIT_ASSERT_EQUAL(std::string(" PARANOID: : "), s0.str()); // std::cout << "test_header() OUT" << std::endl; } /*! * @brief getDate()メソッドのテスト * * - フォーマットされた現在日時文字列を正しく取得できるか? */ void test_getDate(void) { // std::cout << "test_getDate() IN" << std::endl; coil::LogStreamBuffer logger; std::stringstream s0; std::string rstr; logger.addStream(s0.rdbuf()); LoggerMock rtclog(&logger); // フォーマットされた現在日時文字列を正しく取得できるか? rtclog.setDateFormat(""); rstr = rtclog.getDate(); CPPUNIT_ASSERT(rstr.size() == 0); rtclog.setDateFormat("%b %d %H:%M:%S"); rstr = rtclog.getDate(); CPPUNIT_ASSERT(rstr.size() > 0); // std::cout << "test_getDate() OUT" << std::endl; } /*! * @brief strToLevel()メソッドのテスト * * - ログレベルを正しく設定できるか? */ void test_strToLevel(void) { // std::cout << "test_strToLevel() IN" << std::endl; coil::LogStreamBuffer logger; std::stringstream s0; logger.addStream(s0.rdbuf()); LoggerMock rtclog(&logger); // ログレベル設定で、引数に規定値・規定外を設定して正しく動作するか? CPPUNIT_ASSERT(rtclog.strToLevel("SILENT") == rtclog.RTL_SILENT); //規定値 CPPUNIT_ASSERT(rtclog.strToLevel("FATAL") == rtclog.RTL_FATAL); CPPUNIT_ASSERT(rtclog.strToLevel("ERROR") == rtclog.RTL_ERROR); CPPUNIT_ASSERT(rtclog.strToLevel("WARN") == rtclog.RTL_WARN); CPPUNIT_ASSERT(rtclog.strToLevel("INFO") == rtclog.RTL_INFO); CPPUNIT_ASSERT(rtclog.strToLevel("DEBUG") == rtclog.RTL_DEBUG); CPPUNIT_ASSERT(rtclog.strToLevel("TRACE") == rtclog.RTL_TRACE); CPPUNIT_ASSERT(rtclog.strToLevel("VERBOSE") == rtclog.RTL_VERBOSE); CPPUNIT_ASSERT(rtclog.strToLevel("PARANOID") == rtclog.RTL_PARANOID); CPPUNIT_ASSERT(rtclog.strToLevel("other") == rtclog.RTL_SILENT); //規定外 // std::cout << "test_strToLevel() OUT" << std::endl; } /*! * @brief logfile出力のテスト * * - ログレベルを PARANOID にした場合のファイル出力が正しく行われるか? */ void test_logfile_PARANOID(void) { // std::cout << "test_logfile_PARANOID() IN" << std::endl; coil::LogStreamBuffer logger; std::string logfile("rtcPARANOID.log"); std::filebuf of; of.open(logfile.c_str(), std::ios::out); if (!of.is_open()) { std::cerr << "Error: cannot open logfile: " << logfile << std::endl; } logger.addStream(&of, true); RTC::Logger rtclog(&logger); rtclog.setName("Test"); rtclog.setDateFormat("%b %d %H:%M:%S"); rtclog.setLevel("PARANOID"); // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか? RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str"); RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt")); RTC_PARANOID_STR("Macro RTL_PARANOID tests str"); RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str"); RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt")); RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str"); RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str"); RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt")); RTC_TRACE_STR("Macro RTL_TRACE tests str"); RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str"); RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt")); RTC_DEBUG_STR("Macro RTL_DEBUG tests str"); RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str"); RTC_INFO( ("Macro RTL_INFO tests %s","fmt")); RTC_INFO_STR("Macro RTL_INFO tests str"); RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str"); RTC_WARN( ("Macro RTL_WARN tests %s","fmt")); RTC_WARN_STR("Macro RTL_WARN tests str"); RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str"); RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt")); RTC_ERROR_STR("Macro RTL_ERROR tests str"); RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str"); RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt")); RTC_FATAL_STR("Macro RTL_FATAL tests str"); RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str"); of.close(); // ファイル出力があるか? std::string rstr; std::ifstream ifs(logfile.c_str()); ifs >> rstr; CPPUNIT_ASSERT(rstr.size() > 0); ifs >> rstr; ifs >> rstr; ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("PARANOID:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("RTL_PARANOID"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr); // std::cout << "test_logfile_PARANOID() OUT" << std::endl; } /*! * @brief logfile出力のテスト * * - ログレベルを VERBOSE にした場合のファイル出力が正しく行われるか? */ void test_logfile_VERBOSE(void) { // std::cout << "test_logfile_VERBOSE() IN" << std::endl; coil::LogStreamBuffer logger; std::string logfile("rtcVERBOSE.log"); std::filebuf of; of.open(logfile.c_str(), std::ios::out); if (!of.is_open()) { std::cerr << "Error: cannot open logfile: " << logfile << std::endl; } logger.addStream(&of, true); RTC::Logger rtclog(&logger); rtclog.setName("Test"); rtclog.setDateFormat("%b %d %H:%M:%S"); rtclog.setLevel("VERBOSE"); // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか? RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str"); RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt")); RTC_PARANOID_STR("Macro RTL_PARANOID tests str"); RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str"); RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt")); RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str"); RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str"); RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt")); RTC_TRACE_STR("Macro RTL_TRACE tests str"); RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str"); RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt")); RTC_DEBUG_STR("Macro RTL_DEBUG tests str"); RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str"); RTC_INFO( ("Macro RTL_INFO tests %s","fmt")); RTC_INFO_STR("Macro RTL_INFO tests str"); RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str"); RTC_WARN( ("Macro RTL_WARN tests %s","fmt")); RTC_WARN_STR("Macro RTL_WARN tests str"); RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str"); RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt")); RTC_ERROR_STR("Macro RTL_ERROR tests str"); RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str"); RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt")); RTC_FATAL_STR("Macro RTL_FATAL tests str"); RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str"); of.close(); // ファイル出力があるか? std::string rstr; std::ifstream ifs(logfile.c_str()); ifs >> rstr; CPPUNIT_ASSERT(rstr.size() > 0); ifs >> rstr; ifs >> rstr; ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("VERBOSE:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("RTL_VERBOSE"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr); // std::cout << "test_logfile_VERBOSE() OUT" << std::endl; } /*! * @brief logfile出力のテスト * * - ログレベルを TRACE にした場合のファイル出力が正しく行われるか? */ void test_logfile_TRACE(void) { // std::cout << "test_logfile_TRACE() IN" << std::endl; coil::LogStreamBuffer logger; std::string logfile("rtcTRACE.log"); std::filebuf of; of.open(logfile.c_str(), std::ios::out); if (!of.is_open()) { std::cerr << "Error: cannot open logfile: " << logfile << std::endl; } logger.addStream(&of, true); RTC::Logger rtclog(&logger); rtclog.setName("Test"); rtclog.setDateFormat("%b %d %H:%M:%S"); rtclog.setLevel("TRACE"); // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか? RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str"); RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt")); RTC_PARANOID_STR("Macro RTL_PARANOID tests str"); RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str"); RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt")); RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str"); RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str"); RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt")); RTC_TRACE_STR("Macro RTL_TRACE tests str"); RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str"); RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt")); RTC_DEBUG_STR("Macro RTL_DEBUG tests str"); RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str"); RTC_INFO( ("Macro RTL_INFO tests %s","fmt")); RTC_INFO_STR("Macro RTL_INFO tests str"); RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str"); RTC_WARN( ("Macro RTL_WARN tests %s","fmt")); RTC_WARN_STR("Macro RTL_WARN tests str"); RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str"); RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt")); RTC_ERROR_STR("Macro RTL_ERROR tests str"); RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str"); RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt")); RTC_FATAL_STR("Macro RTL_FATAL tests str"); RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str"); of.close(); // ファイル出力があるか? std::string rstr; std::ifstream ifs(logfile.c_str()); ifs >> rstr; CPPUNIT_ASSERT(rstr.size() > 0); ifs >> rstr; ifs >> rstr; ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("TRACE:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("RTL_TRACE"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr); // std::cout << "test_logfile_TRACE() OUT" << std::endl; } /*! * @brief logfile出力のテスト * * - ログレベルを DEBUG にした場合のファイル出力が正しく行われるか? */ void test_logfile_DEBUG(void) { // std::cout << "test_logfile_DEBUG() IN" << std::endl; coil::LogStreamBuffer logger; std::string logfile("rtcDEBUG.log"); std::filebuf of; of.open(logfile.c_str(), std::ios::out); if (!of.is_open()) { std::cerr << "Error: cannot open logfile: " << logfile << std::endl; } logger.addStream(&of, true); RTC::Logger rtclog(&logger); rtclog.setName("Test"); rtclog.setDateFormat("%b %d %H:%M:%S"); rtclog.setLevel("DEBUG"); // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか? RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str"); RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt")); RTC_PARANOID_STR("Macro RTL_PARANOID tests str"); RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str"); RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt")); RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str"); RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str"); RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt")); RTC_TRACE_STR("Macro RTL_TRACE tests str"); RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str"); RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt")); RTC_DEBUG_STR("Macro RTL_DEBUG tests str"); RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str"); RTC_INFO( ("Macro RTL_INFO tests %s","fmt")); RTC_INFO_STR("Macro RTL_INFO tests str"); RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str"); RTC_WARN( ("Macro RTL_WARN tests %s","fmt")); RTC_WARN_STR("Macro RTL_WARN tests str"); RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str"); RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt")); RTC_ERROR_STR("Macro RTL_ERROR tests str"); RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str"); RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt")); RTC_FATAL_STR("Macro RTL_FATAL tests str"); RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str"); of.close(); // ファイル出力があるか? std::string rstr; std::ifstream ifs(logfile.c_str()); ifs >> rstr; CPPUNIT_ASSERT(rstr.size() > 0); ifs >> rstr; ifs >> rstr; ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("DEBUG:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("RTL_DEBUG"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr); // std::cout << "test_logfile_DEBUG() OUT" << std::endl; } /*! * @brief logfile出力のテスト * * - ログレベルを INFO にした場合のファイル出力が正しく行われるか? */ void test_logfile_INFO(void) { // std::cout << "test_logfile_INFO() IN" << std::endl; coil::LogStreamBuffer logger; std::string logfile("rtcINFO.log"); std::filebuf of; of.open(logfile.c_str(), std::ios::out); if (!of.is_open()) { std::cerr << "Error: cannot open logfile: " << logfile << std::endl; } logger.addStream(&of, true); RTC::Logger rtclog(&logger); rtclog.setName("Test"); rtclog.setDateFormat("%b %d %H:%M:%S"); rtclog.setLevel("INFO"); // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか? RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str"); RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt")); RTC_PARANOID_STR("Macro RTL_PARANOID tests str"); RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str"); RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt")); RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str"); RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str"); RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt")); RTC_TRACE_STR("Macro RTL_TRACE tests str"); RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str"); RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt")); RTC_DEBUG_STR("Macro RTL_DEBUG tests str"); RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str"); RTC_INFO( ("Macro RTL_INFO tests %s","fmt")); RTC_INFO_STR("Macro RTL_INFO tests str"); RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str"); RTC_WARN( ("Macro RTL_WARN tests %s","fmt")); RTC_WARN_STR("Macro RTL_WARN tests str"); RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str"); RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt")); RTC_ERROR_STR("Macro RTL_ERROR tests str"); RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str"); RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt")); RTC_FATAL_STR("Macro RTL_FATAL tests str"); RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str"); of.close(); // ファイル出力があるか? std::string rstr; std::ifstream ifs(logfile.c_str()); ifs >> rstr; CPPUNIT_ASSERT(rstr.size() > 0); ifs >> rstr; ifs >> rstr; ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("INFO:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("RTL_INFO"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr); // std::cout << "test_logfile_INFO() OUT" << std::endl; } /*! * @brief logfile出力のテスト * * - ログレベルを WARNING にした場合のファイル出力が正しく行われるか? */ void test_logfile_WARNING(void) { // std::cout << "test_logfile_WARNING() IN" << std::endl; coil::LogStreamBuffer logger; std::string logfile("rtcWARNING.log"); std::filebuf of; of.open(logfile.c_str(), std::ios::out); if (!of.is_open()) { std::cerr << "Error: cannot open logfile: " << logfile << std::endl; } logger.addStream(&of, true); RTC::Logger rtclog(&logger); rtclog.setName("Test"); rtclog.setDateFormat("%b %d %H:%M:%S"); rtclog.setLevel("WARN"); // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか? RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str"); RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt")); RTC_PARANOID_STR("Macro RTL_PARANOID tests str"); RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str"); RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt")); RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str"); RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str"); RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt")); RTC_TRACE_STR("Macro RTL_TRACE tests str"); RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str"); RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt")); RTC_DEBUG_STR("Macro RTL_DEBUG tests str"); RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str"); RTC_INFO( ("Macro RTL_INFO tests %s","fmt")); RTC_INFO_STR("Macro RTL_INFO tests str"); RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str"); RTC_WARN( ("Macro RTL_WARN tests %s","fmt")); RTC_WARN_STR("Macro RTL_WARN tests str"); RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str"); RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt")); RTC_ERROR_STR("Macro RTL_ERROR tests str"); RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str"); RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt")); RTC_FATAL_STR("Macro RTL_FATAL tests str"); RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str"); of.close(); // ファイル出力があるか? std::string rstr; std::ifstream ifs(logfile.c_str()); ifs >> rstr; CPPUNIT_ASSERT(rstr.size() > 0); ifs >> rstr; ifs >> rstr; ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("WARNING:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("RTL_WARN"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr); // std::cout << "test_logfile_WARNING() OUT" << std::endl; } /*! * @brief logfile出力のテスト * * - ログレベルを ERROR にした場合のファイル出力が正しく行われるか? */ void test_logfile_ERROR(void) { // std::cout << "test_logfile_ERROR() IN" << std::endl; coil::LogStreamBuffer logger; std::string logfile("rtcERROR.log"); std::filebuf of; of.open(logfile.c_str(), std::ios::out); if (!of.is_open()) { std::cerr << "Error: cannot open logfile: " << logfile << std::endl; } logger.addStream(&of, true); RTC::Logger rtclog(&logger); rtclog.setName("Test"); rtclog.setDateFormat("%b %d %H:%M:%S"); rtclog.setLevel("ERROR"); // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか? RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str"); RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt")); RTC_PARANOID_STR("Macro RTL_PARANOID tests str"); RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str"); RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt")); RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str"); RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str"); RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt")); RTC_TRACE_STR("Macro RTL_TRACE tests str"); RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str"); RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt")); RTC_DEBUG_STR("Macro RTL_DEBUG tests str"); RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str"); RTC_INFO( ("Macro RTL_INFO tests %s","fmt")); RTC_INFO_STR("Macro RTL_INFO tests str"); RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str"); RTC_WARN( ("Macro RTL_WARN tests %s","fmt")); RTC_WARN_STR("Macro RTL_WARN tests str"); RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str"); RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt")); RTC_ERROR_STR("Macro RTL_ERROR tests str"); RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str"); RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt")); RTC_FATAL_STR("Macro RTL_FATAL tests str"); RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str"); of.close(); // ファイル出力があるか? std::string rstr; std::ifstream ifs(logfile.c_str()); ifs >> rstr; CPPUNIT_ASSERT(rstr.size() > 0); ifs >> rstr; ifs >> rstr; ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("ERROR:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("RTL_ERROR"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr); // std::cout << "test_logfile_ERROR() OUT" << std::endl; } /*! * @brief logfile出力のテスト * * - ログレベルを FATAL にした場合のファイル出力が正しく行われるか? */ void test_logfile_FATAL(void) { // std::cout << "test_logfile_FATAL() IN" << std::endl; coil::LogStreamBuffer logger; std::string logfile("rtcFATAL.log"); std::filebuf of; of.open(logfile.c_str(), std::ios::out); if (!of.is_open()) { std::cerr << "Error: cannot open logfile: " << logfile << std::endl; } logger.addStream(&of, true); RTC::Logger rtclog(&logger); rtclog.setName("Test"); rtclog.setDateFormat("%b %d %H:%M:%S"); rtclog.setLevel("FATAL"); // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか? RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str"); RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt")); RTC_PARANOID_STR("Macro RTL_PARANOID tests str"); RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str"); RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt")); RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str"); RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str"); RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt")); RTC_TRACE_STR("Macro RTL_TRACE tests str"); RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str"); RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt")); RTC_DEBUG_STR("Macro RTL_DEBUG tests str"); RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str"); RTC_INFO( ("Macro RTL_INFO tests %s","fmt")); RTC_INFO_STR("Macro RTL_INFO tests str"); RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str"); RTC_WARN( ("Macro RTL_WARN tests %s","fmt")); RTC_WARN_STR("Macro RTL_WARN tests str"); RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str"); RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt")); RTC_ERROR_STR("Macro RTL_ERROR tests str"); RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str"); RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt")); RTC_FATAL_STR("Macro RTL_FATAL tests str"); RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str"); of.close(); // ファイル出力があるか? std::string rstr; std::ifstream ifs(logfile.c_str()); ifs >> rstr; CPPUNIT_ASSERT(rstr.size() > 0); ifs >> rstr; ifs >> rstr; ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("FATAL:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("RTL_FATAL"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr); // std::cout << "test_logfile_FATAL() OUT" << std::endl; } /*! * @brief logfile出力のテスト * * - ログレベルを SILENT にした場合のファイル出力が正しく行われるか? */ void test_logfile_SILENT(void) { // std::cout << "test_logfile_SILENT() IN" << std::endl; coil::LogStreamBuffer logger; std::string logfile("rtcSILENT.log"); std::filebuf of; of.open(logfile.c_str(), std::ios::out); if (!of.is_open()) { std::cerr << "Error: cannot open logfile: " << logfile << std::endl; } logger.addStream(&of, true); RTC::Logger rtclog(&logger); rtclog.setName("Test"); rtclog.setDateFormat("%b %d %H:%M:%S"); rtclog.setLevel("SILENT"); // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか? RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str"); RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt")); RTC_PARANOID_STR("Macro RTL_PARANOID tests str"); RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str"); RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt")); RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str"); RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str"); RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt")); RTC_TRACE_STR("Macro RTL_TRACE tests str"); RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str"); RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt")); RTC_DEBUG_STR("Macro RTL_DEBUG tests str"); RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str"); RTC_INFO( ("Macro RTL_INFO tests %s","fmt")); RTC_INFO_STR("Macro RTL_INFO tests str"); RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str"); RTC_WARN( ("Macro RTL_WARN tests %s","fmt")); RTC_WARN_STR("Macro RTL_WARN tests str"); RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str"); RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt")); RTC_ERROR_STR("Macro RTL_ERROR tests str"); RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str"); RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt")); RTC_FATAL_STR("Macro RTL_FATAL tests str"); RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str"); of.close(); // ファイル出力があるか? std::string rstr; std::ifstream ifs(logfile.c_str()); ifs >> rstr; CPPUNIT_ASSERT(rstr.size() > 0); ifs >> rstr; ifs >> rstr; ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("SILENT:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("RTL_SILENT"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr); // std::cout << "test_logfile_SILENT() OUT" << std::endl; } /*! * @brief コンストラクタログレベルのテスト * * - コンストラクタ(name)の場合、Managerの設定ログレベル(INFO)で動作するか? */ void test_constract_name(void) { // std::cout << "test_constract_name() IN" << std::endl; RTC::Manager* m_mgr; m_mgr = RTC::Manager::init(0, NULL); CPPUNIT_ASSERT(m_mgr != NULL); RTC::Logger rtclog("TestName"); std::string log_level = m_mgr->getLogLevel(); CPPUNIT_ASSERT_EQUAL(std::string("INFO"), log_level); coil::Properties m_config = m_mgr->getConfig(); std::vector<std::string> logouts = coil::split(m_config["logger.file_name"], ","); // 汎用ログ出力マクロ、各種ログ出力マクロでファイル出力 RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str"); RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt")); RTC_PARANOID_STR("Macro RTL_PARANOID tests str"); RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str"); RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt")); RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str"); RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str"); RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt")); RTC_TRACE_STR("Macro RTL_TRACE tests str"); RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str"); RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt")); RTC_DEBUG_STR("Macro RTL_DEBUG tests str"); RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str"); RTC_INFO( ("Macro RTL_INFO tests %s","fmt")); RTC_INFO_STR("Macro RTL_INFO tests str"); RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str"); RTC_WARN( ("Macro RTL_WARN tests %s","fmt")); RTC_WARN_STR("Macro RTL_WARN tests str"); RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str"); RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt")); RTC_ERROR_STR("Macro RTL_ERROR tests str"); RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str"); RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt")); RTC_FATAL_STR("Macro RTL_FATAL tests str"); RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str"); m_mgr->terminate(); // rtc*.log ファイルが作成され、4列目のログレベルが INFO以下か? // INFO WARNING ERROR FATAL SILENT だけが記録されているか? // Aug 03 14:03:09 INFO: manager: OpenRTM-aist-1.0.0 // [0] 1 2 3 4 5 std::string rstr; std::vector<std::string> vstr; bool bret; std::ifstream ifs(logouts[0].c_str()); while(getline(ifs, rstr)) { if(rstr.size() == 0) break; vstr = coil::split(rstr, " "); // ログレベル判定 bret = false; if( (vstr[3] == "INFO:") || (vstr[3] == "WARNING:") || (vstr[3] == "ERROR:") || (vstr[3] == "FATAL:") || (vstr[3] == "SILENT:") ) bret = true; CPPUNIT_ASSERT(bret); // name判定 bret = false; if( (vstr[4] == "manager:") || (vstr[4] == "TestName:") || (vstr[4] == "NamingOnCorba:") || (vstr[4] == "NamingManager:") || (vstr[4] == "ManagerServant:") ) bret = true; CPPUNIT_ASSERT(bret); } // std::cout << "test_constract_name() OUT" << std::endl; } /*! * @brief ログ出力のデッドロックテスト * * - RTC_LOG出力時、引数の関数内でログ出力がある場合にデッドロックしないか? */ void test_deadlock(void) { // std::cout << "test_deadlock() IN" << std::endl; coil::LogStreamBuffer logger; std::stringstream s0; logger.addStream(s0.rdbuf()); LoggerMock rtclog(&logger); rtclog.setName("Test"); rtclog.setDateFormat(""); rtclog.setLevel("TRACE"); s0.str(""); // ロックモード設定 rtclog.enableLock(); RTC_TRACE(("RTC_TRACE1 %s", rtclog.test_string().c_str())); std::string rstr; getline(s0, rstr); CPPUNIT_ASSERT_EQUAL(std::string(" TRACE: Test: RTC_TRACE2 test_string()"), rstr); getline(s0, rstr); CPPUNIT_ASSERT_EQUAL(std::string(" TRACE: Test: RTC_TRACE1 TestString"), rstr); // ロックモード解除 rtclog.disableLock(); // std::cout << "test_deadlock() OUT" << std::endl; } }; }; // namespace Tests /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(Tests::SystemLoggerTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // SystemLoggerTests_cpp
46  class LoggerMock : public RTC::Logger
47  {
48  public:
49  // コンストラクタ
51  : RTC::Logger(streambuf) {}
52  virtual ~LoggerMock(void) {}
53 
54 
55  void setDateFormat(const char* format)
56  {
57 // std::cout << "LoggerMock::setDateFormat() IN" << std::endl;
59  mock_m_dateFormat = std::string(format);
60 // std::cout << "LoggerMock::setDateFormat() OUT" << std::endl;
61  }
62 
63  void setName(const char* name)
64  {
65 // std::cout << "LoggerMock::setName() IN" << std::endl;
67  mock_m_name = name;
68 // std::cout << "LoggerMock::setName() OUT" << std::endl;
69  }
70 
71  void header(int level)
72  {
73 // std::cout << "LoggerMock::header() IN" << std::endl;
74  RTC::Logger::header(level);
75 // std::cout << "LoggerMock::header() OUT" << std::endl;
76  }
77 
78  std::string getDate(void)
79  {
80 // std::cout << "LoggerMock::getDate() IN" << std::endl;
81  return RTC::Logger::getDate();
82  }
83 
84  int strToLevel(const char* level)
85  {
86 // std::cout << "LoggerMock::strToLevel() IN" << std::endl;
87  return RTC::Logger::strToLevel(level);
88  }
89 
90  // デッドロック確認用
91  std::string test_string(void)
92  {
93 // std::cout << "LoggerMock::test_string() IN" << std::endl;
94  this->lock();
95  this->level(RTC::Logger::RTL_TRACE) << "RTC_TRACE2 test_string()" << std::endl;
96  this->unlock();
97 // std::cout << "LoggerMock::test_string() OUT" << std::endl;
98  return std::string("TestString");
99  }
100 
101  std::string mock_m_name;
102  std::string mock_m_dateFormat;
103  };
104 
105 
112  : public CppUnit::TestFixture
113  {
114  CPPUNIT_TEST_SUITE(SystemLoggerTests);
115 
116  CPPUNIT_TEST(test_setLevel);
117  CPPUNIT_TEST(test_setDateFormat);
118  CPPUNIT_TEST(test_setName);
119  CPPUNIT_TEST(test_header);
120  CPPUNIT_TEST(test_getDate);
121  CPPUNIT_TEST(test_strToLevel);
122  CPPUNIT_TEST(test_logfile_PARANOID);
123  CPPUNIT_TEST(test_logfile_VERBOSE);
124  CPPUNIT_TEST(test_logfile_TRACE);
125  CPPUNIT_TEST(test_logfile_DEBUG);
126  CPPUNIT_TEST(test_logfile_INFO);
127  CPPUNIT_TEST(test_logfile_WARNING);
128  CPPUNIT_TEST(test_logfile_ERROR);
129  CPPUNIT_TEST(test_logfile_FATAL);
130  CPPUNIT_TEST(test_logfile_SILENT);
131  CPPUNIT_TEST(test_constract_name);
132  CPPUNIT_TEST(test_deadlock);
133 
134  CPPUNIT_TEST_SUITE_END();
135 
136  private:
137 
138  protected:
139 
140  public:
145  {
146  }
147 
152  {
153  }
154 
158  virtual void setUp()
159  {
160  }
161 
162 
166  virtual void tearDown()
167  {
168  }
169 
175  void test_setLevel(void)
176  {
177 // std::cout << "test_setLevel() IN" << std::endl;
179  std::stringstream s0;
180 
181  logger.addStream(s0.rdbuf());
182  LoggerMock rtclog(&logger);
183 
184  // ログレベル設定で、引数に規定値・規定外を設定して正しく動作するか?
185  CPPUNIT_ASSERT(rtclog.setLevel("SILENT")); //規定値
186  CPPUNIT_ASSERT(rtclog.setLevel("FATAL"));
187  CPPUNIT_ASSERT(rtclog.setLevel("ERROR"));
188  CPPUNIT_ASSERT(rtclog.setLevel("WARN"));
189  CPPUNIT_ASSERT(rtclog.setLevel("INFO"));
190  CPPUNIT_ASSERT(rtclog.setLevel("DEBUG"));
191  CPPUNIT_ASSERT(rtclog.setLevel("TRACE"));
192  CPPUNIT_ASSERT(rtclog.setLevel("VERBOSE"));
193  CPPUNIT_ASSERT(rtclog.setLevel("PARANOID"));
194  CPPUNIT_ASSERT(rtclog.setLevel("other")); //規定外
195 // std::cout << "test_setLevel() OUT" << std::endl;
196  }
197 
204  {
205 // std::cout << "test_setDateFormat() IN" << std::endl;
207  std::stringstream s0;
208  std::string rstr;
209 
210  logger.addStream(s0.rdbuf());
211  LoggerMock rtclog(&logger);
212 
213  // ヘッダに付加する日時フォーマットを正しく指定できるか?
214  rtclog.setDateFormat("");
215  rstr = rtclog.getDate();
216  CPPUNIT_ASSERT(rstr.size() == 0);
217  CPPUNIT_ASSERT_EQUAL(std::string(""), rtclog.mock_m_dateFormat);
218 
219  rtclog.setDateFormat("%b %d %H:%M:%S");
220  rstr = rtclog.getDate();
221  CPPUNIT_ASSERT(rstr.size() > 0);
222  CPPUNIT_ASSERT_EQUAL(std::string("%b %d %H:%M:%S"), rtclog.mock_m_dateFormat);
223 // std::cout << "test_setDateFormat() OUT" << std::endl;
224  }
225 
231  void test_setName(void)
232  {
233 // std::cout << "test_setName() IN" << std::endl;
235  std::stringstream s0;
236 
237  logger.addStream(s0.rdbuf());
238  LoggerMock rtclog(&logger);
239  rtclog.setDateFormat("");
240  // ヘッダの日時の後に付加する文字列を正しく設定できるか?
241  rtclog.setName(""); // 付加文字列:なし
242  rtclog.header(rtclog.RTL_DEBUG);
243  CPPUNIT_ASSERT_EQUAL(std::string(""), rtclog.mock_m_name);
244  CPPUNIT_ASSERT_EQUAL(std::string(" DEBUG: : "), s0.str());
245 
246  s0.str("");
247  rtclog.setName("TestName"); // 付加文字列:あり rtclog.header(rtclog.RTL_DEBUG); CPPUNIT_ASSERT_EQUAL(std::string("TestName"), rtclog.mock_m_name); CPPUNIT_ASSERT_EQUAL(std::string(" DEBUG: TestName: "), s0.str()); // std::cout << "test_setName() OUT" << std::endl; } /*! * @brief header()メソッドのテスト * * - メッセージのプリフィックス追加を正しく設定できるか? */ void test_header(void) { // std::cout << "test_header() IN" << std::endl; coil::LogStreamBuffer logger; std::stringstream s0; logger.addStream(s0.rdbuf()); LoggerMock rtclog(&logger); // メッセージのプリフィックス追加を正しく設定できるか? rtclog.setDateFormat(""); rtclog.setName(""); rtclog.header(rtclog.RTL_SILENT); CPPUNIT_ASSERT_EQUAL(std::string(" SILENT: : "), s0.str()); s0.str(""); rtclog.header(rtclog.RTL_FATAL); CPPUNIT_ASSERT_EQUAL(std::string(" FATAL: : "), s0.str()); s0.str(""); rtclog.header(rtclog.RTL_ERROR); CPPUNIT_ASSERT_EQUAL(std::string(" ERROR: : "), s0.str()); s0.str(""); rtclog.header(rtclog.RTL_WARN); CPPUNIT_ASSERT_EQUAL(std::string(" WARNING: : "), s0.str()); s0.str(""); rtclog.header(rtclog.RTL_INFO); CPPUNIT_ASSERT_EQUAL(std::string(" INFO: : "), s0.str()); s0.str(""); rtclog.header(rtclog.RTL_DEBUG); CPPUNIT_ASSERT_EQUAL(std::string(" DEBUG: : "), s0.str()); s0.str(""); rtclog.header(rtclog.RTL_TRACE); CPPUNIT_ASSERT_EQUAL(std::string(" TRACE: : "), s0.str()); s0.str(""); rtclog.header(rtclog.RTL_VERBOSE); CPPUNIT_ASSERT_EQUAL(std::string(" VERBOSE: : "), s0.str()); s0.str(""); rtclog.header(rtclog.RTL_PARANOID); CPPUNIT_ASSERT_EQUAL(std::string(" PARANOID: : "), s0.str()); // std::cout << "test_header() OUT" << std::endl; } /*! * @brief getDate()メソッドのテスト * * - フォーマットされた現在日時文字列を正しく取得できるか? */ void test_getDate(void) { // std::cout << "test_getDate() IN" << std::endl; coil::LogStreamBuffer logger; std::stringstream s0; std::string rstr; logger.addStream(s0.rdbuf()); LoggerMock rtclog(&logger); // フォーマットされた現在日時文字列を正しく取得できるか? rtclog.setDateFormat(""); rstr = rtclog.getDate(); CPPUNIT_ASSERT(rstr.size() == 0); rtclog.setDateFormat("%b %d %H:%M:%S"); rstr = rtclog.getDate(); CPPUNIT_ASSERT(rstr.size() > 0); // std::cout << "test_getDate() OUT" << std::endl; } /*! * @brief strToLevel()メソッドのテスト * * - ログレベルを正しく設定できるか? */ void test_strToLevel(void) { // std::cout << "test_strToLevel() IN" << std::endl; coil::LogStreamBuffer logger; std::stringstream s0; logger.addStream(s0.rdbuf()); LoggerMock rtclog(&logger); // ログレベル設定で、引数に規定値・規定外を設定して正しく動作するか? CPPUNIT_ASSERT(rtclog.strToLevel("SILENT") == rtclog.RTL_SILENT); //規定値 CPPUNIT_ASSERT(rtclog.strToLevel("FATAL") == rtclog.RTL_FATAL); CPPUNIT_ASSERT(rtclog.strToLevel("ERROR") == rtclog.RTL_ERROR); CPPUNIT_ASSERT(rtclog.strToLevel("WARN") == rtclog.RTL_WARN); CPPUNIT_ASSERT(rtclog.strToLevel("INFO") == rtclog.RTL_INFO); CPPUNIT_ASSERT(rtclog.strToLevel("DEBUG") == rtclog.RTL_DEBUG); CPPUNIT_ASSERT(rtclog.strToLevel("TRACE") == rtclog.RTL_TRACE); CPPUNIT_ASSERT(rtclog.strToLevel("VERBOSE") == rtclog.RTL_VERBOSE); CPPUNIT_ASSERT(rtclog.strToLevel("PARANOID") == rtclog.RTL_PARANOID); CPPUNIT_ASSERT(rtclog.strToLevel("other") == rtclog.RTL_SILENT); //規定外 // std::cout << "test_strToLevel() OUT" << std::endl; } /*! * @brief logfile出力のテスト * * - ログレベルを PARANOID にした場合のファイル出力が正しく行われるか? */ void test_logfile_PARANOID(void) { // std::cout << "test_logfile_PARANOID() IN" << std::endl; coil::LogStreamBuffer logger; std::string logfile("rtcPARANOID.log"); std::filebuf of; of.open(logfile.c_str(), std::ios::out); if (!of.is_open()) { std::cerr << "Error: cannot open logfile: " << logfile << std::endl; } logger.addStream(&of, true); RTC::Logger rtclog(&logger); rtclog.setName("Test"); rtclog.setDateFormat("%b %d %H:%M:%S"); rtclog.setLevel("PARANOID"); // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか? RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str"); RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt")); RTC_PARANOID_STR("Macro RTL_PARANOID tests str"); RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str"); RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt")); RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str"); RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str"); RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt")); RTC_TRACE_STR("Macro RTL_TRACE tests str"); RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str"); RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt")); RTC_DEBUG_STR("Macro RTL_DEBUG tests str"); RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str"); RTC_INFO( ("Macro RTL_INFO tests %s","fmt")); RTC_INFO_STR("Macro RTL_INFO tests str"); RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str"); RTC_WARN( ("Macro RTL_WARN tests %s","fmt")); RTC_WARN_STR("Macro RTL_WARN tests str"); RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str"); RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt")); RTC_ERROR_STR("Macro RTL_ERROR tests str"); RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str"); RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt")); RTC_FATAL_STR("Macro RTL_FATAL tests str"); RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str"); of.close(); // ファイル出力があるか? std::string rstr; std::ifstream ifs(logfile.c_str()); ifs >> rstr; CPPUNIT_ASSERT(rstr.size() > 0); ifs >> rstr; ifs >> rstr; ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("PARANOID:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("RTL_PARANOID"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr); // std::cout << "test_logfile_PARANOID() OUT" << std::endl; } /*! * @brief logfile出力のテスト * * - ログレベルを VERBOSE にした場合のファイル出力が正しく行われるか? */ void test_logfile_VERBOSE(void) { // std::cout << "test_logfile_VERBOSE() IN" << std::endl; coil::LogStreamBuffer logger; std::string logfile("rtcVERBOSE.log"); std::filebuf of; of.open(logfile.c_str(), std::ios::out); if (!of.is_open()) { std::cerr << "Error: cannot open logfile: " << logfile << std::endl; } logger.addStream(&of, true); RTC::Logger rtclog(&logger); rtclog.setName("Test"); rtclog.setDateFormat("%b %d %H:%M:%S"); rtclog.setLevel("VERBOSE"); // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか? RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str"); RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt")); RTC_PARANOID_STR("Macro RTL_PARANOID tests str"); RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str"); RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt")); RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str"); RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str"); RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt")); RTC_TRACE_STR("Macro RTL_TRACE tests str"); RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str"); RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt")); RTC_DEBUG_STR("Macro RTL_DEBUG tests str"); RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str"); RTC_INFO( ("Macro RTL_INFO tests %s","fmt")); RTC_INFO_STR("Macro RTL_INFO tests str"); RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str"); RTC_WARN( ("Macro RTL_WARN tests %s","fmt")); RTC_WARN_STR("Macro RTL_WARN tests str"); RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str"); RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt")); RTC_ERROR_STR("Macro RTL_ERROR tests str"); RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str"); RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt")); RTC_FATAL_STR("Macro RTL_FATAL tests str"); RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str"); of.close(); // ファイル出力があるか? std::string rstr; std::ifstream ifs(logfile.c_str()); ifs >> rstr; CPPUNIT_ASSERT(rstr.size() > 0); ifs >> rstr; ifs >> rstr; ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("VERBOSE:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("RTL_VERBOSE"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr); // std::cout << "test_logfile_VERBOSE() OUT" << std::endl; } /*! * @brief logfile出力のテスト * * - ログレベルを TRACE にした場合のファイル出力が正しく行われるか? */ void test_logfile_TRACE(void) { // std::cout << "test_logfile_TRACE() IN" << std::endl; coil::LogStreamBuffer logger; std::string logfile("rtcTRACE.log"); std::filebuf of; of.open(logfile.c_str(), std::ios::out); if (!of.is_open()) { std::cerr << "Error: cannot open logfile: " << logfile << std::endl; } logger.addStream(&of, true); RTC::Logger rtclog(&logger); rtclog.setName("Test"); rtclog.setDateFormat("%b %d %H:%M:%S"); rtclog.setLevel("TRACE"); // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか? RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str"); RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt")); RTC_PARANOID_STR("Macro RTL_PARANOID tests str"); RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str"); RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt")); RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str"); RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str"); RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt")); RTC_TRACE_STR("Macro RTL_TRACE tests str"); RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str"); RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt")); RTC_DEBUG_STR("Macro RTL_DEBUG tests str"); RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str"); RTC_INFO( ("Macro RTL_INFO tests %s","fmt")); RTC_INFO_STR("Macro RTL_INFO tests str"); RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str"); RTC_WARN( ("Macro RTL_WARN tests %s","fmt")); RTC_WARN_STR("Macro RTL_WARN tests str"); RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str"); RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt")); RTC_ERROR_STR("Macro RTL_ERROR tests str"); RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str"); RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt")); RTC_FATAL_STR("Macro RTL_FATAL tests str"); RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str"); of.close(); // ファイル出力があるか? std::string rstr; std::ifstream ifs(logfile.c_str()); ifs >> rstr; CPPUNIT_ASSERT(rstr.size() > 0); ifs >> rstr; ifs >> rstr; ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("TRACE:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("RTL_TRACE"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr); // std::cout << "test_logfile_TRACE() OUT" << std::endl; } /*! * @brief logfile出力のテスト * * - ログレベルを DEBUG にした場合のファイル出力が正しく行われるか? */ void test_logfile_DEBUG(void) { // std::cout << "test_logfile_DEBUG() IN" << std::endl; coil::LogStreamBuffer logger; std::string logfile("rtcDEBUG.log"); std::filebuf of; of.open(logfile.c_str(), std::ios::out); if (!of.is_open()) { std::cerr << "Error: cannot open logfile: " << logfile << std::endl; } logger.addStream(&of, true); RTC::Logger rtclog(&logger); rtclog.setName("Test"); rtclog.setDateFormat("%b %d %H:%M:%S"); rtclog.setLevel("DEBUG"); // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか? RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str"); RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt")); RTC_PARANOID_STR("Macro RTL_PARANOID tests str"); RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str"); RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt")); RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str"); RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str"); RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt")); RTC_TRACE_STR("Macro RTL_TRACE tests str"); RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str"); RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt")); RTC_DEBUG_STR("Macro RTL_DEBUG tests str"); RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str"); RTC_INFO( ("Macro RTL_INFO tests %s","fmt")); RTC_INFO_STR("Macro RTL_INFO tests str"); RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str"); RTC_WARN( ("Macro RTL_WARN tests %s","fmt")); RTC_WARN_STR("Macro RTL_WARN tests str"); RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str"); RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt")); RTC_ERROR_STR("Macro RTL_ERROR tests str"); RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str"); RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt")); RTC_FATAL_STR("Macro RTL_FATAL tests str"); RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str"); of.close(); // ファイル出力があるか? std::string rstr; std::ifstream ifs(logfile.c_str()); ifs >> rstr; CPPUNIT_ASSERT(rstr.size() > 0); ifs >> rstr; ifs >> rstr; ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("DEBUG:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("RTL_DEBUG"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr); // std::cout << "test_logfile_DEBUG() OUT" << std::endl; } /*! * @brief logfile出力のテスト * * - ログレベルを INFO にした場合のファイル出力が正しく行われるか? */ void test_logfile_INFO(void) { // std::cout << "test_logfile_INFO() IN" << std::endl; coil::LogStreamBuffer logger; std::string logfile("rtcINFO.log"); std::filebuf of; of.open(logfile.c_str(), std::ios::out); if (!of.is_open()) { std::cerr << "Error: cannot open logfile: " << logfile << std::endl; } logger.addStream(&of, true); RTC::Logger rtclog(&logger); rtclog.setName("Test"); rtclog.setDateFormat("%b %d %H:%M:%S"); rtclog.setLevel("INFO"); // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか? RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str"); RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt")); RTC_PARANOID_STR("Macro RTL_PARANOID tests str"); RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str"); RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt")); RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str"); RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str"); RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt")); RTC_TRACE_STR("Macro RTL_TRACE tests str"); RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str"); RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt")); RTC_DEBUG_STR("Macro RTL_DEBUG tests str"); RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str"); RTC_INFO( ("Macro RTL_INFO tests %s","fmt")); RTC_INFO_STR("Macro RTL_INFO tests str"); RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str"); RTC_WARN( ("Macro RTL_WARN tests %s","fmt")); RTC_WARN_STR("Macro RTL_WARN tests str"); RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str"); RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt")); RTC_ERROR_STR("Macro RTL_ERROR tests str"); RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str"); RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt")); RTC_FATAL_STR("Macro RTL_FATAL tests str"); RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str"); of.close(); // ファイル出力があるか? std::string rstr; std::ifstream ifs(logfile.c_str()); ifs >> rstr; CPPUNIT_ASSERT(rstr.size() > 0); ifs >> rstr; ifs >> rstr; ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("INFO:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("RTL_INFO"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr); // std::cout << "test_logfile_INFO() OUT" << std::endl; } /*! * @brief logfile出力のテスト * * - ログレベルを WARNING にした場合のファイル出力が正しく行われるか? */ void test_logfile_WARNING(void) { // std::cout << "test_logfile_WARNING() IN" << std::endl; coil::LogStreamBuffer logger; std::string logfile("rtcWARNING.log"); std::filebuf of; of.open(logfile.c_str(), std::ios::out); if (!of.is_open()) { std::cerr << "Error: cannot open logfile: " << logfile << std::endl; } logger.addStream(&of, true); RTC::Logger rtclog(&logger); rtclog.setName("Test"); rtclog.setDateFormat("%b %d %H:%M:%S"); rtclog.setLevel("WARN"); // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか? RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str"); RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt")); RTC_PARANOID_STR("Macro RTL_PARANOID tests str"); RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str"); RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt")); RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str"); RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str"); RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt")); RTC_TRACE_STR("Macro RTL_TRACE tests str"); RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str"); RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt")); RTC_DEBUG_STR("Macro RTL_DEBUG tests str"); RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str"); RTC_INFO( ("Macro RTL_INFO tests %s","fmt")); RTC_INFO_STR("Macro RTL_INFO tests str"); RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str"); RTC_WARN( ("Macro RTL_WARN tests %s","fmt")); RTC_WARN_STR("Macro RTL_WARN tests str"); RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str"); RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt")); RTC_ERROR_STR("Macro RTL_ERROR tests str"); RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str"); RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt")); RTC_FATAL_STR("Macro RTL_FATAL tests str"); RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str"); of.close(); // ファイル出力があるか? std::string rstr; std::ifstream ifs(logfile.c_str()); ifs >> rstr; CPPUNIT_ASSERT(rstr.size() > 0); ifs >> rstr; ifs >> rstr; ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("WARNING:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("RTL_WARN"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr); // std::cout << "test_logfile_WARNING() OUT" << std::endl; } /*! * @brief logfile出力のテスト * * - ログレベルを ERROR にした場合のファイル出力が正しく行われるか? */ void test_logfile_ERROR(void) { // std::cout << "test_logfile_ERROR() IN" << std::endl; coil::LogStreamBuffer logger; std::string logfile("rtcERROR.log"); std::filebuf of; of.open(logfile.c_str(), std::ios::out); if (!of.is_open()) { std::cerr << "Error: cannot open logfile: " << logfile << std::endl; } logger.addStream(&of, true); RTC::Logger rtclog(&logger); rtclog.setName("Test"); rtclog.setDateFormat("%b %d %H:%M:%S"); rtclog.setLevel("ERROR"); // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか? RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str"); RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt")); RTC_PARANOID_STR("Macro RTL_PARANOID tests str"); RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str"); RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt")); RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str"); RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str"); RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt")); RTC_TRACE_STR("Macro RTL_TRACE tests str"); RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str"); RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt")); RTC_DEBUG_STR("Macro RTL_DEBUG tests str"); RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str"); RTC_INFO( ("Macro RTL_INFO tests %s","fmt")); RTC_INFO_STR("Macro RTL_INFO tests str"); RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str"); RTC_WARN( ("Macro RTL_WARN tests %s","fmt")); RTC_WARN_STR("Macro RTL_WARN tests str"); RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str"); RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt")); RTC_ERROR_STR("Macro RTL_ERROR tests str"); RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str"); RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt")); RTC_FATAL_STR("Macro RTL_FATAL tests str"); RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str"); of.close(); // ファイル出力があるか? std::string rstr; std::ifstream ifs(logfile.c_str()); ifs >> rstr; CPPUNIT_ASSERT(rstr.size() > 0); ifs >> rstr; ifs >> rstr; ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("ERROR:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("RTL_ERROR"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr); // std::cout << "test_logfile_ERROR() OUT" << std::endl; } /*! * @brief logfile出力のテスト * * - ログレベルを FATAL にした場合のファイル出力が正しく行われるか? */ void test_logfile_FATAL(void) { // std::cout << "test_logfile_FATAL() IN" << std::endl; coil::LogStreamBuffer logger; std::string logfile("rtcFATAL.log"); std::filebuf of; of.open(logfile.c_str(), std::ios::out); if (!of.is_open()) { std::cerr << "Error: cannot open logfile: " << logfile << std::endl; } logger.addStream(&of, true); RTC::Logger rtclog(&logger); rtclog.setName("Test"); rtclog.setDateFormat("%b %d %H:%M:%S"); rtclog.setLevel("FATAL"); // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか? RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str"); RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt")); RTC_PARANOID_STR("Macro RTL_PARANOID tests str"); RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str"); RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt")); RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str"); RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str"); RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt")); RTC_TRACE_STR("Macro RTL_TRACE tests str"); RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str"); RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt")); RTC_DEBUG_STR("Macro RTL_DEBUG tests str"); RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str"); RTC_INFO( ("Macro RTL_INFO tests %s","fmt")); RTC_INFO_STR("Macro RTL_INFO tests str"); RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str"); RTC_WARN( ("Macro RTL_WARN tests %s","fmt")); RTC_WARN_STR("Macro RTL_WARN tests str"); RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str"); RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt")); RTC_ERROR_STR("Macro RTL_ERROR tests str"); RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str"); RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt")); RTC_FATAL_STR("Macro RTL_FATAL tests str"); RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str"); of.close(); // ファイル出力があるか? std::string rstr; std::ifstream ifs(logfile.c_str()); ifs >> rstr; CPPUNIT_ASSERT(rstr.size() > 0); ifs >> rstr; ifs >> rstr; ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("FATAL:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("RTL_FATAL"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr); // std::cout << "test_logfile_FATAL() OUT" << std::endl; } /*! * @brief logfile出力のテスト * * - ログレベルを SILENT にした場合のファイル出力が正しく行われるか? */ void test_logfile_SILENT(void) { // std::cout << "test_logfile_SILENT() IN" << std::endl; coil::LogStreamBuffer logger; std::string logfile("rtcSILENT.log"); std::filebuf of; of.open(logfile.c_str(), std::ios::out); if (!of.is_open()) { std::cerr << "Error: cannot open logfile: " << logfile << std::endl; } logger.addStream(&of, true); RTC::Logger rtclog(&logger); rtclog.setName("Test"); rtclog.setDateFormat("%b %d %H:%M:%S"); rtclog.setLevel("SILENT"); // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか? RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str"); RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt")); RTC_PARANOID_STR("Macro RTL_PARANOID tests str"); RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str"); RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt")); RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str"); RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str"); RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt")); RTC_TRACE_STR("Macro RTL_TRACE tests str"); RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str"); RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt")); RTC_DEBUG_STR("Macro RTL_DEBUG tests str"); RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str"); RTC_INFO( ("Macro RTL_INFO tests %s","fmt")); RTC_INFO_STR("Macro RTL_INFO tests str"); RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str"); RTC_WARN( ("Macro RTL_WARN tests %s","fmt")); RTC_WARN_STR("Macro RTL_WARN tests str"); RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str"); RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt")); RTC_ERROR_STR("Macro RTL_ERROR tests str"); RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str"); RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt")); RTC_FATAL_STR("Macro RTL_FATAL tests str"); RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str"); of.close(); // ファイル出力があるか? std::string rstr; std::ifstream ifs(logfile.c_str()); ifs >> rstr; CPPUNIT_ASSERT(rstr.size() > 0); ifs >> rstr; ifs >> rstr; ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("SILENT:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("RTL_SILENT"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr); // std::cout << "test_logfile_SILENT() OUT" << std::endl; } /*! * @brief コンストラクタログレベルのテスト * * - コンストラクタ(name)の場合、Managerの設定ログレベル(INFO)で動作するか? */ void test_constract_name(void) { // std::cout << "test_constract_name() IN" << std::endl; RTC::Manager* m_mgr; m_mgr = RTC::Manager::init(0, NULL); CPPUNIT_ASSERT(m_mgr != NULL); RTC::Logger rtclog("TestName"); std::string log_level = m_mgr->getLogLevel(); CPPUNIT_ASSERT_EQUAL(std::string("INFO"), log_level); coil::Properties m_config = m_mgr->getConfig(); std::vector<std::string> logouts = coil::split(m_config["logger.file_name"], ","); // 汎用ログ出力マクロ、各種ログ出力マクロでファイル出力 RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str"); RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt")); RTC_PARANOID_STR("Macro RTL_PARANOID tests str"); RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str"); RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt")); RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str"); RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str"); RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt")); RTC_TRACE_STR("Macro RTL_TRACE tests str"); RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str"); RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt")); RTC_DEBUG_STR("Macro RTL_DEBUG tests str"); RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str"); RTC_INFO( ("Macro RTL_INFO tests %s","fmt")); RTC_INFO_STR("Macro RTL_INFO tests str"); RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str"); RTC_WARN( ("Macro RTL_WARN tests %s","fmt")); RTC_WARN_STR("Macro RTL_WARN tests str"); RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str"); RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt")); RTC_ERROR_STR("Macro RTL_ERROR tests str"); RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str"); RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt")); RTC_FATAL_STR("Macro RTL_FATAL tests str"); RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str"); m_mgr->terminate(); // rtc*.log ファイルが作成され、4列目のログレベルが INFO以下か? // INFO WARNING ERROR FATAL SILENT だけが記録されているか? // Aug 03 14:03:09 INFO: manager: OpenRTM-aist-1.0.0 // [0] 1 2 3 4 5 std::string rstr; std::vector<std::string> vstr; bool bret; std::ifstream ifs(logouts[0].c_str()); while(getline(ifs, rstr)) { if(rstr.size() == 0) break; vstr = coil::split(rstr, " "); // ログレベル判定 bret = false; if( (vstr[3] == "INFO:") || (vstr[3] == "WARNING:") || (vstr[3] == "ERROR:") || (vstr[3] == "FATAL:") || (vstr[3] == "SILENT:") ) bret = true; CPPUNIT_ASSERT(bret); // name判定 bret = false; if( (vstr[4] == "manager:") || (vstr[4] == "TestName:") || (vstr[4] == "NamingOnCorba:") || (vstr[4] == "NamingManager:") || (vstr[4] == "ManagerServant:") ) bret = true; CPPUNIT_ASSERT(bret); } // std::cout << "test_constract_name() OUT" << std::endl; } /*! * @brief ログ出力のデッドロックテスト * * - RTC_LOG出力時、引数の関数内でログ出力がある場合にデッドロックしないか? */ void test_deadlock(void) { // std::cout << "test_deadlock() IN" << std::endl; coil::LogStreamBuffer logger; std::stringstream s0; logger.addStream(s0.rdbuf()); LoggerMock rtclog(&logger); rtclog.setName("Test"); rtclog.setDateFormat(""); rtclog.setLevel("TRACE"); s0.str(""); // ロックモード設定 rtclog.enableLock(); RTC_TRACE(("RTC_TRACE1 %s", rtclog.test_string().c_str())); std::string rstr; getline(s0, rstr); CPPUNIT_ASSERT_EQUAL(std::string(" TRACE: Test: RTC_TRACE2 test_string()"), rstr); getline(s0, rstr); CPPUNIT_ASSERT_EQUAL(std::string(" TRACE: Test: RTC_TRACE1 TestString"), rstr); // ロックモード解除 rtclog.disableLock(); // std::cout << "test_deadlock() OUT" << std::endl; } }; }; // namespace Tests /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(Tests::SystemLoggerTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // SystemLoggerTests_cpp
248  rtclog.header(rtclog.RTL_DEBUG);
249  CPPUNIT_ASSERT_EQUAL(std::string("TestName"), rtclog.mock_m_name);
250  CPPUNIT_ASSERT_EQUAL(std::string(" DEBUG: TestName: "), s0.str());
251 // std::cout << "test_setName() OUT" << std::endl;
252  }
253 
259  void test_header(void)
260  {
261 // std::cout << "test_header() IN" << std::endl;
263  std::stringstream s0;
264 
265  logger.addStream(s0.rdbuf());
266  LoggerMock rtclog(&logger);
267 
268  // メッセージのプリフィックス追加を正しく設定できるか?
269  rtclog.setDateFormat("");
270  rtclog.setName("");
271  rtclog.header(rtclog.RTL_SILENT);
272  CPPUNIT_ASSERT_EQUAL(std::string(" SILENT: : "), s0.str());
273  s0.str("");
274  rtclog.header(rtclog.RTL_FATAL);
275  CPPUNIT_ASSERT_EQUAL(std::string(" FATAL: : "), s0.str());
276  s0.str("");
277  rtclog.header(rtclog.RTL_ERROR);
278  CPPUNIT_ASSERT_EQUAL(std::string(" ERROR: : "), s0.str());
279  s0.str("");
280  rtclog.header(rtclog.RTL_WARN);
281  CPPUNIT_ASSERT_EQUAL(std::string(" WARNING: : "), s0.str());
282  s0.str("");
283  rtclog.header(rtclog.RTL_INFO);
284  CPPUNIT_ASSERT_EQUAL(std::string(" INFO: : "), s0.str());
285  s0.str("");
286  rtclog.header(rtclog.RTL_DEBUG);
287  CPPUNIT_ASSERT_EQUAL(std::string(" DEBUG: : "), s0.str());
288  s0.str("");
289  rtclog.header(rtclog.RTL_TRACE);
290  CPPUNIT_ASSERT_EQUAL(std::string(" TRACE: : "), s0.str());
291  s0.str("");
292  rtclog.header(rtclog.RTL_VERBOSE);
293  CPPUNIT_ASSERT_EQUAL(std::string(" VERBOSE: : "), s0.str());
294  s0.str("");
295  rtclog.header(rtclog.RTL_PARANOID);
296  CPPUNIT_ASSERT_EQUAL(std::string(" PARANOID: : "), s0.str());
297 // std::cout << "test_header() OUT" << std::endl;
298  }
299 
305  void test_getDate(void)
306  {
307 // std::cout << "test_getDate() IN" << std::endl;
309  std::stringstream s0;
310  std::string rstr;
311 
312  logger.addStream(s0.rdbuf());
313  LoggerMock rtclog(&logger);
314 
315  // フォーマットされた現在日時文字列を正しく取得できるか?
316  rtclog.setDateFormat("");
317  rstr = rtclog.getDate();
318  CPPUNIT_ASSERT(rstr.size() == 0);
319 
320  rtclog.setDateFormat("%b %d %H:%M:%S");
321  rstr = rtclog.getDate();
322  CPPUNIT_ASSERT(rstr.size() > 0);
323 // std::cout << "test_getDate() OUT" << std::endl;
324  }
325 
331  void test_strToLevel(void)
332  {
333 // std::cout << "test_strToLevel() IN" << std::endl;
335  std::stringstream s0;
336 
337  logger.addStream(s0.rdbuf());
338  LoggerMock rtclog(&logger);
339 
340  // ログレベル設定で、引数に規定値・規定外を設定して正しく動作するか?
341  CPPUNIT_ASSERT(rtclog.strToLevel("SILENT") == rtclog.RTL_SILENT); //規定値
342  CPPUNIT_ASSERT(rtclog.strToLevel("FATAL") == rtclog.RTL_FATAL);
343  CPPUNIT_ASSERT(rtclog.strToLevel("ERROR") == rtclog.RTL_ERROR);
344  CPPUNIT_ASSERT(rtclog.strToLevel("WARN") == rtclog.RTL_WARN);
345  CPPUNIT_ASSERT(rtclog.strToLevel("INFO") == rtclog.RTL_INFO);
346  CPPUNIT_ASSERT(rtclog.strToLevel("DEBUG") == rtclog.RTL_DEBUG);
347  CPPUNIT_ASSERT(rtclog.strToLevel("TRACE") == rtclog.RTL_TRACE);
348  CPPUNIT_ASSERT(rtclog.strToLevel("VERBOSE") == rtclog.RTL_VERBOSE);
349  CPPUNIT_ASSERT(rtclog.strToLevel("PARANOID") == rtclog.RTL_PARANOID);
350  CPPUNIT_ASSERT(rtclog.strToLevel("other") == rtclog.RTL_SILENT); //規定外
351 // std::cout << "test_strToLevel() OUT" << std::endl;
352  }
353 
360  {
361 // std::cout << "test_logfile_PARANOID() IN" << std::endl;
363  std::string logfile("rtcPARANOID.log");
364 
365  std::filebuf of;
366  of.open(logfile.c_str(), std::ios::out);
367  if (!of.is_open())
368  {
369  std::cerr << "Error: cannot open logfile: "
370  << logfile << std::endl;
371  }
372  logger.addStream(&of, true);
373 
374  RTC::Logger rtclog(&logger);
375  rtclog.setName("Test");
376  rtclog.setDateFormat("%b %d %H:%M:%S");
377  rtclog.setLevel("PARANOID");
378 
379  // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか?
380  RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt"));
381  RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str");
382  RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt"));
383  RTC_PARANOID_STR("Macro RTL_PARANOID tests str");
384 
385  RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt"));
386  RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str");
387  RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt"));
388  RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str");
389 
390  RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt"));
391  RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str");
392  RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt"));
393  RTC_TRACE_STR("Macro RTL_TRACE tests str");
394 
395  RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt"));
396  RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str");
397  RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt"));
398  RTC_DEBUG_STR("Macro RTL_DEBUG tests str");
399 
400  RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt"));
401  RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str");
402  RTC_INFO( ("Macro RTL_INFO tests %s","fmt"));
403  RTC_INFO_STR("Macro RTL_INFO tests str");
404 
405  RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt"));
406  RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str");
407  RTC_WARN( ("Macro RTL_WARN tests %s","fmt"));
408  RTC_WARN_STR("Macro RTL_WARN tests str");
409 
410  RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt"));
411  RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str");
412  RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt"));
413  RTC_ERROR_STR("Macro RTL_ERROR tests str");
414 
415  RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt"));
416  RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str");
417  RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt"));
418  RTC_FATAL_STR("Macro RTL_FATAL tests str");
419 
420  RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt"));
421  RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str");
422 
423  of.close();
424 
425  // ファイル出力があるか?
426  std::string rstr;
427  std::ifstream ifs(logfile.c_str());
428  ifs >> rstr;
429  CPPUNIT_ASSERT(rstr.size() > 0);
430  ifs >> rstr;
431  ifs >> rstr;
432  ifs >> rstr;
433  CPPUNIT_ASSERT_EQUAL(std::string("PARANOID:"), rstr);
434  ifs >> rstr;
435  CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr);
436  ifs >> rstr;
437  CPPUNIT_ASSERT_EQUAL(std::string("RTL_PARANOID"), rstr);
438  ifs >> rstr;
439  CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr);
440  ifs >> rstr;
441  CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr);
442 
443 // std::cout << "test_logfile_PARANOID() OUT" << std::endl;
444  }
445 
452  {
453 // std::cout << "test_logfile_VERBOSE() IN" << std::endl;
455  std::string logfile("rtcVERBOSE.log");
456 
457  std::filebuf of;
458  of.open(logfile.c_str(), std::ios::out);
459  if (!of.is_open())
460  {
461  std::cerr << "Error: cannot open logfile: "
462  << logfile << std::endl;
463  }
464  logger.addStream(&of, true);
465 
466  RTC::Logger rtclog(&logger);
467  rtclog.setName("Test");
468  rtclog.setDateFormat("%b %d %H:%M:%S");
469  rtclog.setLevel("VERBOSE");
470 
471  // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか?
472  RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt"));
473  RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str");
474  RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt"));
475  RTC_PARANOID_STR("Macro RTL_PARANOID tests str");
476 
477  RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt"));
478  RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str");
479  RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt"));
480  RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str");
481 
482  RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt"));
483  RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str");
484  RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt"));
485  RTC_TRACE_STR("Macro RTL_TRACE tests str");
486 
487  RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt"));
488  RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str");
489  RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt"));
490  RTC_DEBUG_STR("Macro RTL_DEBUG tests str");
491 
492  RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt"));
493  RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str");
494  RTC_INFO( ("Macro RTL_INFO tests %s","fmt"));
495  RTC_INFO_STR("Macro RTL_INFO tests str");
496 
497  RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt"));
498  RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str");
499  RTC_WARN( ("Macro RTL_WARN tests %s","fmt"));
500  RTC_WARN_STR("Macro RTL_WARN tests str");
501 
502  RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt"));
503  RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str");
504  RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt"));
505  RTC_ERROR_STR("Macro RTL_ERROR tests str");
506 
507  RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt"));
508  RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str");
509  RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt"));
510  RTC_FATAL_STR("Macro RTL_FATAL tests str");
511 
512  RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt"));
513  RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str");
514 
515  of.close();
516 
517  // ファイル出力があるか?
518  std::string rstr;
519  std::ifstream ifs(logfile.c_str());
520  ifs >> rstr;
521  CPPUNIT_ASSERT(rstr.size() > 0);
522  ifs >> rstr;
523  ifs >> rstr;
524  ifs >> rstr;
525  CPPUNIT_ASSERT_EQUAL(std::string("VERBOSE:"), rstr);
526  ifs >> rstr;
527  CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr);
528  ifs >> rstr;
529  CPPUNIT_ASSERT_EQUAL(std::string("RTL_VERBOSE"), rstr);
530  ifs >> rstr;
531  CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr);
532  ifs >> rstr;
533  CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr);
534 
535 // std::cout << "test_logfile_VERBOSE() OUT" << std::endl;
536  }
537 
544  {
545 // std::cout << "test_logfile_TRACE() IN" << std::endl;
547  std::string logfile("rtcTRACE.log");
548 
549  std::filebuf of;
550  of.open(logfile.c_str(), std::ios::out);
551  if (!of.is_open())
552  {
553  std::cerr << "Error: cannot open logfile: "
554  << logfile << std::endl;
555  }
556  logger.addStream(&of, true);
557 
558  RTC::Logger rtclog(&logger);
559  rtclog.setName("Test");
560  rtclog.setDateFormat("%b %d %H:%M:%S");
561  rtclog.setLevel("TRACE");
562 
563  // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか?
564  RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt"));
565  RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str");
566  RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt"));
567  RTC_PARANOID_STR("Macro RTL_PARANOID tests str");
568 
569  RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt"));
570  RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str");
571  RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt"));
572  RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str");
573 
574  RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt"));
575  RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str");
576  RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt"));
577  RTC_TRACE_STR("Macro RTL_TRACE tests str");
578 
579  RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt"));
580  RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str");
581  RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt"));
582  RTC_DEBUG_STR("Macro RTL_DEBUG tests str");
583 
584  RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt"));
585  RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str");
586  RTC_INFO( ("Macro RTL_INFO tests %s","fmt"));
587  RTC_INFO_STR("Macro RTL_INFO tests str");
588 
589  RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt"));
590  RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str");
591  RTC_WARN( ("Macro RTL_WARN tests %s","fmt"));
592  RTC_WARN_STR("Macro RTL_WARN tests str");
593 
594  RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt"));
595  RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str");
596  RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt"));
597  RTC_ERROR_STR("Macro RTL_ERROR tests str");
598 
599  RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt"));
600  RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str");
601  RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt"));
602  RTC_FATAL_STR("Macro RTL_FATAL tests str");
603 
604  RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt"));
605  RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str");
606 
607  of.close();
608 
609  // ファイル出力があるか?
610  std::string rstr;
611  std::ifstream ifs(logfile.c_str());
612  ifs >> rstr;
613  CPPUNIT_ASSERT(rstr.size() > 0);
614  ifs >> rstr;
615  ifs >> rstr;
616  ifs >> rstr;
617  CPPUNIT_ASSERT_EQUAL(std::string("TRACE:"), rstr);
618  ifs >> rstr;
619  CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr);
620  ifs >> rstr;
621  CPPUNIT_ASSERT_EQUAL(std::string("RTL_TRACE"), rstr);
622  ifs >> rstr;
623  CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr);
624  ifs >> rstr;
625  CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr);
626 
627 // std::cout << "test_logfile_TRACE() OUT" << std::endl;
628  }
629 
636  {
637 // std::cout << "test_logfile_DEBUG() IN" << std::endl;
639  std::string logfile("rtcDEBUG.log");
640 
641  std::filebuf of;
642  of.open(logfile.c_str(), std::ios::out);
643  if (!of.is_open())
644  {
645  std::cerr << "Error: cannot open logfile: "
646  << logfile << std::endl;
647  }
648  logger.addStream(&of, true);
649 
650  RTC::Logger rtclog(&logger);
651  rtclog.setName("Test");
652  rtclog.setDateFormat("%b %d %H:%M:%S");
653  rtclog.setLevel("DEBUG");
654 
655  // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか?
656  RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt"));
657  RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str");
658  RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt"));
659  RTC_PARANOID_STR("Macro RTL_PARANOID tests str");
660 
661  RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt"));
662  RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str");
663  RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt"));
664  RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str");
665 
666  RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt"));
667  RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str");
668  RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt"));
669  RTC_TRACE_STR("Macro RTL_TRACE tests str");
670 
671  RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt"));
672  RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str");
673  RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt"));
674  RTC_DEBUG_STR("Macro RTL_DEBUG tests str");
675 
676  RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt"));
677  RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str");
678  RTC_INFO( ("Macro RTL_INFO tests %s","fmt"));
679  RTC_INFO_STR("Macro RTL_INFO tests str");
680 
681  RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt"));
682  RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str");
683  RTC_WARN( ("Macro RTL_WARN tests %s","fmt"));
684  RTC_WARN_STR("Macro RTL_WARN tests str");
685 
686  RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt"));
687  RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str");
688  RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt"));
689  RTC_ERROR_STR("Macro RTL_ERROR tests str");
690 
691  RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt"));
692  RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str");
693  RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt"));
694  RTC_FATAL_STR("Macro RTL_FATAL tests str");
695 
696  RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt"));
697  RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str");
698 
699  of.close();
700 
701  // ファイル出力があるか?
702  std::string rstr;
703  std::ifstream ifs(logfile.c_str());
704  ifs >> rstr;
705  CPPUNIT_ASSERT(rstr.size() > 0);
706  ifs >> rstr;
707  ifs >> rstr;
708  ifs >> rstr;
709  CPPUNIT_ASSERT_EQUAL(std::string("DEBUG:"), rstr);
710  ifs >> rstr;
711  CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr);
712  ifs >> rstr;
713  CPPUNIT_ASSERT_EQUAL(std::string("RTL_DEBUG"), rstr);
714  ifs >> rstr;
715  CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr);
716  ifs >> rstr;
717  CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr);
718 
719 // std::cout << "test_logfile_DEBUG() OUT" << std::endl;
720  }
721 
727  void test_logfile_INFO(void)
728  {
729 // std::cout << "test_logfile_INFO() IN" << std::endl;
731  std::string logfile("rtcINFO.log");
732 
733  std::filebuf of;
734  of.open(logfile.c_str(), std::ios::out);
735  if (!of.is_open())
736  {
737  std::cerr << "Error: cannot open logfile: "
738  << logfile << std::endl;
739  }
740  logger.addStream(&of, true);
741 
742  RTC::Logger rtclog(&logger);
743  rtclog.setName("Test");
744  rtclog.setDateFormat("%b %d %H:%M:%S");
745  rtclog.setLevel("INFO");
746 
747  // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか?
748  RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt"));
749  RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str");
750  RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt"));
751  RTC_PARANOID_STR("Macro RTL_PARANOID tests str");
752 
753  RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt"));
754  RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str");
755  RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt"));
756  RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str");
757 
758  RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt"));
759  RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str");
760  RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt"));
761  RTC_TRACE_STR("Macro RTL_TRACE tests str");
762 
763  RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt"));
764  RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str");
765  RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt"));
766  RTC_DEBUG_STR("Macro RTL_DEBUG tests str");
767 
768  RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt"));
769  RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str");
770  RTC_INFO( ("Macro RTL_INFO tests %s","fmt"));
771  RTC_INFO_STR("Macro RTL_INFO tests str");
772 
773  RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt"));
774  RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str");
775  RTC_WARN( ("Macro RTL_WARN tests %s","fmt"));
776  RTC_WARN_STR("Macro RTL_WARN tests str");
777 
778  RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt"));
779  RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str");
780  RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt"));
781  RTC_ERROR_STR("Macro RTL_ERROR tests str");
782 
783  RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt"));
784  RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str");
785  RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt"));
786  RTC_FATAL_STR("Macro RTL_FATAL tests str");
787 
788  RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt"));
789  RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str");
790 
791  of.close();
792 
793  // ファイル出力があるか?
794  std::string rstr;
795  std::ifstream ifs(logfile.c_str());
796  ifs >> rstr;
797  CPPUNIT_ASSERT(rstr.size() > 0);
798  ifs >> rstr;
799  ifs >> rstr;
800  ifs >> rstr;
801  CPPUNIT_ASSERT_EQUAL(std::string("INFO:"), rstr);
802  ifs >> rstr;
803  CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr);
804  ifs >> rstr;
805  CPPUNIT_ASSERT_EQUAL(std::string("RTL_INFO"), rstr);
806  ifs >> rstr;
807  CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr);
808  ifs >> rstr;
809  CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr);
810 
811 // std::cout << "test_logfile_INFO() OUT" << std::endl;
812  }
813 
820  {
821 // std::cout << "test_logfile_WARNING() IN" << std::endl;
823  std::string logfile("rtcWARNING.log");
824 
825  std::filebuf of;
826  of.open(logfile.c_str(), std::ios::out);
827  if (!of.is_open())
828  {
829  std::cerr << "Error: cannot open logfile: "
830  << logfile << std::endl;
831  }
832  logger.addStream(&of, true);
833 
834  RTC::Logger rtclog(&logger);
835  rtclog.setName("Test");
836  rtclog.setDateFormat("%b %d %H:%M:%S");
837  rtclog.setLevel("WARN");
838 
839  // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか?
840  RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt"));
841  RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str");
842  RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt"));
843  RTC_PARANOID_STR("Macro RTL_PARANOID tests str");
844 
845  RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt"));
846  RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str");
847  RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt"));
848  RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str");
849 
850  RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt"));
851  RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str");
852  RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt"));
853  RTC_TRACE_STR("Macro RTL_TRACE tests str");
854 
855  RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt"));
856  RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str");
857  RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt"));
858  RTC_DEBUG_STR("Macro RTL_DEBUG tests str");
859 
860  RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt"));
861  RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str");
862  RTC_INFO( ("Macro RTL_INFO tests %s","fmt"));
863  RTC_INFO_STR("Macro RTL_INFO tests str");
864 
865  RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt"));
866  RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str");
867  RTC_WARN( ("Macro RTL_WARN tests %s","fmt"));
868  RTC_WARN_STR("Macro RTL_WARN tests str");
869 
870  RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt"));
871  RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str");
872  RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt"));
873  RTC_ERROR_STR("Macro RTL_ERROR tests str");
874 
875  RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt"));
876  RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str");
877  RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt"));
878  RTC_FATAL_STR("Macro RTL_FATAL tests str");
879 
880  RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt"));
881  RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str");
882 
883  of.close();
884 
885  // ファイル出力があるか?
886  std::string rstr;
887  std::ifstream ifs(logfile.c_str());
888  ifs >> rstr;
889  CPPUNIT_ASSERT(rstr.size() > 0);
890  ifs >> rstr;
891  ifs >> rstr;
892  ifs >> rstr;
893  CPPUNIT_ASSERT_EQUAL(std::string("WARNING:"), rstr);
894  ifs >> rstr;
895  CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr);
896  ifs >> rstr;
897  CPPUNIT_ASSERT_EQUAL(std::string("RTL_WARN"), rstr);
898  ifs >> rstr;
899  CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr);
900  ifs >> rstr;
901  CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr);
902 
903 // std::cout << "test_logfile_WARNING() OUT" << std::endl;
904  }
905 
912  {
913 // std::cout << "test_logfile_ERROR() IN" << std::endl;
915  std::string logfile("rtcERROR.log");
916 
917  std::filebuf of;
918  of.open(logfile.c_str(), std::ios::out);
919  if (!of.is_open())
920  {
921  std::cerr << "Error: cannot open logfile: "
922  << logfile << std::endl;
923  }
924  logger.addStream(&of, true);
925 
926  RTC::Logger rtclog(&logger);
927  rtclog.setName("Test");
928  rtclog.setDateFormat("%b %d %H:%M:%S");
929  rtclog.setLevel("ERROR");
930 
931  // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか?
932  RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt"));
933  RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str");
934  RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt"));
935  RTC_PARANOID_STR("Macro RTL_PARANOID tests str");
936 
937  RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt"));
938  RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str");
939  RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt"));
940  RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str");
941 
942  RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt"));
943  RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str");
944  RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt"));
945  RTC_TRACE_STR("Macro RTL_TRACE tests str");
946 
947  RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt"));
948  RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str");
949  RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt"));
950  RTC_DEBUG_STR("Macro RTL_DEBUG tests str");
951 
952  RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt"));
953  RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str");
954  RTC_INFO( ("Macro RTL_INFO tests %s","fmt"));
955  RTC_INFO_STR("Macro RTL_INFO tests str");
956 
957  RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt"));
958  RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str");
959  RTC_WARN( ("Macro RTL_WARN tests %s","fmt"));
960  RTC_WARN_STR("Macro RTL_WARN tests str");
961 
962  RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt"));
963  RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str");
964  RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt"));
965  RTC_ERROR_STR("Macro RTL_ERROR tests str");
966 
967  RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt"));
968  RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str");
969  RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt"));
970  RTC_FATAL_STR("Macro RTL_FATAL tests str");
971 
972  RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt"));
973  RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str");
974 
975  of.close();
976 
977  // ファイル出力があるか?
978  std::string rstr;
979  std::ifstream ifs(logfile.c_str());
980  ifs >> rstr;
981  CPPUNIT_ASSERT(rstr.size() > 0);
982  ifs >> rstr;
983  ifs >> rstr;
984  ifs >> rstr;
985  CPPUNIT_ASSERT_EQUAL(std::string("ERROR:"), rstr);
986  ifs >> rstr;
987  CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr);
988  ifs >> rstr;
989  CPPUNIT_ASSERT_EQUAL(std::string("RTL_ERROR"), rstr);
990  ifs >> rstr;
991  CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr);
992  ifs >> rstr;
993  CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr);
994 
995 // std::cout << "test_logfile_ERROR() OUT" << std::endl;
996  }
997 
1004  {
1005 // std::cout << "test_logfile_FATAL() IN" << std::endl;
1007  std::string logfile("rtcFATAL.log");
1008 
1009  std::filebuf of;
1010  of.open(logfile.c_str(), std::ios::out);
1011  if (!of.is_open())
1012  {
1013  std::cerr << "Error: cannot open logfile: "
1014  << logfile << std::endl;
1015  }
1016  logger.addStream(&of, true);
1017 
1018  RTC::Logger rtclog(&logger);
1019  rtclog.setName("Test");
1020  rtclog.setDateFormat("%b %d %H:%M:%S");
1021  rtclog.setLevel("FATAL");
1022 
1023  // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか?
1024  RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt"));
1025  RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str");
1026  RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt"));
1027  RTC_PARANOID_STR("Macro RTL_PARANOID tests str");
1028 
1029  RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt"));
1030  RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str");
1031  RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt"));
1032  RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str");
1033 
1034  RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt"));
1035  RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str");
1036  RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt"));
1037  RTC_TRACE_STR("Macro RTL_TRACE tests str");
1038 
1039  RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt"));
1040  RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str");
1041  RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt"));
1042  RTC_DEBUG_STR("Macro RTL_DEBUG tests str");
1043 
1044  RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt"));
1045  RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str");
1046  RTC_INFO( ("Macro RTL_INFO tests %s","fmt"));
1047  RTC_INFO_STR("Macro RTL_INFO tests str");
1048 
1049  RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt"));
1050  RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str");
1051  RTC_WARN( ("Macro RTL_WARN tests %s","fmt"));
1052  RTC_WARN_STR("Macro RTL_WARN tests str");
1053 
1054  RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt"));
1055  RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str");
1056  RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt"));
1057  RTC_ERROR_STR("Macro RTL_ERROR tests str");
1058 
1059  RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt"));
1060  RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str");
1061  RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt"));
1062  RTC_FATAL_STR("Macro RTL_FATAL tests str");
1063 
1064  RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt"));
1065  RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str");
1066 
1067  of.close();
1068 
1069  // ファイル出力があるか?
1070  std::string rstr;
1071  std::ifstream ifs(logfile.c_str());
1072  ifs >> rstr;
1073  CPPUNIT_ASSERT(rstr.size() > 0);
1074  ifs >> rstr;
1075  ifs >> rstr;
1076  ifs >> rstr;
1077  CPPUNIT_ASSERT_EQUAL(std::string("FATAL:"), rstr);
1078  ifs >> rstr;
1079  CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr);
1080  ifs >> rstr;
1081  CPPUNIT_ASSERT_EQUAL(std::string("RTL_FATAL"), rstr);
1082  ifs >> rstr;
1083  CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr);
1084  ifs >> rstr;
1085  CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr);
1086 
1087 // std::cout << "test_logfile_FATAL() OUT" << std::endl;
1088  }
1089 
1096  {
1097 // std::cout << "test_logfile_SILENT() IN" << std::endl;
1099  std::string logfile("rtcSILENT.log");
1100 
1101  std::filebuf of;
1102  of.open(logfile.c_str(), std::ios::out);
1103  if (!of.is_open())
1104  {
1105  std::cerr << "Error: cannot open logfile: "
1106  << logfile << std::endl;
1107  }
1108  logger.addStream(&of, true);
1109 
1110  RTC::Logger rtclog(&logger);
1111  rtclog.setName("Test");
1112  rtclog.setDateFormat("%b %d %H:%M:%S");
1113  rtclog.setLevel("SILENT");
1114 
1115  // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか?
1116  RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt"));
1117  RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str");
1118  RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt"));
1119  RTC_PARANOID_STR("Macro RTL_PARANOID tests str");
1120 
1121  RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt"));
1122  RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str");
1123  RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt"));
1124  RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str");
1125 
1126  RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt"));
1127  RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str");
1128  RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt"));
1129  RTC_TRACE_STR("Macro RTL_TRACE tests str");
1130 
1131  RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt"));
1132  RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str");
1133  RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt"));
1134  RTC_DEBUG_STR("Macro RTL_DEBUG tests str");
1135 
1136  RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt"));
1137  RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str");
1138  RTC_INFO( ("Macro RTL_INFO tests %s","fmt"));
1139  RTC_INFO_STR("Macro RTL_INFO tests str");
1140 
1141  RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt"));
1142  RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str");
1143  RTC_WARN( ("Macro RTL_WARN tests %s","fmt"));
1144  RTC_WARN_STR("Macro RTL_WARN tests str");
1145 
1146  RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt"));
1147  RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str");
1148  RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt"));
1149  RTC_ERROR_STR("Macro RTL_ERROR tests str");
1150 
1151  RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt"));
1152  RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str");
1153  RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt"));
1154  RTC_FATAL_STR("Macro RTL_FATAL tests str");
1155 
1156  RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt"));
1157  RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str");
1158 
1159  of.close();
1160 
1161  // ファイル出力があるか?
1162  std::string rstr;
1163  std::ifstream ifs(logfile.c_str());
1164  ifs >> rstr;
1165  CPPUNIT_ASSERT(rstr.size() > 0);
1166  ifs >> rstr;
1167  ifs >> rstr;
1168  ifs >> rstr;
1169  CPPUNIT_ASSERT_EQUAL(std::string("SILENT:"), rstr);
1170  ifs >> rstr;
1171  CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr);
1172  ifs >> rstr;
1173  CPPUNIT_ASSERT_EQUAL(std::string("RTL_SILENT"), rstr);
1174  ifs >> rstr;
1175  CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr);
1176  ifs >> rstr;
1177  CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr);
1178 
1179 // std::cout << "test_logfile_SILENT() OUT" << std::endl;
1180  }
1181 
1188  {
1189 // std::cout << "test_constract_name() IN" << std::endl;
1190  RTC::Manager* m_mgr;
1191  m_mgr = RTC::Manager::init(0, NULL);
1192  CPPUNIT_ASSERT(m_mgr != NULL);
1193 
1194  RTC::Logger rtclog("TestName");
1195  std::string log_level = m_mgr->getLogLevel();
1196  CPPUNIT_ASSERT_EQUAL(std::string("INFO"), log_level);
1197 
1198  coil::Properties m_config = m_mgr->getConfig();
1199  std::vector<std::string> logouts = coil::split(m_config["logger.file_name"], ",");
1200 
1201  // 汎用ログ出力マクロ、各種ログ出力マクロでファイル出力 RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str"); RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt")); RTC_PARANOID_STR("Macro RTL_PARANOID tests str"); RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str"); RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt")); RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str"); RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str"); RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt")); RTC_TRACE_STR("Macro RTL_TRACE tests str"); RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str"); RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt")); RTC_DEBUG_STR("Macro RTL_DEBUG tests str"); RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str"); RTC_INFO( ("Macro RTL_INFO tests %s","fmt")); RTC_INFO_STR("Macro RTL_INFO tests str"); RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str"); RTC_WARN( ("Macro RTL_WARN tests %s","fmt")); RTC_WARN_STR("Macro RTL_WARN tests str"); RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str"); RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt")); RTC_ERROR_STR("Macro RTL_ERROR tests str"); RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str"); RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt")); RTC_FATAL_STR("Macro RTL_FATAL tests str"); RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str"); m_mgr->terminate(); // rtc*.log ファイルが作成され、4列目のログレベルが INFO以下か? // INFO WARNING ERROR FATAL SILENT だけが記録されているか? // Aug 03 14:03:09 INFO: manager: OpenRTM-aist-1.0.0 // [0] 1 2 3 4 5 std::string rstr; std::vector<std::string> vstr; bool bret; std::ifstream ifs(logouts[0].c_str()); while(getline(ifs, rstr)) { if(rstr.size() == 0) break; vstr = coil::split(rstr, " "); // ログレベル判定 bret = false; if( (vstr[3] == "INFO:") || (vstr[3] == "WARNING:") || (vstr[3] == "ERROR:") || (vstr[3] == "FATAL:") || (vstr[3] == "SILENT:") ) bret = true; CPPUNIT_ASSERT(bret); // name判定 bret = false; if( (vstr[4] == "manager:") || (vstr[4] == "TestName:") || (vstr[4] == "NamingOnCorba:") || (vstr[4] == "NamingManager:") || (vstr[4] == "ManagerServant:") ) bret = true; CPPUNIT_ASSERT(bret); } // std::cout << "test_constract_name() OUT" << std::endl; } /*! * @brief ログ出力のデッドロックテスト * * - RTC_LOG出力時、引数の関数内でログ出力がある場合にデッドロックしないか? */ void test_deadlock(void) { // std::cout << "test_deadlock() IN" << std::endl; coil::LogStreamBuffer logger; std::stringstream s0; logger.addStream(s0.rdbuf()); LoggerMock rtclog(&logger); rtclog.setName("Test"); rtclog.setDateFormat(""); rtclog.setLevel("TRACE"); s0.str(""); // ロックモード設定 rtclog.enableLock(); RTC_TRACE(("RTC_TRACE1 %s", rtclog.test_string().c_str())); std::string rstr; getline(s0, rstr); CPPUNIT_ASSERT_EQUAL(std::string(" TRACE: Test: RTC_TRACE2 test_string()"), rstr); getline(s0, rstr); CPPUNIT_ASSERT_EQUAL(std::string(" TRACE: Test: RTC_TRACE1 TestString"), rstr); // ロックモード解除 rtclog.disableLock(); // std::cout << "test_deadlock() OUT" << std::endl; } }; }; // namespace Tests /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(Tests::SystemLoggerTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // SystemLoggerTests_cpp
1202  RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt"));
1203  RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str");
1204  RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt"));
1205  RTC_PARANOID_STR("Macro RTL_PARANOID tests str");
1206 
1207  RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt"));
1208  RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str");
1209  RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt"));
1210  RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str");
1211 
1212  RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt"));
1213  RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str");
1214  RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt"));
1215  RTC_TRACE_STR("Macro RTL_TRACE tests str");
1216 
1217  RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt"));
1218  RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str");
1219  RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt"));
1220  RTC_DEBUG_STR("Macro RTL_DEBUG tests str");
1221 
1222  RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt"));
1223  RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str");
1224  RTC_INFO( ("Macro RTL_INFO tests %s","fmt"));
1225  RTC_INFO_STR("Macro RTL_INFO tests str");
1226 
1227  RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt"));
1228  RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str");
1229  RTC_WARN( ("Macro RTL_WARN tests %s","fmt"));
1230  RTC_WARN_STR("Macro RTL_WARN tests str");
1231 
1232  RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt"));
1233  RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str");
1234  RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt"));
1235  RTC_ERROR_STR("Macro RTL_ERROR tests str");
1236 
1237  RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt"));
1238  RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str");
1239  RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt"));
1240  RTC_FATAL_STR("Macro RTL_FATAL tests str");
1241 
1242  RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt"));
1243  RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str");
1244 
1245  m_mgr->terminate();
1246 
1247  // rtc*.log ファイルが作成され、4列目のログレベルが INFO以下か?
1248  // INFO WARNING ERROR FATAL SILENT だけが記録されているか?
1249  // Aug 03 14:03:09 INFO: manager: OpenRTM-aist-1.0.0
1250  // [0] 1 2 3 4 5
1251  std::string rstr;
1252  std::vector<std::string> vstr;
1253  bool bret;
1254  std::ifstream ifs(logouts[0].c_str());
1255  while(getline(ifs, rstr))
1256  {
1257  if(rstr.size() == 0) break;
1258  vstr = coil::split(rstr, " ");
1259  // ログレベル判定
1260  bret = false;
1261  if( (vstr[3] == "INFO:") || (vstr[3] == "WARNING:") || (vstr[3] == "ERROR:") ||
1262  (vstr[3] == "FATAL:") || (vstr[3] == "SILENT:") )
1263  bret = true;
1264  CPPUNIT_ASSERT(bret);
1265 
1266  // name判定
1267  bret = false;
1268  if( (vstr[4] == "manager:") || (vstr[4] == "TestName:") ||
1269  (vstr[4] == "NamingOnCorba:") || (vstr[4] == "NamingManager:") ||
1270  (vstr[4] == "ManagerServant:") )
1271  bret = true;
1272  CPPUNIT_ASSERT(bret);
1273  }
1274 // std::cout << "test_constract_name() OUT" << std::endl;
1275  }
1276 
1282  void test_deadlock(void)
1283  {
1284 // std::cout << "test_deadlock() IN" << std::endl;
1286  std::stringstream s0;
1287 
1288  logger.addStream(s0.rdbuf());
1289  LoggerMock rtclog(&logger);
1290  rtclog.setName("Test");
1291  rtclog.setDateFormat("");
1292  rtclog.setLevel("TRACE");
1293  s0.str("");
1294  // ロックモード設定 rtclog.enableLock(); RTC_TRACE(("RTC_TRACE1 %s", rtclog.test_string().c_str())); std::string rstr; getline(s0, rstr); CPPUNIT_ASSERT_EQUAL(std::string(" TRACE: Test: RTC_TRACE2 test_string()"), rstr); getline(s0, rstr); CPPUNIT_ASSERT_EQUAL(std::string(" TRACE: Test: RTC_TRACE1 TestString"), rstr); // ロックモード解除 rtclog.disableLock(); // std::cout << "test_deadlock() OUT" << std::endl; } }; }; // namespace Tests /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(Tests::SystemLoggerTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // SystemLoggerTests_cpp
1295  rtclog.enableLock();
1296  RTC_TRACE(("RTC_TRACE1 %s", rtclog.test_string().c_str()));
1297 
1298  std::string rstr;
1299  getline(s0, rstr);
1300  CPPUNIT_ASSERT_EQUAL(std::string(" TRACE: Test: RTC_TRACE2 test_string()"), rstr);
1301  getline(s0, rstr);
1302  CPPUNIT_ASSERT_EQUAL(std::string(" TRACE: Test: RTC_TRACE1 TestString"), rstr);
1303 
1304  // ロックモード解除 rtclog.disableLock(); // std::cout << "test_deadlock() OUT" << std::endl; } }; }; // namespace Tests /* * Register test suite */ CPPUNIT_TEST_SUITE_REGISTRATION(Tests::SystemLoggerTests); #ifdef LOCAL_MAIN int main(int argc, char* argv[]) { FORMAT format = TEXT_OUT; int target = 0; std::string xsl; std::string ns; std::string fname; std::ofstream ofs; int i(1); while (i < argc) { std::string arg(argv[i]); std::string next_arg; if (i + 1 < argc) next_arg = argv[i + 1]; else next_arg = ""; if (arg == "--text") { format = TEXT_OUT; break; } if (arg == "--xml") { if (next_arg == "") { fname = argv[0]; fname += ".xml"; } else { fname = next_arg; } format = XML_OUT; ofs.open(fname.c_str()); } if ( arg == "--compiler" ) { format = COMPILER_OUT; break; } if ( arg == "--cerr" ) { target = 1; break; } if ( arg == "--xsl" ) { if (next_arg == "") xsl = "default.xsl"; else xsl = next_arg; } if ( arg == "--namespace" ) { if (next_arg == "") { std::cerr << "no namespace specified" << std::endl; exit(1); } else { xsl = next_arg; } } ++i; } CppUnit::TextUi::TestRunner runner; if ( ns.empty() ) runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); else runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest()); CppUnit::Outputter* outputter = 0; std::ostream* stream = target ? &std::cerr : &std::cout; switch ( format ) { case TEXT_OUT : outputter = new CppUnit::TextOutputter(&runner.result(),*stream); break; case XML_OUT : std::cout << "XML_OUT" << std::endl; outputter = new CppUnit::XmlOutputter(&runner.result(), ofs, "shift_jis"); static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl); break; case COMPILER_OUT : outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream); break; } runner.setOutputter(outputter); runner.run(); return 0; // runner.run() ? 0 : 1; } #endif // MAIN #endif // SystemLoggerTests_cpp
1305  rtclog.disableLock();
1306 // std::cout << "test_deadlock() OUT" << std::endl;
1307  }
1308 
1309  };
1310 }; // namespace Tests
1311 
1312 /*
1313  * Register test suite
1314  */
1316 
1317 #ifdef LOCAL_MAIN
1318 int main(int argc, char* argv[])
1319 {
1320 
1321  FORMAT format = TEXT_OUT;
1322  int target = 0;
1323  std::string xsl;
1324  std::string ns;
1325  std::string fname;
1326  std::ofstream ofs;
1327 
1328  int i(1);
1329  while (i < argc)
1330  {
1331  std::string arg(argv[i]);
1332  std::string next_arg;
1333  if (i + 1 < argc) next_arg = argv[i + 1];
1334  else next_arg = "";
1335 
1336  if (arg == "--text") { format = TEXT_OUT; break; }
1337  if (arg == "--xml")
1338  {
1339  if (next_arg == "")
1340  {
1341  fname = argv[0];
1342  fname += ".xml";
1343  }
1344  else
1345  {
1346  fname = next_arg;
1347  }
1348  format = XML_OUT;
1349  ofs.open(fname.c_str());
1350  }
1351  if ( arg == "--compiler" ) { format = COMPILER_OUT; break; }
1352  if ( arg == "--cerr" ) { target = 1; break; }
1353  if ( arg == "--xsl" )
1354  {
1355  if (next_arg == "") xsl = "default.xsl";
1356  else xsl = next_arg;
1357  }
1358  if ( arg == "--namespace" )
1359  {
1360  if (next_arg == "")
1361  {
1362  std::cerr << "no namespace specified" << std::endl;
1363  exit(1);
1364  }
1365  else
1366  {
1367  xsl = next_arg;
1368  }
1369  }
1370  ++i;
1371  }
1372  CppUnit::TextUi::TestRunner runner;
1373  if ( ns.empty() )
1374  runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
1375  else
1376  runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest());
1377  CppUnit::Outputter* outputter = 0;
1378  std::ostream* stream = target ? &std::cerr : &std::cout;
1379  switch ( format )
1380  {
1381  case TEXT_OUT :
1382  outputter = new CppUnit::TextOutputter(&runner.result(),*stream);
1383  break;
1384  case XML_OUT :
1385  std::cout << "XML_OUT" << std::endl;
1386  outputter = new CppUnit::XmlOutputter(&runner.result(),
1387  ofs, "shift_jis");
1388  static_cast<CppUnit::XmlOutputter*>(outputter)->setStyleSheet(xsl);
1389  break;
1390  case COMPILER_OUT :
1391  outputter = new CppUnit::CompilerOutputter(&runner.result(),*stream);
1392  break;
1393  }
1394  runner.setOutputter(outputter);
1395  runner.run();
1396  return 0; // runner.run() ? 0 : 1;
1397 }
1398 #endif // MAIN
1399 #endif // SystemLoggerTests_cpp
void setDateFormat(const char *format)
Set date/time format for adding the header.
std::string test_string(void)
#define RTC_ERROR(fmt)
Error log output macro.
Definition: SystemLogger.h:422
int main(int argc, char **argv)
virtual void header(int level)
Message prefix appender function.
virtual void tearDown()
Test finalization.
RT-Component.
void test_logfile_VERBOSE(void)
logfile出力のテスト
log_streambuf template class
#define RTC_ERROR_STR(str)
Definition: SystemLogger.h:423
RT component logger class.
void test_logfile_WARNING(void)
logfile出力のテスト
void test_logfile_PARANOID(void)
logfile出力のテスト
void test_logfile_INFO(void)
logfile出力のテスト
std::string & getLogLevel()
Get the log level of the configuration.
Definition: Manager.h:286
void terminate()
Terminate manager.
Definition: Manager.cpp:169
vstring split(const std::string &input, const std::string &delimiter, bool ignore_empty)
Split string by delimiter.
Definition: stringutil.cpp:346
Manager class.
Definition: Manager.h:80
void test_logfile_FATAL(void)
logfile出力のテスト
void setName(const char *name)
Set suffix of date/time string of header.
void setDateFormat(const char *format)
#define RTC_VERBOSE_STR(str)
Definition: SystemLogger.h:534
virtual ~LoggerMock(void)
#define RTC_INFO_STR(str)
Definition: SystemLogger.h:467
int strToLevel(const char *level)
#define RTC_WARN(fmt)
Warning log output macro.
Definition: SystemLogger.h:444
RTComponent manager class.
#define RTC_FATAL(fmt)
Error log output macro.
Definition: SystemLogger.h:400
#define RTC_DEBUG_STR(str)
Definition: SystemLogger.h:489
#define RTC_PARANOID(fmt)
Paranoid level log output macro.
Definition: SystemLogger.h:555
void addStream(streambuf_type *stream, bool cleanup=false)
Destructor.
coil::Properties & getConfig()
Get the manager configuration.
Definition: Manager.h:305
void test_logfile_DEBUG(void)
logfile出力のテスト
def bret
7 送受信データ比較
Definition: ConnectTest.py:377
#define RTC_DEBUG(fmt)
Debug level log output macro.
Definition: SystemLogger.h:488
void test_setName(void)
setName()メソッドのテスト
#define RTC_TRACE(fmt)
static Manager * init(int argc, char **argv)
Initialize manager.
Definition: Manager.cpp:110
#define RTC_LOG_STR(LV, str)
Definition: SystemLogger.h:373
void test_setDateFormat(void)
setDateFormat()メソッドのテスト
CPPUNIT_TEST_SUITE_REGISTRATION(Tests::SystemLoggerTests)
#define RTC_WARN_STR(str)
Definition: SystemLogger.h:445
#define RTC_LOG(LV, fmt)
void test_strToLevel(void)
strToLevel()メソッドのテスト
void enableLock()
Enable the lock mode.
virtual ~SystemLoggerTests()
Destructor.
std::string getDate(void)
Logger class.
Definition: SystemLogger.h:99
void test_logfile_ERROR(void)
logfile出力のテスト
std::string mock_m_dateFormat
void test_logfile_SILENT(void)
logfile出力のテスト
void test_setLevel(void)
setLevel()メソッドのテスト
void header(int level)
Message prefix appender function.
virtual void setUp()
Test initialization.
bool setLevel(const char *level)
Set log level by string.
ostream_type & level(int level)
Acquire log stream.
Class represents a set of properties.
Definition: Properties.h:101
LoggerMock(RTC::LogStreamBuf *streambuf)
void setName(const char *name)
#define RTC_INFO(fmt)
Information level log output macro.
Definition: SystemLogger.h:466
::OutPortBase::Logger logger
void lock()
Acquire log lock Acquire log lock when the lock mode is set.
void test_getDate(void)
getDate()メソッドのテスト
int strToLevel(const char *level)
Set the log level Set the log level corresponding to the given string.
void test_deadlock(void)
ログ出力のデッドロックテスト
void test_constract_name(void)
コンストラクタログレベルのテスト
void disableLock()
Disable the lock mode.
void unlock()
Release the log lock Release the log lock when the lock mode is set.
std::string getDate(void)
Get the current formatted date/time string Get the current datetime described by specified format...
#define RTC_FATAL_STR(str)
Definition: SystemLogger.h:401
void test_logfile_TRACE(void)
logfile出力のテスト
#define RTC_VERBOSE(fmt)
Verbose level log output macro.
Definition: SystemLogger.h:533
#define RTC_TRACE_STR(str)
Definition: SystemLogger.h:511
#define RTC_PARANOID_STR(str)
Definition: SystemLogger.h:556
void test_header(void)
header()メソッドのテスト


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Feb 28 2022 23:00:45