diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:19:14 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:19:14 +0200 |
commit | 01eb8253196672c969a39587e90b49321a182428 (patch) | |
tree | 4a3b71d7913de519744466c9227fda6461c4f0b5 /lib/error_log.cpp | |
parent | 5.0 (diff) | |
download | FreeFileSync-01eb8253196672c969a39587e90b49321a182428.tar.gz FreeFileSync-01eb8253196672c969a39587e90b49321a182428.tar.bz2 FreeFileSync-01eb8253196672c969a39587e90b49321a182428.zip |
5.1
Diffstat (limited to 'lib/error_log.cpp')
-rw-r--r-- | lib/error_log.cpp | 101 |
1 files changed, 0 insertions, 101 deletions
diff --git a/lib/error_log.cpp b/lib/error_log.cpp deleted file mode 100644 index a71e72e1..00000000 --- a/lib/error_log.cpp +++ /dev/null @@ -1,101 +0,0 @@ -// ************************************************************************** -// * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * -// ************************************************************************** - -#include "error_log.h" -#include <zen/time.h> -#include <zen/i18n.h> -#include <algorithm> - -using namespace zen; - - -void ErrorLogging::logMsg(const wxString& message, zen::MessageType type) -{ - Entry newEntry; - newEntry.type = type; - newEntry.time = std::time(NULL); - newEntry.message = message; - - messages.push_back(newEntry); - - ++statistics[type]; -} - - -int ErrorLogging::typeCount(int typeFilter) const -{ - int count = 0; - - if (typeFilter & TYPE_INFO) - count += statistics[TYPE_INFO]; - if (typeFilter & TYPE_WARNING) - count += statistics[TYPE_WARNING]; - if (typeFilter & TYPE_ERROR) - count += statistics[TYPE_ERROR]; - if (typeFilter & TYPE_FATAL_ERROR) - count += statistics[TYPE_FATAL_ERROR]; - - return count; -} - - -std::vector<wxString> ErrorLogging::getFormattedMessages(int typeFilter) const -{ - std::vector<wxString> output; - - std::for_each(messages.begin(), messages.end(), - [&](const Entry& entry) - { - if (entry.type & typeFilter) - output.push_back(formatMessage(entry)); - }); - - return output; -} - - -wxString ErrorLogging::formatMessage(const Entry& msg) -{ - wxString typeName; - switch (msg.type) - { - case TYPE_INFO: - typeName = _("Info"); - break; - case TYPE_WARNING: - typeName = _("Warning"); - break; - case TYPE_ERROR: - typeName = _("Error"); - break; - case TYPE_FATAL_ERROR: - typeName = _("Fatal Error"); - break; - } - - const wxString prefix = L"[" + formatTime<wxString>(FORMAT_TIME, localTime(msg.time)) + L"] " + typeName + L": "; - - wxString formattedText = prefix; - for (auto iter = msg.message.begin(); iter != msg.message.end(); ) - if (*iter == L'\n') - { - formattedText += L'\n'; - - wxString blanks; - blanks.resize(prefix.size(), L' '); - formattedText += blanks; - - do //remove duplicate newlines - { - ++iter; - } - while (iter != msg.message.end() && *iter == L'\n'); - } - else - formattedText += *iter++; - - return formattedText; -} |