Commit eb7576c7 authored by kulvait's avatar kulvait

Organization of tests

parent 696bad81
#include "PlogSetup.h"
namespace CTL {
namespace util {
PlogSetup::PlogSetup(plog::Severity verbosityLevel, std::string csvLogFile, bool logToConsole)
: verbosityLevel(verbosityLevel)
, csvLogFile(csvLogFile)
, logToConsole(logToConsole)
{
}
void PlogSetup::initLogging()
{
if(!csvLogFile.empty())
{
static plog::RollingFileAppender<plog::CsvFormatter> fileAppender(csvLogFile.c_str(), 0,
0);
if(logToConsole)
{
static plog::ColorConsoleAppender<plog::TxtFormatter> consoleAppender;
plog::init(verbosityLevel, &fileAppender).addAppender(&consoleAppender);
} else
{
plog::init(verbosityLevel, &fileAppender);
}
} else
{
if(logToConsole)
{
static plog::ColorConsoleAppender<plog::TxtFormatter> consoleAppender;
plog::init(verbosityLevel, &consoleAppender);
}
}
return;
}
} // namespace util
} // namespace CTL
#pragma once
#define PLOG_CAPTURE_FILE
// External dependencies
#include <plog/Appenders/ColorConsoleAppender.h>
#include <plog/Log.h>
#include <string>
namespace CTL {
namespace util {
class PlogSetup
{
public:
PlogSetup(plog::Severity verbosityLevel, std::string csvLogFile, bool logToConsole);
void initLogging();
private:
plog::Severity verbosityLevel; // Set to debug to see the debug messages, info messages
std::string csvLogFile; // Set to empty string to disable
bool logToConsole;
};
} // namespace util
} // namespace CTL
#define CATCH_CONFIG_RUNNER
#include "PlogSetup.h"
#include "PLOG/PlogSetup.h"
#include "catch.hpp"
#include "PROG/RunTimeInfo.hpp"
......@@ -15,7 +15,7 @@ int main(int argc, char* argv[])
= plog::debug; // Set to debug to see the debug messages, info messages
std::string csvLogFile = "/tmp/imageRegistrationLog.csv"; // Set NULL to disable
bool logToConsole = true;
util::PlogSetup plogSetup(verbosityLevel, csvLogFile, logToConsole);
plog::PlogSetup plogSetup(verbosityLevel, csvLogFile, logToConsole);
plogSetup.initLogging();
}
int result = Catch::Session().run(argc, argv);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment