master
denes 5 years ago
parent 0e65bb9eaf
commit 6e6d2289c1
Signed by: denes
GPG Key ID: A7D50EAD42F9FC9F

@ -1,19 +1,11 @@
#ifndef ARGPARSER_HPP
#define ARGPARSER_HPP
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <iostream>
#include <sstream>
// #include <ostream>
// #include <utility> // 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"

@ -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()
* {

@ -1,4 +1,3 @@
// #include <cstdlib>
#include <iostream>
#include <fstream>
@ -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();

Loading…
Cancel
Save