Programming exercise to implement a logger class
cpp
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.
denes fb2ca5cbd0
Updating the readme file
5 years ago
Catch2@930f49a641 build unit tests with catch2 5 years ago
.gitignore Updating the readme file 5 years ago
.gitmodules build unit tests with catch2 5 years ago
ArgParser.hpp Updating the readme file 5 years ago
CMakeLists.txt build unit tests with catch2 5 years ago
LICENSE Initial commit 5 years ago
Logger.hpp print owner of process 5 years ago
README.md Updating the readme file 5 years ago
Singleton_DCLP.hpp Read input 5 years ago
cpp_logger_test.cpp build unit tests with catch2 5 years ago
main.cpp print owner of process 5 years ago

README.md

cpp_logger_assignment

Programming exercise to implement a logger class

Build it with:

cmake .
make
./cpplogger

And/or run unit-tests, using 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: <https://gitea.matetelki.eu/denes/cpp_logger_assignment>
Author: Denes Matetelki <denes@matetelki.com>

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<CTRL+D>
cat /tmp/this.txt | ./cpplogger -f /tmp/that.txt

Or used as a library

#include <Logger.hpp>

Logger::getInstance()->setStream(std::ostream* os);

Logger::getInstance()->setPrintTimeStamp(true);
Logger::getInstance()->setPrintUserName(false);

LOG  << word1 << word2 << variable << END;