diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-09-01 12:38:59 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-09-06 01:18:54 +0300 |
commit | 11d80e856811ceddec805ce68b0a17b13f5cf25e (patch) | |
tree | 31e4c919f5acd2e20b5f805bbe8524b1d0f9f754 /src/logger.cpp | |
parent | a15146e08d00f9986edfde7a15a70790b64cc1ce (diff) | |
download | plus-11d80e856811ceddec805ce68b0a17b13f5cf25e.tar.gz plus-11d80e856811ceddec805ce68b0a17b13f5cf25e.tar.bz2 plus-11d80e856811ceddec805ce68b0a17b13f5cf25e.tar.xz plus-11d80e856811ceddec805ce68b0a17b13f5cf25e.zip |
In debug packets logging also display offset.
Diffstat (limited to 'src/logger.cpp')
-rw-r--r-- | src/logger.cpp | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/src/logger.cpp b/src/logger.cpp index 024de4660..2b80602e8 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -120,7 +120,9 @@ void Logger::dlog(const std::string &str) std::cout << timeStr.str() << str << std::endl; } -void Logger::dlog2(const std::string &str, const char* const comment) +void Logger::dlog2(const std::string &str, + const int pos, + const char* const comment) { if (!mDebugLog) return; @@ -137,17 +139,41 @@ void Logger::dlog2(const std::string &str, const char* const comment) if (mLogFile.is_open()) { if (comment) - mLogFile << timeStr.str() << str << ": " << comment << std::endl; + { + mLogFile << timeStr.str(); + mLogFile.fill('0'); + mLogFile.width(4); + mLogFile << pos << " "; + mLogFile << str << ": " << comment << std::endl; + } else - mLogFile << timeStr.str() << str << std::endl; + { + mLogFile << timeStr.str(); + mLogFile.fill('0'); + mLogFile.width(4); + mLogFile << pos << " "; + mLogFile << str << std::endl; + } } if (mLogToStandardOut) { if (comment) - std::cout << timeStr.str() << str << ": " << comment << std::endl; + { + std::cout << timeStr.str(); + std::cout.fill('0'); + std::cout.width(4); + std::cout << pos << " "; + std::cout << str << ": " << comment << std::endl; + } else - std::cout << timeStr.str() << str << std::endl; + { + std::cout << timeStr.str(); + std::cout.fill('0'); + std::cout.width(4); + std::cout << pos << " "; + std::cout << str << std::endl; + } } } #endif |