2 * test cases for loggin module.
4 * (c) Copyright 2007 by Intra2net AG
16 #define BOOST_TEST_DYN_LINK
17 #include <boost/test/unit_test.hpp>
19 #include <logfunc.hpp>
20 #include <tracefunc.hpp>
24 #define DOUT(msg) std::cout << msg << std::endl
26 #define DOUT(msg) do {} while (0)
33 Logger::PartLogger module_logger(HERE);
35 } // eo namespace <anonymous>
37 class TestLoggingFixture
46 Logger::set_log_level(0);
47 Logger::enable_syslog(false);
48 Logger::enable_stderr_log(false);
49 Logger::enable_log_file(false);
53 BOOST_FIXTURE_TEST_SUITE(TestLogging, TestLoggingFixture)
55 BOOST_AUTO_TEST_CASE(Syslog1)
57 //Logger::enable_syslog("I2N Unittest", Logger::Facility::User );
58 Logger::enable_syslog( Logger::Facility::User );
59 Logger::PartLogger log(__func__);
61 Logger::set_log_level( 7 );
62 Logger::enable_stderr_log();
63 Logger::enable_log_file("zzUnitTest.log");
65 log.error("Test error msg");
66 log.error() << "Stream test error msg #" << 2 << ".";
67 log.warning() << "Stream test warning msg";
68 log.notice() << "Stream test notice msg";
69 log.info() << "Stream test info msg";
70 log.debug() << "Stream test debug msg";
73 << "multiline log message" << std::endl
74 << "this (second) line should be indented" << std::endl
75 << "and this also!" << std::endl;
76 log.debug(HERE) << "This should have a source info";
78 module_logger.debug(HERE) << "module level debug message with source loc info";
83 BOOST_AUTO_TEST_CASE(TestScopeTrace1)
85 //Logger::enable_syslog("I2N Unittest", Logger::Facility::User );
86 Logger::enable_syslog( Logger::Facility::User );
87 Logger::PartLogger log(__func__);
89 Logger::set_log_level( 7 );
90 Logger::enable_stderr_log();
91 Logger::enable_log_file("zzUnitTest.log");
95 log.notice() << "Stream test notice msg";
101 SCOPETRACKER(); // #4
105 SCOPETRACKER(); // #3
108 } // eo TestScopeTrace1()
110 BOOST_AUTO_TEST_SUITE_END()