diff --git a/core/util/Logger.cc b/core/util/Logger.cc index a32f0196..a2271c46 100644 --- a/core/util/Logger.cc +++ b/core/util/Logger.cc @@ -10,14 +10,13 @@ using std::endl; -void Logger::add(const std::string& what, const std::string& descr) +void Logger::timestamp() { - (*m_pDest) << "[" << descr; - if(m_showTime) - { + (*m_pDest) << "[" << m_description; + if (m_showTime) { time_t rawtime; struct tm* timeinfo; - char buffer [80]; + char buffer[80]; time(&rawtime); timeinfo = localtime(&rawtime); @@ -25,5 +24,5 @@ void Logger::add(const std::string& what, const std::string& descr) strftime(buffer, 80, "%H:%M:%S", timeinfo); (*m_pDest) << " " << buffer; } - (*m_pDest) << "] " << what; + (*m_pDest) << "] "; } diff --git a/core/util/Logger.hpp b/core/util/Logger.hpp index f98009c9..9f0f57b9 100644 --- a/core/util/Logger.hpp +++ b/core/util/Logger.hpp @@ -17,6 +17,8 @@ class Logger std::ostream* m_pDest; std::string m_description; bool m_showTime; + void timestamp(); + public: /** * Constructor. @@ -38,29 +40,15 @@ class Logger m_description = descr; } /** - * Add a new log entry. - * @param what Message for log entry. - * @param descr Description shown alongside this log entry in square - * brackets [ ]. - */ - void add(const std::string& what, const std::string& descr); - /** - * Add a new log entry. - * @param what Message for log entry. The default description is - * being used in square brackets [ ]. - */ - void add(const std::string& what) { add(what, m_description); } - /** - * Simplifies the logging. + * Add a new log entry. Returns a std::ostream reference to continue + * streaming a longer log entry. * @param v data to log */ template inline std::ostream& operator <<(const T& v) { - std::stringstream ss; - ss << v; - add(ss.str()); - return (*m_pDest); + timestamp(); + return (*m_pDest) << v; } };