diff --git a/Log.cpp b/Log.cpp index 4f54549..391f9fe 100644 --- a/Log.cpp +++ b/Log.cpp @@ -15,6 +15,13 @@ #include #endif +#if LOG_ENABLEFLUSH == 1 +#define FLUSH_COMMAND std::endl +#else +// dont flush +#define FLUSH_COMMAND '\n' +#endif + namespace Log { #if LOG_ENABLEQT == 1 @@ -54,8 +61,7 @@ public: std::ostream* os = getOs(lvl); if (os) { - *os << sbuf; - os->put('\n'); + *os << sbuf << FLUSH_COMMAND; } }; diff --git a/Makefile b/Makefile index 0b94e75..331b8ed 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,8 @@ TARGET = Log.o TEST = test LOG_USEMUTEX ?= 0 LOG_ENABLEQT ?= 0 -CXXFLAGS = -O2 -g -std=c++11 -Wall -Wextra -pedantic-errors -MMD -DLOG_USEMUTEX=$(LOG_USEMUTEX) -DLOG_ENABLEQT=$(LOG_ENABLEQT) +LOG_ENABLEFLUSH ?= 0 +CXXFLAGS = -O2 -g -std=c++11 -Wall -Wextra -pedantic-errors -MMD -DLOG_USEMUTEX=$(LOG_USEMUTEX) -DLOG_ENABLEQT=$(LOG_ENABLEQT) -DLOG_ENABLEFLUSH=$(LOG_ENABLEFLUSH) .PHONY: all clean