From ca49316628e8e3e6161d9a9649893664ef36c925 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 31 Aug 2014 14:32:24 +0300 Subject: Improve packets logging speed. --- src/logger.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/logger.cpp') diff --git a/src/logger.cpp b/src/logger.cpp index d53ebc99b..024de4660 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -119,6 +119,37 @@ void Logger::dlog(const std::string &str) if (mLogToStandardOut) std::cout << timeStr.str() << str << std::endl; } + +void Logger::dlog2(const std::string &str, const char* const comment) +{ + if (!mDebugLog) + return; + + // Get the current system time + timeval tv; + gettimeofday(&tv, nullptr); + + // Print the log entry + std::stringstream timeStr; + DATESTREAM + DLOG_ANDROID(str.c_str()) + + if (mLogFile.is_open()) + { + if (comment) + mLogFile << timeStr.str() << str << ": " << comment << std::endl; + else + mLogFile << timeStr.str() << str << std::endl; + } + + if (mLogToStandardOut) + { + if (comment) + std::cout << timeStr.str() << str << ": " << comment << std::endl; + else + std::cout << timeStr.str() << str << std::endl; + } +} #endif void Logger::log1(const char *const buf) -- cgit v1.2.3-70-g09d2