From afe0cb47291ed6668947eb06396d6b1487de4898 Mon Sep 17 00:00:00 2001 From: sha512sum Date: Wed, 3 Jul 2024 15:24:58 +0000 Subject: [PATCH] Fix logging in HttpHandlerBase --- include/cserver/server/handlers/http_handler_base.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/cserver/server/handlers/http_handler_base.hpp b/include/cserver/server/handlers/http_handler_base.hpp index fd26993..b5cf225 100644 --- a/include/cserver/server/handlers/http_handler_base.hpp +++ b/include/cserver/server/handlers/http_handler_base.hpp @@ -24,10 +24,12 @@ struct HttpHandlerBase : ComponentBase { co_return co_await std::forward(self).HandleRequestThrow(std::move(request)); } catch(const std::exception& err) { auto typeName = boost::core::demangle(__cxxabiv1::__cxa_current_exception_type()->name()); - self.logging.template Warning<"In handler with default name {} uncaught exception of type {}: {}">(T::kName, typeName, err.what()); + if(self.logging.level <= LoggingLevel::kWarning) + self.logging.template Warning<"In handler with default name {} uncaught exception of type {}: {}">(T::kName, typeName, err.what()); } catch(...) { auto typeName = boost::core::demangle(__cxxabiv1::__cxa_current_exception_type()->name()); - self.logging.template Warning<"In handler with default name {} uncaught exception of type {}">(T::kName, typeName); + if(self.logging.level <= LoggingLevel::kWarning) + self.logging.template Warning<"In handler with default name {} uncaught exception of type {}">(T::kName, typeName); }; co_return http::HttpResponse{.statusCode = 500, .statusMessage = "Internal Server Error", .body = "Internal Server Error"}; };