From e63f79169b2c031bdc1a4bb6ba8df34363e9e3c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 9 Dec 2016 01:34:46 +0100 Subject: Use an other implementation of a null_stream for the logger --- louloulibs/logger/logger.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'louloulibs/logger/logger.cpp') diff --git a/louloulibs/logger/logger.cpp b/louloulibs/logger/logger.cpp index 7336579..92a3d9b 100644 --- a/louloulibs/logger/logger.cpp +++ b/louloulibs/logger/logger.cpp @@ -3,14 +3,18 @@ Logger::Logger(const int log_level): log_level(log_level), - stream(std::cout.rdbuf()) + stream(std::cout.rdbuf()), + null_buffer{}, + null_stream{&null_buffer} { } Logger::Logger(const int log_level, const std::string& log_file): log_level(log_level), ofstream(log_file.data(), std::ios_base::app), - stream(ofstream.rdbuf()) + stream(ofstream.rdbuf()), + null_buffer{}, + null_stream{&null_buffer} { } -- cgit v1.2.3 From f9c31cb129b17d57281c87b549b382957dca425e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sat, 10 Dec 2016 03:59:26 +0100 Subject: The logger writes to std::clog --- louloulibs/logger/logger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'louloulibs/logger/logger.cpp') diff --git a/louloulibs/logger/logger.cpp b/louloulibs/logger/logger.cpp index 92a3d9b..79f9e8f 100644 --- a/louloulibs/logger/logger.cpp +++ b/louloulibs/logger/logger.cpp @@ -3,7 +3,7 @@ Logger::Logger(const int log_level): log_level(log_level), - stream(std::cout.rdbuf()), + stream(std::clog.rdbuf()), null_buffer{}, null_stream{&null_buffer} { -- cgit v1.2.3 From 6b245ee64a828dd86da0acf6ffb56b618b170ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 13 Dec 2016 23:37:43 +0100 Subject: Switch back to using std::cout instead of std::clog --- louloulibs/logger/logger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'louloulibs/logger/logger.cpp') diff --git a/louloulibs/logger/logger.cpp b/louloulibs/logger/logger.cpp index 79f9e8f..92a3d9b 100644 --- a/louloulibs/logger/logger.cpp +++ b/louloulibs/logger/logger.cpp @@ -3,7 +3,7 @@ Logger::Logger(const int log_level): log_level(log_level), - stream(std::clog.rdbuf()), + stream(std::cout.rdbuf()), null_buffer{}, null_stream{&null_buffer} { -- cgit v1.2.3 From 0ab40dc1ab4e689921da54080b135e1d22b1c586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 14 Mar 2017 21:45:23 +0100 Subject: Refactoring louloulibs and cmake Use OBJECT libraries Remove the louloulibs directory Write FOUND variables in the cache --- louloulibs/logger/logger.cpp | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 louloulibs/logger/logger.cpp (limited to 'louloulibs/logger/logger.cpp') diff --git a/louloulibs/logger/logger.cpp b/louloulibs/logger/logger.cpp deleted file mode 100644 index 92a3d9b..0000000 --- a/louloulibs/logger/logger.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include - -Logger::Logger(const int log_level): - log_level(log_level), - stream(std::cout.rdbuf()), - null_buffer{}, - null_stream{&null_buffer} -{ -} - -Logger::Logger(const int log_level, const std::string& log_file): - log_level(log_level), - ofstream(log_file.data(), std::ios_base::app), - stream(ofstream.rdbuf()), - null_buffer{}, - null_stream{&null_buffer} -{ -} - -std::unique_ptr& Logger::instance() -{ - static std::unique_ptr instance; - - if (!instance) - { - const std::string log_file = Config::get("log_file", ""); - const int log_level = Config::get_int("log_level", 0); - if (log_file.empty()) - instance = std::make_unique(log_level); - else - instance = std::make_unique(log_level, log_file); - } - return instance; -} - -std::ostream& Logger::get_stream(const int lvl) -{ - if (lvl >= this->log_level) - return this->stream; - return this->null_stream; -} -- cgit v1.2.3