You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
774 B

#include <iostream>
#include <fstream>
#include "ArgParser.hpp"
#include "Logger.hpp"
int main(int argc, char* argv[])
{
ArgParser argparser;
const int r = argparser.parse(argc, argv);
if (r != -1) return r;
std::ofstream logfile;
if (argparser.useConsole()) {
Logger::getInstance()->setStream(&std::cout);
} else {
logfile.open (argparser.logFile(),
std::ios::out | std::ios::app);
if (!logfile.is_open()) {
std::cerr << "Could not open file '" <<
argparser.logFile() << "' to append." << std::endl;
return EXIT_FAILURE;
}
Logger::getInstance()->setStream(&logfile);
}
std::string line;
while (std::getline(std::cin, line))
LOG << line << std::endl;
if (!argparser.useConsole())
logfile.close();
return EXIT_SUCCESS;
}