From b88c91dd3d03f1a452cdd48f0db4e010cb150753 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Tue, 12 May 2015 02:19:44 -0300 Subject: Common: Remove async logging It provided a large increase in complexity of the logging system while having a negligible performance impact: the usage patterns of the ring buffer meant that each log contended with the logging thread, causing it to effectively act as a synchronous extra buffering. Also removed some broken code related to filtering of subclasses which was broken since it was introduced. (Which means no one ever used that feature anyway, since, 8 months later, no one ever complained.) --- src/common/logging/filter.cpp | 41 ++++------------------------------------- 1 file changed, 4 insertions(+), 37 deletions(-) (limited to 'src/common/logging/filter.cpp') diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp index 50f2e13f..55cc8888 100644 --- a/src/common/logging/filter.cpp +++ b/src/common/logging/filter.cpp @@ -22,16 +22,6 @@ void Filter::SetClassLevel(Class log_class, Level level) { class_levels[static_cast(log_class)] = level; } -void Filter::SetSubclassesLevel(const ClassInfo& log_class, Level level) { - const size_t log_class_i = static_cast(log_class.log_class); - - const size_t begin = log_class_i + 1; - const size_t end = begin + log_class.num_children; - for (size_t i = begin; begin < end; ++i) { - class_levels[i] = level; - } -} - void Filter::ParseFilterString(const std::string& filter_str) { auto clause_begin = filter_str.cbegin(); while (clause_begin != filter_str.cend()) { @@ -53,7 +43,7 @@ void Filter::ParseFilterString(const std::string& filter_str) { template static Level GetLevelByName(const It begin, const It end) { for (u8 i = 0; i < static_cast(Level::Count); ++i) { - const char* level_name = Logger::GetLevelName(static_cast(i)); + const char* level_name = GetLevelName(static_cast(i)); if (Common::ComparePartialString(begin, end, level_name)) { return static_cast(i); } @@ -64,7 +54,7 @@ static Level GetLevelByName(const It begin, const It end) { template static Class GetClassByName(const It begin, const It end) { for (ClassType i = 0; i < static_cast(Class::Count); ++i) { - const char* level_name = Logger::GetLogClassName(static_cast(i)); + const char* level_name = GetLogClassName(static_cast(i)); if (Common::ComparePartialString(begin, end, level_name)) { return static_cast(i); } @@ -72,20 +62,6 @@ static Class GetClassByName(const It begin, const It end) { return Class::Count; } -template -static InputIt find_last(InputIt begin, const InputIt end, const T& value) { - auto match = end; - while (begin != end) { - auto new_match = std::find(begin, end, value); - if (new_match != end) { - match = new_match; - ++new_match; - } - begin = new_match; - } - return match; -} - bool Filter::ParseFilterRule(const std::string::const_iterator begin, const std::string::const_iterator end) { auto level_separator = std::find(begin, end, ':'); @@ -106,22 +82,13 @@ bool Filter::ParseFilterRule(const std::string::const_iterator begin, return true; } - auto class_name_end = find_last(begin, level_separator, '.'); - if (class_name_end != level_separator && - !Common::ComparePartialString(class_name_end + 1, level_separator, "*")) { - class_name_end = level_separator; - } - - const Class log_class = GetClassByName(begin, class_name_end); + const Class log_class = GetClassByName(begin, level_separator); if (log_class == Class::Count) { LOG_ERROR(Log, "Unknown log class in filter: %s", std::string(begin, end).c_str()); return false; } - if (class_name_end == level_separator) { - SetClassLevel(log_class, level); - } - SetSubclassesLevel(log_class, level); + SetClassLevel(log_class, level); return true; } -- cgit v1.2.3