all should work now, but test mrwautofunctiontracelog4cxx_test-mt fails, so no multithreading until this is fixed; refs #2

This commit is contained in:
Marc Wäckerlin
2012-07-06 09:35:05 +00:00
parent c5c8f82d05
commit c24a43ccb2
7 changed files with 121 additions and 119 deletions

View File

@@ -67,7 +67,7 @@ void anotherFunction() {
}
#ifdef _MT
#include <boost/thread/thread.hxx>
#include <boost/thread/thread.hpp>
//#include <unistd.h> // sleep, the one from boost::thread does not work!
class Thread {
public:
@@ -91,91 +91,91 @@ namespace mrw {
log4cxx::helpers::Properties properties;
std::string name, cont;
properties.setProperty((name="log4j.rootLogger",
log4cxx::String(name.begin(), name.end())),
std::string(name.begin(), name.end())),
(cont="OFF, A1",
log4cxx::String(cont.begin(), cont.end())));
std::string(cont.begin(), cont.end())));
properties.setProperty((name="log4j.logger.mrw.fn",
log4cxx::String(name.begin(), name.end())),
std::string(name.begin(), name.end())),
(cont="DEBUG",
log4cxx::String(cont.begin(), cont.end())));
std::string(cont.begin(), cont.end())));
properties.setProperty((name="log4j.logger.mrw.fn.global",
log4cxx::String(name.begin(), name.end())),
std::string(name.begin(), name.end())),
(cont="OFF",
log4cxx::String(cont.begin(), cont.end())));
std::string(cont.begin(), cont.end())));
properties.setProperty((name="log4j.logger.mrw.fn.allocator",
log4cxx::String(name.begin(), name.end())),
std::string(name.begin(), name.end())),
(cont="OFF",
log4cxx::String(cont.begin(), cont.end())));
std::string(cont.begin(), cont.end())));
properties.setProperty((name="log4j.logger.mrw.fn.std.*",
log4cxx::String(name.begin(), name.end())),
std::string(name.begin(), name.end())),
(cont="OFF",
log4cxx::String(cont.begin(), cont.end())));
std::string(cont.begin(), cont.end())));
properties.setProperty((name="log4j.logger.mrw.fn.log4cxx",
log4cxx::String(name.begin(), name.end())),
std::string(name.begin(), name.end())),
(cont="OFF",
log4cxx::String(cont.begin(), cont.end())));
std::string(cont.begin(), cont.end())));
properties.setProperty((name="log4j.logger.mrw.fn.boost",
log4cxx::String(name.begin(), name.end())),
std::string(name.begin(), name.end())),
(cont="OFF",
log4cxx::String(cont.begin(), cont.end())));
std::string(cont.begin(), cont.end())));
properties.setProperty((name="log4j.logger.mrw.fn.Thread",
log4cxx::String(name.begin(), name.end())),
std::string(name.begin(), name.end())),
(cont="OFF",
log4cxx::String(cont.begin(), cont.end())));
std::string(cont.begin(), cont.end())));
properties.setProperty((name="log4j.logger.mrw.fn.mrw",
log4cxx::String(name.begin(), name.end())),
std::string(name.begin(), name.end())),
(cont="OFF",
log4cxx::String(cont.begin(), cont.end())));
std::string(cont.begin(), cont.end())));
properties.setProperty((name="log4j.logger.mrw.fn.std",
log4cxx::String(name.begin(), name.end())),
std::string(name.begin(), name.end())),
(cont="OFF",
log4cxx::String(cont.begin(), cont.end())));
std::string(cont.begin(), cont.end())));
properties.setProperty((name="log4j.logger.mrw.fn.new",
log4cxx::String(name.begin(), name.end())),
std::string(name.begin(), name.end())),
(cont="OFF",
log4cxx::String(cont.begin(), cont.end())));
std::string(cont.begin(), cont.end())));
properties.setProperty((name="log4j.logger.mrw.fn.CppUnit",
log4cxx::String(name.begin(), name.end())),
std::string(name.begin(), name.end())),
(cont="OFF",
log4cxx::String(cont.begin(), cont.end())));
std::string(cont.begin(), cont.end())));
properties.setProperty((name="log4j.logger.mrw.fn.__gnu_cxx",
log4cxx::String(name.begin(), name.end())),
std::string(name.begin(), name.end())),
(cont="OFF",
log4cxx::String(cont.begin(), cont.end())));
std::string(cont.begin(), cont.end())));
properties.setProperty((name="log4j.appender.A1",
log4cxx::String(name.begin(), name.end())),
std::string(name.begin(), name.end())),
(cont="org.apache.log4j.FileAppender",
log4cxx::String(cont.begin(), cont.end())));
std::string(cont.begin(), cont.end())));
properties.setProperty((name="log4j.appender.A1.layout",
log4cxx::String(name.begin(), name.end())),
std::string(name.begin(), name.end())),
(cont="org.apache.log4j.PatternLayout",
log4cxx::String(cont.begin(), cont.end())));
std::string(cont.begin(), cont.end())));
#ifdef _MT
properties.setProperty((name="log4j.appender.A1.layout.ConversionPattern",
log4cxx::String(name.begin(), name.end())),
std::string(name.begin(), name.end())),
(cont="%t-%-27c%m%n",
log4cxx::String(cont.begin(), cont.end())));
std::string(cont.begin(), cont.end())));
properties.setProperty((name="log4j.appender.A1.filename",
log4cxx::String(name.begin(), name.end())),
std::string(name.begin(), name.end())),
(cont="mrwautofunctiontracelog4cxx_test-mt.log",
log4cxx::String(cont.begin(), cont.end())));
std::string(cont.begin(), cont.end())));
#else
properties.setProperty((name="log4j.appender.A1.layout.ConversionPattern",
log4cxx::String(name.begin(), name.end())),
std::string(name.begin(), name.end())),
(cont="%-27c%m%n",
log4cxx::String(cont.begin(), cont.end())));
std::string(cont.begin(), cont.end())));
properties.setProperty((name="log4j.appender.A1.filename",
log4cxx::String(name.begin(), name.end())),
std::string(name.begin(), name.end())),
(cont="mrwautofunctiontracelog4cxx_test.log",
log4cxx::String(cont.begin(), cont.end())));
std::string(cont.begin(), cont.end())));
#endif
log4cxx::PropertyConfigurator::configure(properties);
#ifdef _MT
// sleep(4); // to be reproducable, wait for "main" flag
Thread threadFunction;
boost::thread::thread thread1(threadFunction);
boost::thread::thread thread2(threadFunction);
boost::thread::thread thread3(threadFunction);
boost::thread thread1(threadFunction);
boost::thread thread2(threadFunction);
boost::thread thread3(threadFunction);
#endif
anotherFunction();
#ifdef _MT