Browse Source

Added logging for both main files.

tempestpy_adaptions
dehnert 12 years ago
parent
commit
e748c35268
  1. 46
      src/mrmc.cpp
  2. 24
      test/mrmc-tests.cpp

46
src/mrmc.cpp

@ -24,26 +24,44 @@
#include "src/utility/settings.h" #include "src/utility/settings.h"
#include "Eigen/Sparse" #include "Eigen/Sparse"
#include <log4cplus/logger.h>
#include <log4cplus/loggingmacros.h>
#include <log4cplus/configurator.h>
#include "log4cplus/logger.h"
#include "log4cplus/loggingmacros.h"
#include "log4cplus/consoleappender.h"
#include "log4cplus/fileappender.h"
#include "src/exceptions/InvalidSettings.h" #include "src/exceptions/InvalidSettings.h"
log4cplus::Logger logger;
/*!
* Initializes the logging framework.
*/
void setUpLogging() {
log4cplus::SharedAppenderPtr fileLogAppender(new log4cplus::FileAppender("mrmc.log"));
fileLogAppender->setName("mainFileAppender");
fileLogAppender->setLayout(std::auto_ptr<log4cplus::Layout>(new log4cplus::PatternLayout("%-5p - %D{%H:%M:%s} (%r ms) - %F:%L : %m%n")));
logger = log4cplus::Logger::getInstance("mainLogger");
logger.addAppender(fileLogAppender);
// Uncomment these lines to enable console logging output
// log4cplus::SharedAppenderPtr consoleLogAppender(new log4cplus::ConsoleAppender());
// consoleLogAppender->setName("mainConsoleAppender");
// consoleLogAppender->setLayout(std::auto_ptr<log4cplus::Layout>(new log4cplus::PatternLayout("%-5p - %D{%H:%M:%s} (%r ms) - %F:%L : %m%n")));
// logger.addAppender(consoleLogAppender);
}
int main(const int argc, const char* argv[]) { int main(const int argc, const char* argv[]) {
setUpLogging();
mrmc::settings::Settings* s = NULL; mrmc::settings::Settings* s = NULL;
log4cplus::BasicConfigurator loggingConfig;
loggingConfig.configure();
log4cplus::Logger logger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("main"));
LOG4CPLUS_INFO(logger, "This is the Markov Reward Model Checker (MRMC) by i2 of RWTH Aachen university."); LOG4CPLUS_INFO(logger, "This is the Markov Reward Model Checker (MRMC) by i2 of RWTH Aachen university.");
try
{
try {
s = new mrmc::settings::Settings(argc, argv, nullptr); s = new mrmc::settings::Settings(argc, argv, nullptr);
} }
catch (mrmc::exceptions::InvalidSettings&)
{
std::cout << "Could not recover from settings error, terminating." << std::endl;
catch (mrmc::exceptions::InvalidSettings&) {
LOG4CPLUS_FATAL(logger, "Could not recover from settings error, terminating.");
delete s; delete s;
return 1; return 1;
} }
@ -69,6 +87,8 @@ int main(const int argc, const char* argv[]) {
delete s; delete s;
} }
LOG4CPLUS_INFO(logger, "Nothing more to do, exiting.");
return 0; return 0;
} }

24
test/mrmc-tests.cpp

@ -1,8 +1,32 @@
#include <iostream> #include <iostream>
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "log4cplus/logger.h"
#include "log4cplus/loggingmacros.h"
#include "log4cplus/consoleappender.h"
#include "log4cplus/fileappender.h"
log4cplus::Logger logger;
/*!
* Initializes the logging framework.
*/
void setUpLogging() {
log4cplus::SharedAppenderPtr fileLogAppender(new log4cplus::FileAppender("mrmc-tests.log"));
fileLogAppender->setName("mainFileAppender");
fileLogAppender->setLayout(std::auto_ptr<log4cplus::Layout>(new log4cplus::PatternLayout("%-5p - %D{%H:%M:%s} (%r ms) - %F:%L : %m%n")));
logger = log4cplus::Logger::getInstance("mainLogger");
logger.addAppender(fileLogAppender);
// Uncomment these lines to enable console logging output
// log4cplus::SharedAppenderPtr consoleLogAppender(new log4cplus::ConsoleAppender());
// consoleLogAppender->setName("mainConsoleAppender");
// consoleLogAppender->setLayout(std::auto_ptr<log4cplus::Layout>(new log4cplus::PatternLayout("%-5p - %D{%H:%M:%s} (%r ms) - %F:%L : %m%n")));
// logger.addAppender(consoleLogAppender);
}
int main(int argc, char** argv) { int main(int argc, char** argv) {
setUpLogging();
std::cout << "MRMC Testing Suite" << std::endl; std::cout << "MRMC Testing Suite" << std::endl;
testing::InitGoogleTest(&argc, argv); testing::InitGoogleTest(&argc, argv);

Loading…
Cancel
Save