From 6e6d2289c1627aa51e7119bacc0222a1da345a63 Mon Sep 17 00:00:00 2001 From: denes Date: Tue, 5 Nov 2019 14:26:59 +0100 Subject: [PATCH] Read input --- ArgParser.hpp | 10 +--------- Singleton_DCLP.hpp | 3 +-- main.cpp | 9 +++++---- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/ArgParser.hpp b/ArgParser.hpp index ae65a25..c7e9d89 100644 --- a/ArgParser.hpp +++ b/ArgParser.hpp @@ -1,19 +1,11 @@ #ifndef ARGPARSER_HPP #define ARGPARSER_HPP -#include -#include -#include #include #include #include -// #include -// #include // move - -// #include "Singleton_DCLP.hpp" - class ArgParser { public: @@ -23,7 +15,7 @@ public: std::ostringstream oss; oss << "Usage: cpplogger [OPTION]\n" - << "Logs the input to the console or to a file.\n" + << "Logs the input (till EOF) to the console or to a file.\n" << "\n" << "Options:\n" << " -c, log to console\n" diff --git a/Singleton_DCLP.hpp b/Singleton_DCLP.hpp index 755800b..8847843 100644 --- a/Singleton_DCLP.hpp +++ b/Singleton_DCLP.hpp @@ -19,8 +19,7 @@ public: Singleton_DCLP& operator=( const Singleton_DCLP& ) = delete; - /** I knowthat c++-11 has the "atomic initializers" and this can be - * replaced with: + /** c++-11 has the "atomic initializers" and this can be replaced with: * * static T getInstance() * { diff --git a/main.cpp b/main.cpp index ff26180..787574a 100644 --- a/main.cpp +++ b/main.cpp @@ -1,4 +1,3 @@ -// #include #include #include @@ -16,7 +15,8 @@ int main(int argc, char* argv[]) if (argparser.useConsole()) { Logger::getInstance()->setStream(&std::cout); } else { - logfile.open (argparser.logFile(), std::ios::out | std::ios::app); + 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; @@ -25,8 +25,9 @@ int main(int argc, char* argv[]) Logger::getInstance()->setStream(&logfile); } - - LOG << "hello" << std::endl; + std::string line; + while (std::getline(std::cin, line)) + LOG << line << std::endl; if (!argparser.useConsole()) logfile.close();