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.hpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'louloulibs/logger/logger.hpp') diff --git a/louloulibs/logger/logger.hpp b/louloulibs/logger/logger.hpp index 0893c77..b3284a6 100644 --- a/louloulibs/logger/logger.hpp +++ b/louloulibs/logger/logger.hpp @@ -33,15 +33,15 @@ # define __FILENAME__ __FILE__ #endif + /** - * Juste a structure representing a stream doing nothing with its input. + * A buffer, used to construct an ostream that does nothing + * when we output data in it */ -class nullstream: public std::ostream +class NullBuffer: public std::streambuf { -public: - nullstream(): - std::ostream(0) - { } + public: + int overflow(int c) { return c; } }; class Logger @@ -59,9 +59,11 @@ public: private: const int log_level; - std::ofstream ofstream; - nullstream null_stream; + std::ofstream ofstream{}; std::ostream stream; + + NullBuffer null_buffer; + std::ostream null_stream; }; #define WHERE __FILENAME__, ":", __LINE__, ":\t" -- cgit v1.2.3