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.
41 lines
917 B
41 lines
917 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.printToConsole()) {
|
|
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);
|
|
}
|
|
|
|
Logger::getInstance()->setPrintTimeStamp(argparser.printTimestamp());
|
|
Logger::getInstance()->setPrintUserName(argparser.printUsername());
|
|
|
|
std::string line;
|
|
while (std::getline(std::cin, line))
|
|
LOG << line << END;
|
|
|
|
if (!argparser.printToConsole())
|
|
logfile.close();
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|
|
|