From be9206f1131dec8b51847c199ba021e0345eeb3a Mon Sep 17 00:00:00 2001 From: Majid Date: Thu, 10 Jan 2013 21:07:55 +1100 Subject: [PATCH] v3.17 minor logic improvement --- VERSION_HISTORY.md | 2 ++ easylogging++.h | 27 ++++++++++++--------------- index.php | 2 +- samples/bin/many_logs.cpp.bin | Bin 34273 -> 30741 bytes samples/bin/time_tracker.cpp.bin | Bin 34429 -> 31037 bytes samples/bin/time_waster.cpp.bin | Bin 34453 -> 31051 bytes 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/VERSION_HISTORY.md b/VERSION_HISTORY.md index eee53421b..c17fb5e53 100644 --- a/VERSION_HISTORY.md +++ b/VERSION_HISTORY.md @@ -53,3 +53,5 @@ History was not kept before version 2.1. * 3.14: fix for windows compile failure, thanks to `codyzu` * 3.15: Added more control over disabling logs Changed from `_DISABLE_EASYLOGGINGPP` to `_DISABLE_LOGS` + * 3.16: Minor improvement + * 3.17: Minor logic improvement diff --git a/easylogging++.h b/easylogging++.h index 11f78b73f..5c7ee2135 100644 --- a/easylogging++.h +++ b/easylogging++.h @@ -1,7 +1,7 @@ /////////////////////////////////////////////////////////////////////////// // // // easylogging++.h - Core of EasyLogging++ // -// EasyLogging++ v3.16 // +// EasyLogging++ v3.17 // // Cross platform logging made easy for C++ applications // // Author Majid Khan // // http://www.icplusplus.com // @@ -314,15 +314,12 @@ static inline void updateDateFormat(void) { const char* timeFormatLocal = "%H:%M:%S"; if (::easyloggingpp::showDate) { strcpy(::easyloggingpp::dateFormat, dateFormatLocal); - } - else if ((::easyloggingpp::showDateTime) || (::easyloggingpp::showTime)) { - if (::easyloggingpp::showDateTime) { - strcpy(::easyloggingpp::dateFormat, dateFormatLocal); - strcat(::easyloggingpp::dateFormat, " "); - strcat(::easyloggingpp::dateFormat, timeFormatLocal); - } else if (::easyloggingpp::showTime) { - strcpy(::easyloggingpp::dateFormat, timeFormatLocal); - } + } else if (::easyloggingpp::showTime) { + strcpy(::easyloggingpp::dateFormat, timeFormatLocal); + } else if (::easyloggingpp::showDateTime) { + strcpy(::easyloggingpp::dateFormat, dateFormatLocal); + strcat(::easyloggingpp::dateFormat, " "); + strcat(::easyloggingpp::dateFormat, timeFormatLocal); } } @@ -383,14 +380,14 @@ static void writeLog(void) { ::easyloggingpp::cleanStream(); } -static void updateFormatValue(const std::string& replaceWhat, const std::string& replaceWith, std::string& str) { +static void updateFormatValue(const std::string& formatSpecifier, const std::string& value, std::string& currentFormat) { size_t foundAt = -1; - while ((foundAt = str.find(replaceWhat, foundAt + 1)) != std::string::npos){ - if (str.substr(foundAt, 1) == "\\") { - str = str.erase(foundAt - 2, 1); + while ((foundAt = currentFormat.find(formatSpecifier, foundAt + 1)) != std::string::npos){ + if (currentFormat.substr(foundAt, 1) == "\\") { + currentFormat = currentFormat.erase(foundAt - 2, 1); foundAt++; } else { - str = str.replace(foundAt, replaceWhat.size(), replaceWith); + currentFormat = currentFormat.replace(foundAt, formatSpecifier.size(), value); break; } } diff --git a/index.php b/index.php index df491f29d..de2012f28 100644 --- a/index.php +++ b/index.php @@ -1,7 +1,7 @@