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.

40 lines
848 B

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