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

@ -1,19 +1,11 @@
#ifndef ARGPARSER_HPP #ifndef ARGPARSER_HPP
#define ARGPARSER_HPP #define ARGPARSER_HPP
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
// #include <ostream>
// #include <utility> // move
// #include "Singleton_DCLP.hpp"
class ArgParser class ArgParser
{ {
public: public:
@ -23,7 +15,7 @@ public:
std::ostringstream oss; std::ostringstream oss;
oss oss
<< "Usage: cpplogger [OPTION]\n" << "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" << "\n"
<< "Options:\n" << "Options:\n"
<< " -c, log to console\n" << " -c, log to console\n"

@ -19,8 +19,7 @@ public:
Singleton_DCLP& operator=( const Singleton_DCLP& ) = delete; Singleton_DCLP& operator=( const Singleton_DCLP& ) = delete;
/** I knowthat c++-11 has the "atomic initializers" and this can be /** c++-11 has the "atomic initializers" and this can be replaced with:
* replaced with:
* *
* static T getInstance() * static T getInstance()
* { * {

@ -1,4 +1,3 @@
// #include <cstdlib>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
@ -16,7 +15,8 @@ int main(int argc, char* argv[])
if (argparser.useConsole()) { if (argparser.useConsole()) {
Logger::getInstance()->setStream(&std::cout); Logger::getInstance()->setStream(&std::cout);
} else { } 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()) { if (!logfile.is_open()) {
std::cerr << "Could not open file '" << std::cerr << "Could not open file '" <<
argparser.logFile() << "' to append." << std::endl; argparser.logFile() << "' to append." << std::endl;
@ -25,8 +25,9 @@ int main(int argc, char* argv[])
Logger::getInstance()->setStream(&logfile); Logger::getInstance()->setStream(&logfile);
} }
std::string line;
LOG << "hello" << std::endl; while (std::getline(std::cin, line))
LOG << line << std::endl;
if (!argparser.useConsole()) if (!argparser.useConsole())
logfile.close(); logfile.close();

Loading…
Cancel
Save