diff --git a/.gitignore b/.gitignore index 945a3ef..b5586e1 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,4 @@ cpp_logger_assignment.kdev4 # bin cpplogger - +cpplogger_test diff --git a/ArgParser.hpp b/ArgParser.hpp index d17dc46..649def8 100644 --- a/ArgParser.hpp +++ b/ArgParser.hpp @@ -34,7 +34,8 @@ public: << "\n" << "Option -c and -f are mutually exclusive, specify one.\n" << "\n" - << "Denes Matetelki \n"; + << "Homepage: \n" + << "Author: Denes Matetelki \n"; if (cout) std::cout << oss.str(); diff --git a/README.md b/README.md index 6bb0f30..aa08af1 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,72 @@ # cpp_logger_assignment -Programming exercise to implement a logger class \ No newline at end of file +Programming exercise to implement a logger class + + +Build it with: + +``` +cmake . +make +./cpplogger +``` + +And/or run unit-tests, using [catch2](https://github.com/catchorg/Catch2) as a submodule. + + +``` +git submodule update --init --recursive +cmake . -DBUILD_TESTS=ON +make +./cpplogger_test +``` + +## The binary can be used as a command line tool: + + +``` +./cpplogger +Usage: cpplogger [OPTION] +Logs the input (till EOF) to the console or to a file. + +Options: + -c, log to console + -f FILE log to FILE + -t, prefix lines with timestamp + -n, prefix lines with hostname + -u, prefix lines with user name + -h print this help + +Option -c and -f are mutually exclusive, specify one. + +Homepage: +Author: Denes Matetelki +``` + +Examples: + +``` +./cpplogger -t -u -c +hello world +Mon Nov 11 16:01:03 2019 dmatetelki hello world +how is it going +Mon Nov 11 16:01:09 2019 dmatetelki how is it going +``` + +``` +cat /tmp/this.txt | ./cpplogger -f /tmp/that.txt +``` + +## Or used as a library + +``` +#include + +Logger::getInstance()->setStream(std::ostream* os); + +Logger::getInstance()->setPrintTimeStamp(true); +Logger::getInstance()->setPrintUserName(false); + +LOG << word1 << word2 << variable << END; +``` +