From ff4f55858d22a093a1d27ead686c5bf809a53835 Mon Sep 17 00:00:00 2001 From: Leonid Stryzhevskyi Date: Tue, 14 May 2024 04:34:11 +0300 Subject: [PATCH 01/10] implement new logging formatter --- src/CMakeLists.txt | 2 + src/oatpp/Environment.hpp | 4 +- src/oatpp/base/Countable.hpp | 6 +- src/oatpp/base/Log.cpp | 302 ++++++++++++++++++++++ src/oatpp/base/Log.hpp | 189 ++++++++++++++ src/oatpp/data/stream/BufferStream.cpp | 4 + src/oatpp/data/stream/BufferStream.hpp | 6 + test/CMakeLists.txt | 2 + test/oatpp/AllTestsMain.cpp | 338 +++++++++++++------------ test/oatpp/base/LogTest.cpp | 61 +++++ test/oatpp/base/LogTest.hpp | 45 ++++ 11 files changed, 791 insertions(+), 168 deletions(-) create mode 100644 src/oatpp/base/Log.cpp create mode 100644 src/oatpp/base/Log.hpp create mode 100644 test/oatpp/base/LogTest.cpp create mode 100644 test/oatpp/base/LogTest.hpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3171cf08..ce57de8f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -35,6 +35,8 @@ add_library(oatpp oatpp/base/Config.hpp oatpp/base/Countable.cpp oatpp/base/Countable.hpp + oatpp/base/Log.cpp + oatpp/base/Log.hpp oatpp/base/ObjectHandle.hpp oatpp/codegen/api_controller/auth_define.hpp oatpp/codegen/api_controller/auth_undef.hpp diff --git a/src/oatpp/Environment.hpp b/src/oatpp/Environment.hpp index 22fcc9d2..0e60c578 100644 --- a/src/oatpp/Environment.hpp +++ b/src/oatpp/Environment.hpp @@ -87,8 +87,8 @@ namespace oatpp { /** * Interface for system-wide Logger.
- * All calls to `OATPP_DISABLE_LOGV`, `OATPP_DISABLE_LOGD`, `OATPP_DISABLE_LOGI`, - * `OATPP_DISABLE_LOGW`, `OATPP_DISABLE_LOGE` will come here. + * All calls to `OATPP_LOGV`, `OATPP_LOGD`, `OATPP_LOGI`, + * `OATPP_LOGW`, `OATPP_LOGE` will come here. */ class Logger { public: diff --git a/src/oatpp/base/Countable.hpp b/src/oatpp/base/Countable.hpp index b04fd230..15b3b6ef 100644 --- a/src/oatpp/base/Countable.hpp +++ b/src/oatpp/base/Countable.hpp @@ -22,8 +22,8 @@ * ***************************************************************************/ -#ifndef oatpp_base_Countable -#define oatpp_base_Countable +#ifndef oatpp_base_Countable_hpp +#define oatpp_base_Countable_hpp #include "oatpp/Environment.hpp" @@ -59,4 +59,4 @@ public: }} -#endif /* oatpp_base_Countable */ +#endif /* oatpp_base_Countable_hpp */ diff --git a/src/oatpp/base/Log.cpp b/src/oatpp/base/Log.cpp new file mode 100644 index 00000000..9c078941 --- /dev/null +++ b/src/oatpp/base/Log.cpp @@ -0,0 +1,302 @@ +/*************************************************************************** + * + * Project _____ __ ____ _ _ + * ( _ ) /__\ (_ _)_| |_ _| |_ + * )(_)( /(__)\ )( (_ _)(_ _) + * (_____)(__)(__)(__) |_| |_| + * + * + * Copyright 2018-present, Leonid Stryzhevskyi + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ***************************************************************************/ + +#include "Log.hpp" + +#include "oatpp/utils/parser/Caret.hpp" +#include "oatpp/macro/basic.hpp" + +namespace oatpp::base{ + +LogMessage::LogMessage(const oatpp::String& msg) + : m_msg(msg != nullptr ? msg : "") + , m_stream(256) + , m_currParam(0) +{ + + utils::parser::Caret caret(m_msg); + while (caret.canContinue()) { + + if(caret.findText("{}", 2)) { + m_params.push_back({caret.getPosition(), caret.getPosition() + 2}); + caret.inc(2); + } + + } + +} + +std::string LogMessage::toStdString() const { + if(m_currParam == 0) { + m_stream.writeSimple(m_msg->data(), static_cast(m_msg->size())); + } else if(m_currParam > 0) { + auto& prev = m_params.at(m_currParam - 1); + m_stream.writeSimple(m_msg->data() + prev.endPos, static_cast(m_msg->size()) - prev.endPos); + } + return m_stream.toStdString(); +} + +bool LogMessage::writeNextChunk() { + + if(m_currParam >= m_params.size()) return false; + + if(m_currParam == 0) { + auto& curr = m_params.at(m_currParam); + m_stream.writeSimple(m_msg->data(), curr.startPos); + } else if(m_currParam > 0) { + auto& prev = m_params.at(m_currParam - 1); + auto& curr = m_params.at(m_currParam); + m_stream.writeSimple(m_msg->data() + prev.endPos, curr.startPos - prev.endPos); + } + + m_currParam ++; + return true; + +} + +LogMessage& LogMessage::operator << (const char* str) { + if(writeNextChunk()) { + if(str != nullptr) { + m_stream.writeSimple(str); + } else { + m_stream.writeSimple("{}"); + } + } + return *this; +} + +LogMessage& LogMessage::operator << (bool value) { + if(writeNextChunk()) { + m_stream.writeAsString(value); + } + return *this; +} + +LogMessage& LogMessage::operator << (v_int8 value) { + if(writeNextChunk()) { + m_stream.writeAsString(value); + } + return *this; +} + +LogMessage& LogMessage::operator << (v_uint8 value) { + if(writeNextChunk()) { + m_stream.writeAsString(value); + } + return *this; +} + +LogMessage& LogMessage::operator << (v_int16 value) { + if(writeNextChunk()) { + m_stream.writeAsString(value); + } + return *this; +} + +LogMessage& LogMessage::operator << (v_uint16 value) { + if(writeNextChunk()) { + m_stream.writeAsString(value); + } + return *this; +} + +LogMessage& LogMessage::operator << (v_int32 value) { + if(writeNextChunk()) { + m_stream.writeAsString(value); + } + return *this; +} + +LogMessage& LogMessage::operator << (v_uint32 value) { + if(writeNextChunk()) { + m_stream.writeAsString(value); + } + return *this; +} + +LogMessage& LogMessage::operator << (v_int64 value) { + if(writeNextChunk()) { + m_stream.writeAsString(value); + } + return *this; +} + +LogMessage& LogMessage::operator << (v_uint64 value) { + if(writeNextChunk()) { + m_stream.writeAsString(value); + } + return *this; +} + +LogMessage& LogMessage::operator << (v_float32 value) { + if(writeNextChunk()) { + m_stream.writeAsString(value); + } + return *this; +} + +LogMessage& LogMessage::operator << (v_float64 value) { + if(writeNextChunk()) { + m_stream.writeAsString(value); + } + return *this; +} + +LogMessage& LogMessage::operator << (const oatpp::String& str) { + if(writeNextChunk()) { + if(str != nullptr) { + m_stream.writeSimple(str); + } else { + m_stream.writeSimple("{}"); + } + } + return *this; +} + +LogMessage& LogMessage::operator << (const Boolean& value) { + if(writeNextChunk()) { + if(value.get() != nullptr) { + m_stream.writeAsString(*value); + } else { + m_stream.writeSimple("{}"); + } + } + return *this; +} + +LogMessage& LogMessage::operator << (const Int8& value) { + if(writeNextChunk()) { + if(value.get() != nullptr) { + m_stream.writeAsString(*value); + } else { + m_stream.writeSimple("{}"); + } + } + return *this; +} + +LogMessage& LogMessage::operator << (const UInt8& value) { + if(writeNextChunk()) { + if(value.get() != nullptr) { + m_stream.writeAsString(*value); + } else { + m_stream.writeSimple("{}"); + } + } + return *this; +} + +LogMessage& LogMessage::operator << (const Int16& value) { + if(writeNextChunk()) { + if(value.get() != nullptr) { + m_stream.writeAsString(*value); + } else { + m_stream.writeSimple("{}"); + } + } + return *this; +} + +LogMessage& LogMessage::operator << (const UInt16& value) { + if(writeNextChunk()) { + if(value.get() != nullptr) { + m_stream.writeAsString(*value); + } else { + m_stream.writeSimple("{}"); + } + } + return *this; +} + +LogMessage& LogMessage::operator << (const Int32& value) { + if(writeNextChunk()) { + if(value.get() != nullptr) { + m_stream.writeAsString(*value); + } else { + m_stream.writeSimple("{}"); + } + } + return *this; +} + +LogMessage& LogMessage::operator << (const UInt32& value) { + if(writeNextChunk()) { + if(value.get() != nullptr) { + m_stream.writeAsString(*value); + } else { + m_stream.writeSimple("{}"); + } + } + return *this; +} + +LogMessage& LogMessage::operator << (const Int64& value) { + if(writeNextChunk()) { + if(value.get() != nullptr) { + m_stream.writeAsString(*value); + } else { + m_stream.writeSimple("{}"); + } + } + return *this; +} + +LogMessage& LogMessage::operator << (const UInt64& value) { + if(writeNextChunk()) { + if(value.get() != nullptr) { + m_stream.writeAsString(*value); + } else { + m_stream.writeSimple("{}"); + } + } + return *this; +} + +LogMessage& LogMessage::operator << (const Float32& value) { + if(writeNextChunk()) { + if(value.get() != nullptr) { + m_stream.writeAsString(*value); + } else { + m_stream.writeSimple("{}"); + } + } + return *this; +} + +LogMessage& LogMessage::operator << (const Float64& value) { + if(writeNextChunk()) { + if(value.get() != nullptr) { + m_stream.writeAsString(*value); + } else { + m_stream.writeSimple("{}"); + } + } + return *this; +} + +void LogMessage::log(v_uint32 priority, const std::string& tag, const LogMessage& message) { + oatpp::Environment::log(priority, tag, message.toStdString()); +} + +} diff --git a/src/oatpp/base/Log.hpp b/src/oatpp/base/Log.hpp new file mode 100644 index 00000000..0d4b66ec --- /dev/null +++ b/src/oatpp/base/Log.hpp @@ -0,0 +1,189 @@ +/*************************************************************************** + * + * Project _____ __ ____ _ _ + * ( _ ) /__\ (_ _)_| |_ _| |_ + * )(_)( /(__)\ )( (_ _)(_ _) + * (_____)(__)(__)(__) |_| |_| + * + * + * Copyright 2018-present, Leonid Stryzhevskyi + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ***************************************************************************/ + +#ifndef oatpp_base_Log_hpp +#define oatpp_base_Log_hpp + +#include "oatpp/data/stream/BufferStream.hpp" + +namespace oatpp::base{ + +class LogMessage { +private: + + struct Parameter { + v_buff_size startPos; + v_buff_size endPos; + }; + +private: + bool writeNextChunk(); +private: + oatpp::String m_msg; + mutable data::stream::BufferOutputStream m_stream; + v_uint64 m_currParam; + std::vector m_params; +public: + + explicit LogMessage(const oatpp::String& msg); + + std::string toStdString() const; + + LogMessage& operator << (const char* str); + LogMessage& operator << (bool value); + LogMessage& operator << (v_int8 value); + LogMessage& operator << (v_uint8 value); + LogMessage& operator << (v_int16 value); + LogMessage& operator << (v_uint16 value); + LogMessage& operator << (v_int32 value); + LogMessage& operator << (v_uint32 value); + LogMessage& operator << (v_int64 value); + LogMessage& operator << (v_uint64 value); + LogMessage& operator << (v_float32 value); + LogMessage& operator << (v_float64 value); + + LogMessage& operator << (const oatpp::String& str); + LogMessage& operator << (const Boolean& value); + LogMessage& operator << (const Int8& value); + LogMessage& operator << (const UInt8& value); + LogMessage& operator << (const Int16& value); + LogMessage& operator << (const UInt16& value); + LogMessage& operator << (const Int32& value); + LogMessage& operator << (const UInt32& value); + LogMessage& operator << (const Int64& value); + LogMessage& operator << (const UInt64& value); + LogMessage& operator << (const Float32& value); + LogMessage& operator << (const Float64& value); + +public: + + static void log(v_uint32 priority, const std::string& tag, const LogMessage& message); + +}; + +} + +#define OATPP_LOG_PARAMS(IDX, CNT, P) \ +<< P + +#define OATPP_LOG_MACRO_0(PRIORITY, TAG, MSG) \ +oatpp::base::LogMessage::log(PRIORITY, TAG, LogMessage(MSG)); + +#define OATPP_LOG_MACRO_1(PRIORITY, TAG, MSG, ...) \ +oatpp::base::LogMessage::log(PRIORITY, TAG, LogMessage(MSG) OATPP_MACRO_FOREACH_OR_EMPTY(OATPP_LOG_PARAMS, __VA_ARGS__)); + +/** + * General LOG macro + * @param PRIORITY - Http method ("GET", "POST", "PUT", etc.) + * @param TAG - Path to endpoint (without host) + * @param MSG - Name of the generated method + */ +#define OATPP_LOG(PRIORITY, TAG, ...) \ +OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_LOG_MACRO_, (__VA_ARGS__)) (PRIORITY, TAG, __VA_ARGS__)) + +//////////////////////////// +//////////////////////////// +//////////////////////////// + +#ifndef OATPP_DISABLE_LOGV + +/** + * Log message with &l:Logger::PRIORITY_V;
+ * *To disable this log compile oatpp with `#define OATPP_DISABLE_LOGV`* + * @param TAG - message tag. + * @param ...(1) - message. + * @param ... - optional format parameter. + */ +#define OATPP_LOGv(TAG, ...) \ + OATPP_LOG(oatpp::Logger::PRIORITY_V, TAG, __VA_ARGS__); + +#else + #define OATPP_LOGv(TAG, ...) +#endif + +#ifndef OATPP_DISABLE_LOGD + +/** + * Log message with &l:Logger::PRIORITY_D;
+ * *To disable this log compile oatpp with `#define OATPP_DISABLE_LOGD`* + * @param TAG - message tag. + * @param ...(1) - message + * @param ... - optional format parameter. + */ +#define OATPP_LOGd(TAG, ...) \ + OATPP_LOG(oatpp::Logger::PRIORITY_D, TAG, __VA_ARGS__); + +#else + #define OATPP_LOGd(TAG, ...) +#endif + +#ifndef OATPP_DISABLE_LOGI + +/** + * Log message with &l:Logger::PRIORITY_I;
+ * *To disable this log compile oatpp with `#define OATPP_DISABLE_LOGI`* + * @param TAG - message tag. + * @param ...(1) - message. + * @param ... - optional format parameter. + */ +#define OATPP_LOGi(TAG, ...) \ + OATPP_LOG(oatpp::Logger::PRIORITY_I, TAG, __VA_ARGS__); + +#else + #define OATPP_LOGi(TAG, ...) +#endif + +#ifndef OATPP_DISABLE_LOGW + +/** + * Log message with &l:Logger::PRIORITY_W;
+ * *To disable this log compile oatpp with `#define OATPP_DISABLE_LOGW`* + * @param TAG - message tag. + * @param ...(1) - message. + * @param ... - optional format parameter. + */ +#define OATPP_LOGw(TAG, ...) \ + OATPP_LOG(oatpp::Logger::PRIORITY_W, TAG, __VA_ARGS__); + +#else + #define OATPP_LOGw(TAG, ...) +#endif + +#ifndef OATPP_DISABLE_LOGE + +/** + * Log message with &l:Logger::PRIORITY_E;
+ * *To disable this log compile oatpp with `#define OATPP_DISABLE_LOGE`* + * @param TAG - message tag. + * @param ...(1) - message. + * @param ... - optional format parameter. + */ +#define OATPP_LOGe(TAG, ...) \ + OATPP_LOG(oatpp::Logger::PRIORITY_E, TAG, __VA_ARGS__); + +#else + #define OATPP_LOGe(TAG, ...) +#endif + +#endif /* oatpp_base_Log_hpp */ diff --git a/src/oatpp/data/stream/BufferStream.cpp b/src/oatpp/data/stream/BufferStream.cpp index 6d2d4eac..a54c3dd3 100644 --- a/src/oatpp/data/stream/BufferStream.cpp +++ b/src/oatpp/data/stream/BufferStream.cpp @@ -129,6 +129,10 @@ oatpp::String BufferOutputStream::toString() { return oatpp::String(reinterpret_cast(m_data), m_position); } +std::string BufferOutputStream::toStdString() const { + return std::string(reinterpret_cast(m_data), static_cast(m_position)); +} + oatpp::String BufferOutputStream::getSubstring(v_buff_size pos, v_buff_size count) { if(pos + count <= m_position) { return oatpp::String(reinterpret_cast(m_data + pos), count); diff --git a/src/oatpp/data/stream/BufferStream.hpp b/src/oatpp/data/stream/BufferStream.hpp index bf240481..de3ed7f7 100644 --- a/src/oatpp/data/stream/BufferStream.hpp +++ b/src/oatpp/data/stream/BufferStream.hpp @@ -127,6 +127,12 @@ public: */ oatpp::String toString(); + /** + * Copy data to `std::string`. + * @return + */ + std::string toStdString() const; + /** * Create &id:oatpp::String; from part of buffer. * @param pos - starting position in buffer. diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 31375838..dc46dfbd 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -6,6 +6,8 @@ add_executable(oatppAllTests oatpp/async/LockTest.hpp oatpp/base/CommandLineArgumentsTest.cpp oatpp/base/CommandLineArgumentsTest.hpp + oatpp/base/LogTest.cpp + oatpp/base/LogTest.hpp oatpp/data/buffer/ProcessorTest.cpp oatpp/data/buffer/ProcessorTest.hpp oatpp/data/mapping/ObjectRemapperTest.cpp diff --git a/test/oatpp/AllTestsMain.cpp b/test/oatpp/AllTestsMain.cpp index e181ee05..c9c0d1f4 100644 --- a/test/oatpp/AllTestsMain.cpp +++ b/test/oatpp/AllTestsMain.cpp @@ -66,6 +66,8 @@ #include "oatpp/data/buffer/ProcessorTest.hpp" #include "oatpp/base/CommandLineArgumentsTest.hpp" +#include "oatpp/base/LogTest.hpp" + #include "oatpp/LoggerTest.hpp" #include "oatpp/async/Coroutine.hpp" @@ -80,172 +82,182 @@ namespace { +//#define LOG_PARAMS \ +//<< P + + + void runTests() { - oatpp::Environment::printCompilationConfig(); + //LOG("AAA", "MSG: {}", param1, param2); - OATPP_LOGD("Tests", "oatpp::String size=%lu", sizeof(oatpp::String)) - OATPP_LOGD("Tests", "std::string size=%lu", sizeof(std::string)) - OATPP_LOGD("Tests", "Vector size=%lu", sizeof(std::vector)) - OATPP_LOGD("Tests", "Map size=%lu", sizeof(std::unordered_map)) - OATPP_LOGD("Tests", "Tree size=%lu", sizeof(oatpp::data::mapping::Tree)) - - //return; - - OATPP_LOGD("Tests", "coroutine handle size=%lu", sizeof(oatpp::async::CoroutineHandle)) - OATPP_LOGD("Tests", "coroutine size=%lu", sizeof(oatpp::async::AbstractCoroutine)) - OATPP_LOGD("Tests", "action size=%lu", sizeof(oatpp::async::Action)) - OATPP_LOGD("Tests", "class count=%d", oatpp::data::type::ClassId::getClassCount()) - - auto names = oatpp::data::type::ClassId::getRegisteredClassNames(); - v_int32 i = 0; - for(auto& name : names) { - OATPP_LOGD("CLASS", "%d --> '%s'", i, name) - i ++; - } - - OATPP_RUN_TEST(oatpp::test::LoggerTest); - OATPP_RUN_TEST(oatpp::base::CommandLineArgumentsTest); - - OATPP_RUN_TEST(oatpp::data::share::MemoryLabelTest); - OATPP_RUN_TEST(oatpp::data::share::LazyStringMapTest); - OATPP_RUN_TEST(oatpp::data::share::StringTemplateTest); - - OATPP_RUN_TEST(oatpp::data::buffer::ProcessorTest); - OATPP_RUN_TEST(oatpp::data::stream::BufferStreamTest); - - OATPP_RUN_TEST(oatpp::data::mapping::TreeTest); - OATPP_RUN_TEST(oatpp::data::mapping::ObjectToTreeMapperTest); - OATPP_RUN_TEST(oatpp::data::mapping::TreeToObjectMapperTest); - OATPP_RUN_TEST(oatpp::data::mapping::ObjectRemapperTest); - - OATPP_RUN_TEST(oatpp::data::type::ObjectWrapperTest); - OATPP_RUN_TEST(oatpp::data::type::TypeTest); - - OATPP_RUN_TEST(oatpp::data::type::StringTest); - - OATPP_RUN_TEST(oatpp::data::type::PrimitiveTest); - OATPP_RUN_TEST(oatpp::data::type::ListTest); - OATPP_RUN_TEST(oatpp::data::type::VectorTest); - OATPP_RUN_TEST(oatpp::data::type::UnorderedSetTest); - OATPP_RUN_TEST(oatpp::data::type::PairListTest); - OATPP_RUN_TEST(oatpp::data::type::UnorderedMapTest); - OATPP_RUN_TEST(oatpp::data::type::AnyTest); - OATPP_RUN_TEST(oatpp::data::type::EnumTest); - - OATPP_RUN_TEST(oatpp::data::type::ObjectTest); - - OATPP_RUN_TEST(oatpp::data::type::InterpretationTest); - OATPP_RUN_TEST(oatpp::data::mapping::TypeResolverTest); - - OATPP_RUN_TEST(oatpp::data::resource::InMemoryDataTest); - - OATPP_RUN_TEST(oatpp::async::ConditionVariableTest); - OATPP_RUN_TEST(oatpp::async::LockTest); - - OATPP_RUN_TEST(oatpp::utils::parser::CaretTest); - - OATPP_RUN_TEST(oatpp::provider::PoolTest); - OATPP_RUN_TEST(oatpp::provider::PoolTemplateTest); - - OATPP_RUN_TEST(oatpp::json::EnumTest); - OATPP_RUN_TEST(oatpp::json::BooleanTest); - - OATPP_RUN_TEST(oatpp::json::UnorderedSetTest); - - OATPP_RUN_TEST(oatpp::json::DeserializerTest); - - OATPP_RUN_TEST(oatpp::json::DTOMapperPerfTest); - - OATPP_RUN_TEST(oatpp::json::DTOMapperTest); - OATPP_RUN_TEST(oatpp::test::encoding::Base64Test); - OATPP_RUN_TEST(oatpp::test::encoding::UnicodeTest); - OATPP_RUN_TEST(oatpp::test::encoding::UrlTest); - - OATPP_RUN_TEST(oatpp::test::network::UrlTest); - OATPP_RUN_TEST(oatpp::test::network::ConnectionPoolTest); - OATPP_RUN_TEST(oatpp::test::network::monitor::ConnectionMonitorTest); - OATPP_RUN_TEST(oatpp::test::network::virtual_::PipeTest); - OATPP_RUN_TEST(oatpp::test::network::virtual_::InterfaceTest); - - OATPP_RUN_TEST(oatpp::test::web::protocol::http::encoding::ChunkedTest); - - OATPP_RUN_TEST(oatpp::test::web::mime::multipart::StatefulParserTest); - OATPP_RUN_TEST(oatpp::web::mime::ContentMappersTest); - - OATPP_RUN_TEST(oatpp::test::web::server::HttpRouterTest); - OATPP_RUN_TEST(oatpp::test::web::server::api::ApiControllerTest); - OATPP_RUN_TEST(oatpp::test::web::server::handler::AuthorizationHandlerTest); - - { - - oatpp::test::web::server::ServerStopTest test_virtual(0); - test_virtual.run(); - - oatpp::test::web::server::ServerStopTest test_port(8000); - test_port.run(); - - } - - { - - oatpp::test::web::PipelineTest test_virtual(0, 3000); - test_virtual.run(); - - oatpp::test::web::PipelineTest test_port(8000, 3000); - test_port.run(); - - } - - { - - oatpp::test::web::PipelineAsyncTest test_virtual(0, 3000); - test_virtual.run(); - - oatpp::test::web::PipelineAsyncTest test_port(8000, 3000); - test_port.run(); - - } - - { - - oatpp::test::web::FullTest test_virtual(0, 1000); - test_virtual.run(); - - oatpp::test::web::FullTest test_port(8000, 5); - test_port.run(); - - } - - { - - oatpp::test::web::FullAsyncTest test_virtual(0, 1000); - test_virtual.run(); - - oatpp::test::web::FullAsyncTest test_port(8000, 5); - test_port.run(); - - } - - { - - oatpp::test::web::FullAsyncClientTest test_virtual(0, 1000); - test_virtual.run(20); - - oatpp::test::web::FullAsyncClientTest test_port(8000, 5); - test_port.run(1); - - } - - { - - oatpp::test::web::ClientRetryTest test_virtual(0); - test_virtual.run(); - - oatpp::test::web::ClientRetryTest test_port(8000); - test_port.run(); - - } +// oatpp::Environment::printCompilationConfig(); +// +// OATPP_LOGD("Tests", "oatpp::String size={}", sizeof(oatpp::String)) +// +// OATPP_LOGD("Tests", "oatpp::String size=%lu", sizeof(oatpp::String)) +// OATPP_LOGD("Tests", "std::string size=%lu", sizeof(std::string)) +// OATPP_LOGD("Tests", "Vector size=%lu", sizeof(std::vector)) +// OATPP_LOGD("Tests", "Map size=%lu", sizeof(std::unordered_map)) +// OATPP_LOGD("Tests", "Tree size=%lu", sizeof(oatpp::data::mapping::Tree)) +// +// //return; +// +// OATPP_LOGD("Tests", "coroutine handle size=%lu", sizeof(oatpp::async::CoroutineHandle)) +// OATPP_LOGD("Tests", "coroutine size=%lu", sizeof(oatpp::async::AbstractCoroutine)) +// OATPP_LOGD("Tests", "action size=%lu", sizeof(oatpp::async::Action)) +// OATPP_LOGD("Tests", "class count=%d", oatpp::data::type::ClassId::getClassCount()) +// +// auto names = oatpp::data::type::ClassId::getRegisteredClassNames(); +// v_int32 i = 0; +// for(auto& name : names) { +// OATPP_LOGD("CLASS", "%d --> '%s'", i, name) +// i ++; +// } +// +// OATPP_RUN_TEST(oatpp::test::LoggerTest); +// OATPP_RUN_TEST(oatpp::base::CommandLineArgumentsTest); + OATPP_RUN_TEST(oatpp::base::LogTest); +// +// OATPP_RUN_TEST(oatpp::data::share::MemoryLabelTest); +// OATPP_RUN_TEST(oatpp::data::share::LazyStringMapTest); +// OATPP_RUN_TEST(oatpp::data::share::StringTemplateTest); +// +// OATPP_RUN_TEST(oatpp::data::buffer::ProcessorTest); +// OATPP_RUN_TEST(oatpp::data::stream::BufferStreamTest); +// +// OATPP_RUN_TEST(oatpp::data::mapping::TreeTest); +// OATPP_RUN_TEST(oatpp::data::mapping::ObjectToTreeMapperTest); +// OATPP_RUN_TEST(oatpp::data::mapping::TreeToObjectMapperTest); +// OATPP_RUN_TEST(oatpp::data::mapping::ObjectRemapperTest); +// +// OATPP_RUN_TEST(oatpp::data::type::ObjectWrapperTest); +// OATPP_RUN_TEST(oatpp::data::type::TypeTest); +// +// OATPP_RUN_TEST(oatpp::data::type::StringTest); +// +// OATPP_RUN_TEST(oatpp::data::type::PrimitiveTest); +// OATPP_RUN_TEST(oatpp::data::type::ListTest); +// OATPP_RUN_TEST(oatpp::data::type::VectorTest); +// OATPP_RUN_TEST(oatpp::data::type::UnorderedSetTest); +// OATPP_RUN_TEST(oatpp::data::type::PairListTest); +// OATPP_RUN_TEST(oatpp::data::type::UnorderedMapTest); +// OATPP_RUN_TEST(oatpp::data::type::AnyTest); +// OATPP_RUN_TEST(oatpp::data::type::EnumTest); +// +// OATPP_RUN_TEST(oatpp::data::type::ObjectTest); +// +// OATPP_RUN_TEST(oatpp::data::type::InterpretationTest); +// OATPP_RUN_TEST(oatpp::data::mapping::TypeResolverTest); +// +// OATPP_RUN_TEST(oatpp::data::resource::InMemoryDataTest); +// +// OATPP_RUN_TEST(oatpp::async::ConditionVariableTest); +// OATPP_RUN_TEST(oatpp::async::LockTest); +// +// OATPP_RUN_TEST(oatpp::utils::parser::CaretTest); +// +// OATPP_RUN_TEST(oatpp::provider::PoolTest); +// OATPP_RUN_TEST(oatpp::provider::PoolTemplateTest); +// +// OATPP_RUN_TEST(oatpp::json::EnumTest); +// OATPP_RUN_TEST(oatpp::json::BooleanTest); +// +// OATPP_RUN_TEST(oatpp::json::UnorderedSetTest); +// +// OATPP_RUN_TEST(oatpp::json::DeserializerTest); +// +// OATPP_RUN_TEST(oatpp::json::DTOMapperPerfTest); +// +// OATPP_RUN_TEST(oatpp::json::DTOMapperTest); +// OATPP_RUN_TEST(oatpp::test::encoding::Base64Test); +// OATPP_RUN_TEST(oatpp::test::encoding::UnicodeTest); +// OATPP_RUN_TEST(oatpp::test::encoding::UrlTest); +// +// OATPP_RUN_TEST(oatpp::test::network::UrlTest); +// OATPP_RUN_TEST(oatpp::test::network::ConnectionPoolTest); +// OATPP_RUN_TEST(oatpp::test::network::monitor::ConnectionMonitorTest); +// OATPP_RUN_TEST(oatpp::test::network::virtual_::PipeTest); +// OATPP_RUN_TEST(oatpp::test::network::virtual_::InterfaceTest); +// +// OATPP_RUN_TEST(oatpp::test::web::protocol::http::encoding::ChunkedTest); +// +// OATPP_RUN_TEST(oatpp::test::web::mime::multipart::StatefulParserTest); +// OATPP_RUN_TEST(oatpp::web::mime::ContentMappersTest); +// +// OATPP_RUN_TEST(oatpp::test::web::server::HttpRouterTest); +// OATPP_RUN_TEST(oatpp::test::web::server::api::ApiControllerTest); +// OATPP_RUN_TEST(oatpp::test::web::server::handler::AuthorizationHandlerTest); +// +// { +// +// oatpp::test::web::server::ServerStopTest test_virtual(0); +// test_virtual.run(); +// +// oatpp::test::web::server::ServerStopTest test_port(8000); +// test_port.run(); +// +// } +// +// { +// +// oatpp::test::web::PipelineTest test_virtual(0, 3000); +// test_virtual.run(); +// +// oatpp::test::web::PipelineTest test_port(8000, 3000); +// test_port.run(); +// +// } +// +// { +// +// oatpp::test::web::PipelineAsyncTest test_virtual(0, 3000); +// test_virtual.run(); +// +// oatpp::test::web::PipelineAsyncTest test_port(8000, 3000); +// test_port.run(); +// +// } +// +// { +// +// oatpp::test::web::FullTest test_virtual(0, 1000); +// test_virtual.run(); +// +// oatpp::test::web::FullTest test_port(8000, 5); +// test_port.run(); +// +// } +// +// { +// +// oatpp::test::web::FullAsyncTest test_virtual(0, 1000); +// test_virtual.run(); +// +// oatpp::test::web::FullAsyncTest test_port(8000, 5); +// test_port.run(); +// +// } +// +// { +// +// oatpp::test::web::FullAsyncClientTest test_virtual(0, 1000); +// test_virtual.run(20); +// +// oatpp::test::web::FullAsyncClientTest test_port(8000, 5); +// test_port.run(1); +// +// } +// +// { +// +// oatpp::test::web::ClientRetryTest test_virtual(0); +// test_virtual.run(); +// +// oatpp::test::web::ClientRetryTest test_port(8000); +// test_port.run(); +// +// } } diff --git a/test/oatpp/base/LogTest.cpp b/test/oatpp/base/LogTest.cpp new file mode 100644 index 00000000..1b51afdf --- /dev/null +++ b/test/oatpp/base/LogTest.cpp @@ -0,0 +1,61 @@ +/*************************************************************************** + * + * Project _____ __ ____ _ _ + * ( _ ) /__\ (_ _)_| |_ _| |_ + * )(_)( /(__)\ )( (_ _)(_ _) + * (_____)(__)(__)(__) |_| |_| + * + * + * Copyright 2018-present, Leonid Stryzhevskyi + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ***************************************************************************/ + +#include "LogTest.hpp" + +#include "oatpp/base/Log.hpp" + +namespace oatpp::base { + +void LogTest::onRun() { + +// oatpp::String val = "hello"; +// oatpp::Float64 fv; +// +// LogMessage msg("{} double={}, float={}"); +// +// //msg << val << fv << ""; +// +// LogMessage::log(0, TAG, msg << 1 << 2 << 3); +// +// //std::cout << msg.toStdString() << std::endl; + + OATPP_LOGv(TAG, "1={}, 2={}, 3={}", 1, 2, 3) + OATPP_LOGv(TAG, "empty params") + + OATPP_LOGd(TAG, "1={}, 2={}, 3={}", 1, 2, 3) + OATPP_LOGd(TAG, "empty params") + + OATPP_LOGi(TAG, "1={}, 2={}, 3={}", 1, 2, 3) + OATPP_LOGi(TAG, "empty params") + + OATPP_LOGw(TAG, "1={}, 2={}, 3={}", 1, 2, 3) + OATPP_LOGw(TAG, "empty params") + + OATPP_LOGe(TAG, "1={}, 2={}, 3={}", 1, 2, 3) + OATPP_LOGe(TAG, "empty params") + +} + +} diff --git a/test/oatpp/base/LogTest.hpp b/test/oatpp/base/LogTest.hpp new file mode 100644 index 00000000..25ea4a3c --- /dev/null +++ b/test/oatpp/base/LogTest.hpp @@ -0,0 +1,45 @@ +/*************************************************************************** + * + * Project _____ __ ____ _ _ + * ( _ ) /__\ (_ _)_| |_ _| |_ + * )(_)( /(__)\ )( (_ _)(_ _) + * (_____)(__)(__)(__) |_| |_| + * + * + * Copyright 2018-present, Leonid Stryzhevskyi + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ***************************************************************************/ + +#ifndef oatpp_base_LogTest_hpp +#define oatpp_base_LogTest_hpp + +#include "oatpp-test/UnitTest.hpp" + +namespace oatpp::base { + +/** + * Test command line arguments parsing. + */ +class LogTest : public oatpp::test::UnitTest{ +public: + + LogTest():UnitTest("TEST[base::LogTest]"){} + void onRun() override; + +}; + +} + +#endif /* oatpp_base_LogTest_hpp */ From 19114d749f862273a6b7b4aebe0ec65929059793 Mon Sep 17 00:00:00 2001 From: Leonid Stryzhevskyi Date: Tue, 14 May 2024 06:34:49 +0300 Subject: [PATCH 02/10] logs: convert logs to new format --- src/oatpp-test/Checker.cpp | 7 +- src/oatpp-test/UnitTest.cpp | 8 +- src/oatpp-test/UnitTest.hpp | 2 +- src/oatpp-test/web/ClientServerTestRunner.hpp | 4 +- src/oatpp/Environment.cpp | 55 +-- src/oatpp/Environment.hpp | 143 +------- .../async/worker/IOEventWorker_epoll.cpp | 36 +- .../async/worker/IOEventWorker_kqueue.cpp | 25 +- src/oatpp/base/Log.cpp | 20 ++ src/oatpp/base/Log.hpp | 65 +++- src/oatpp/concurrency/Utils.cpp | 5 +- src/oatpp/data/stream/FileStream.cpp | 5 +- src/oatpp/data/stream/Stream.cpp | 15 +- .../network/ConnectionProviderSwitch.cpp | 3 +- src/oatpp/network/Server.cpp | 8 +- .../network/monitor/ConnectionMonitor.cpp | 10 +- src/oatpp/network/tcp/Connection.cpp | 8 +- .../network/tcp/client/ConnectionProvider.cpp | 5 +- .../network/tcp/server/ConnectionProvider.cpp | 25 +- src/oatpp/network/virtual_/Interface.cpp | 5 +- src/oatpp/web/client/ApiClient.hpp | 5 +- src/oatpp/web/mime/multipart/PartReader.cpp | 7 +- .../http/incoming/RequestHeadersReader.cpp | 3 +- .../protocol/http/outgoing/MultipartBody.cpp | 7 +- src/oatpp/web/server/HttpProcessor.cpp | 6 +- src/oatpp/web/server/api/ApiController.hpp | 5 +- src/oatpp/web/url/mapping/Router.hpp | 2 +- test/oatpp/AllTestsMain.cpp | 337 +++++++++--------- test/oatpp/LoggerTest.cpp | 58 +-- test/oatpp/async/ConditionVariableTest.cpp | 6 +- test/oatpp/async/LockTest.cpp | 6 +- test/oatpp/data/buffer/ProcessorTest.cpp | 3 +- .../oatpp/data/mapping/ObjectRemapperTest.cpp | 8 +- .../data/mapping/ObjectToTreeMapperTest.cpp | 12 +- test/oatpp/data/mapping/TreeTest.cpp | 24 +- .../data/mapping/TreeToObjectMapperTest.cpp | 8 +- test/oatpp/data/share/MemoryLabelTest.cpp | 38 +- test/oatpp/data/share/StringTemplateTest.cpp | 40 +-- test/oatpp/data/stream/BufferStreamTest.cpp | 2 +- test/oatpp/data/type/AnyTest.cpp | 28 +- test/oatpp/data/type/EnumTest.cpp | 44 +-- test/oatpp/data/type/InterpretationTest.cpp | 12 +- test/oatpp/data/type/ListTest.cpp | 28 +- test/oatpp/data/type/ObjectTest.cpp | 96 ++--- test/oatpp/data/type/ObjectWrapperTest.cpp | 42 +-- test/oatpp/data/type/PairListTest.cpp | 28 +- test/oatpp/data/type/PrimitiveTest.cpp | 50 +-- test/oatpp/data/type/StringTest.cpp | 60 ++-- test/oatpp/data/type/TypeTest.cpp | 32 +- test/oatpp/data/type/UnorderedMapTest.cpp | 28 +- test/oatpp/data/type/UnorderedSetTest.cpp | 25 +- test/oatpp/data/type/VectorTest.cpp | 29 +- test/oatpp/encoding/Base64Test.cpp | 5 +- test/oatpp/encoding/UnicodeTest.cpp | 3 +- test/oatpp/encoding/UrlTest.cpp | 7 +- test/oatpp/json/BooleanTest.cpp | 17 +- test/oatpp/json/DTOMapperPerfTest.cpp | 3 +- test/oatpp/json/DTOMapperTest.cpp | 19 +- test/oatpp/json/DeserializerTest.cpp | 21 +- test/oatpp/json/EnumTest.cpp | 64 ++-- test/oatpp/json/UnorderedSetTest.cpp | 5 +- test/oatpp/network/ConnectionPoolTest.cpp | 3 +- test/oatpp/network/UrlTest.cpp | 27 +- .../network/monitor/ConnectionMonitorTest.cpp | 28 +- test/oatpp/network/virtual_/InterfaceTest.cpp | 2 +- test/oatpp/network/virtual_/PipeTest.cpp | 6 +- test/oatpp/provider/PoolTemplateTest.cpp | 10 +- test/oatpp/provider/PoolTest.cpp | 20 +- test/oatpp/web/ClientRetryTest.cpp | 14 +- test/oatpp/web/FullAsyncClientTest.cpp | 20 +- test/oatpp/web/FullAsyncTest.cpp | 4 +- test/oatpp/web/FullTest.cpp | 2 +- test/oatpp/web/PipelineTest.cpp | 4 +- test/oatpp/web/app/Controller.hpp | 22 +- test/oatpp/web/app/ControllerAsync.hpp | 20 +- test/oatpp/web/mime/ContentMappersTest.cpp | 22 +- .../web/mime/multipart/StatefulParserTest.cpp | 2 +- .../protocol/http/encoding/ChunkedTest.cpp | 4 +- test/oatpp/web/server/HttpRouterTest.cpp | 32 +- test/oatpp/web/server/ServerStopTest.cpp | 28 +- .../web/server/api/ApiControllerTest.cpp | 8 +- .../handler/AuthorizationHandlerTest.cpp | 4 +- 82 files changed, 938 insertions(+), 1021 deletions(-) diff --git a/src/oatpp-test/Checker.cpp b/src/oatpp-test/Checker.cpp index c47b5853..cf67d554 100644 --- a/src/oatpp-test/Checker.cpp +++ b/src/oatpp-test/Checker.cpp @@ -23,6 +23,7 @@ ***************************************************************************/ #include "Checker.hpp" +#include "oatpp/base/Log.hpp" namespace oatpp { namespace test { @@ -33,7 +34,7 @@ PerformanceChecker::PerformanceChecker(const char* tag) PerformanceChecker::~PerformanceChecker(){ v_int64 elapsedTicks = oatpp::Environment::getMicroTickCount() - m_ticks; - OATPP_LOGD(m_tag, "%ld(micro)", elapsedTicks) + OATPP_LOGd(m_tag, "{}(micro)", elapsedTicks) } v_int64 PerformanceChecker::getElapsedTicks(){ @@ -54,9 +55,9 @@ ThreadLocalObjectsChecker::~ThreadLocalObjectsChecker(){ v_counter objectsCreatedPerTest = oatpp::Environment::getThreadLocalObjectsCreated() - m_objectsCreated; if(leakingObjects == 0){ - OATPP_LOGE(m_tag, "OK:\n created(obj): %ld", objectsCreatedPerTest) + OATPP_LOGe(m_tag, "OK:\n created(obj): {}", objectsCreatedPerTest) }else{ - OATPP_LOGE(m_tag, "FAILED, leakingObjects = %ld", leakingObjects) + OATPP_LOGe(m_tag, "FAILED, leakingObjects = {}", leakingObjects) OATPP_ASSERT(false) } diff --git a/src/oatpp-test/UnitTest.cpp b/src/oatpp-test/UnitTest.cpp index 6e854256..6f498365 100644 --- a/src/oatpp-test/UnitTest.cpp +++ b/src/oatpp-test/UnitTest.cpp @@ -30,7 +30,7 @@ namespace oatpp { namespace test { void UnitTest::run(v_int32 times) { - OATPP_LOGI(TAG, "\033[1mSTART\033[0m...") + OATPP_LOGi(TAG, "\033[1mSTART\033[0m...") v_counter objectsCount = oatpp::Environment::getObjectsCount(); v_counter objectsCreated = oatpp::Environment::getObjectsCreated(); @@ -51,11 +51,11 @@ void UnitTest::run(v_int32 times) { v_counter objectsCreatedPerTest = oatpp::Environment::getObjectsCreated() - objectsCreated; if(leakingObjects == 0){ - OATPP_LOGI(TAG, "\033[1mFINISHED\033[0m - \033[1;32msuccess!\033[0m") - OATPP_LOGI(TAG, "\033[33m%ld(micro), %ld(objs)\033[0m\n", millis, objectsCreatedPerTest) + OATPP_LOGi(TAG, "\033[1mFINISHED\033[0m - \033[1;32msuccess!\033[0m") + OATPP_LOGi(TAG, "\033[33m{}(micro), {}(objs)\033[0m\n", millis, objectsCreatedPerTest) }else{ - OATPP_LOGE(TAG, "\033[1mFINISHED\033[0m - \033[1;31mfailed\033[0m, leakingObjects = %ld", leakingObjects) + OATPP_LOGe(TAG, "\033[1mFINISHED\033[0m - \033[1;31mfailed\033[0m, leakingObjects = {}", leakingObjects) exit(EXIT_FAILURE); diff --git a/src/oatpp-test/UnitTest.hpp b/src/oatpp-test/UnitTest.hpp index 40833fd7..0ba454d9 100644 --- a/src/oatpp-test/UnitTest.hpp +++ b/src/oatpp-test/UnitTest.hpp @@ -26,7 +26,7 @@ #define oatpp_test_UnitTest_hpp #include "oatpp/Environment.hpp" -#include "oatpp/macro/basic.hpp" +#include "oatpp/base/Log.hpp" #include diff --git a/src/oatpp-test/web/ClientServerTestRunner.hpp b/src/oatpp-test/web/ClientServerTestRunner.hpp index 3ec31959..0e03e8c0 100644 --- a/src/oatpp-test/web/ClientServerTestRunner.hpp +++ b/src/oatpp-test/web/ClientServerTestRunner.hpp @@ -100,7 +100,7 @@ public: bool runConditionForLambda = true; m_server = std::make_shared(m_connectionProvider, m_connectionHandler); - OATPP_LOGD("\033[1;34mClientServerTestRunner\033[0m", "\033[1;34mRunning server on port %s. Timeout %ld(micro)\033[0m", + OATPP_LOGd("\033[1;34mClientServerTestRunner\033[0m", "\033[1;34mRunning server on port {}. Timeout {}(micro)\033[0m", m_connectionProvider->getProperty("port").toString()->c_str(), timeout.count()) @@ -137,7 +137,7 @@ public: clientThread.join(); auto elapsed = std::chrono::duration_cast(std::chrono::system_clock::now() - startTime); - OATPP_LOGD("\033[1;34mClientServerTestRunner\033[0m", "\033[1;34mFinished with time %ld(micro). Stopping server...\033[0m", elapsed.count()) + OATPP_LOGd("\033[1;34mClientServerTestRunner\033[0m", "\033[1;34mFinished with time {}(micro). Stopping server...\033[0m", elapsed.count()) running = false; timeoutCondition.notify_one(); diff --git a/src/oatpp/Environment.cpp b/src/oatpp/Environment.cpp index b849f630..8a242321 100644 --- a/src/oatpp/Environment.cpp +++ b/src/oatpp/Environment.cpp @@ -25,6 +25,8 @@ #include "Environment.hpp" +#include "oatpp/base/Log.hpp" + #include #include #include @@ -246,6 +248,8 @@ void Environment::checkTypes(){ v_uint32 vUInt32 = ~v_uint32(1); v_uint64 vUInt64 = ~v_uint64(1); + OATPP_LOGe("AAA", "") + OATPP_ASSERT(vInt32 < 0) OATPP_ASSERT(vInt64 < 0) OATPP_ASSERT(vUInt32 > 0) @@ -309,18 +313,18 @@ std::shared_ptr Environment::getLogger() { void Environment::printCompilationConfig() { - OATPP_LOGD("oatpp-version", OATPP_VERSION) + OATPP_LOGd("oatpp-version", OATPP_VERSION) #ifdef OATPP_DISABLE_ENV_OBJECT_COUNTERS - OATPP_LOGD("oatpp/Config", "OATPP_DISABLE_ENV_OBJECT_COUNTERS") + OATPP_LOGd("oatpp/Config", "OATPP_DISABLE_ENV_OBJECT_COUNTERS") #endif #ifdef OATPP_COMPAT_BUILD_NO_THREAD_LOCAL - OATPP_LOGD("oatpp/Config", "OATPP_COMPAT_BUILD_NO_THREAD_LOCAL") + OATPP_LOGd("oatpp/Config", "OATPP_COMPAT_BUILD_NO_THREAD_LOCAL") #endif #ifdef OATPP_THREAD_HARDWARE_CONCURRENCY - OATPP_LOGD("oatpp/Config", "OATPP_THREAD_HARDWARE_CONCURRENCY=%d", OATPP_THREAD_HARDWARE_CONCURRENCY) + OATPP_LOGd("oatpp/Config", "OATPP_THREAD_HARDWARE_CONCURRENCY={}", OATPP_THREAD_HARDWARE_CONCURRENCY) #endif } @@ -331,49 +335,6 @@ void Environment::log(v_uint32 priority, const std::string& tag, const std::stri } } - -void Environment::logFormatted(v_uint32 priority, const LogCategory& category, const char* message, ...) { - if (category.categoryEnabled && (category.enabledPriorities & (1U << priority))) { - va_list args; - va_start(args, message); - vlogFormatted(priority, category.tag, message, args); - va_end(args); - } -} - -void Environment::logFormatted(v_uint32 priority, const std::string& tag, const char* message, ...) { - va_list args; - va_start(args, message); - vlogFormatted(priority, tag, message, args); - va_end(args); -} - -void Environment::vlogFormatted(v_uint32 priority, const std::string& tag, const char* message, va_list args) { - // do we have a logger and the priority is enabled? - if (m_logger == nullptr || !m_logger->isLogPriorityEnabled(priority)) { - return; - } - // if we dont need to format anything, just print the message - if(message == nullptr) { - log(priority, tag, std::string()); - return; - } - // check how big our buffer has to be - va_list argscpy; - va_copy(argscpy, args); - v_buff_size allocsize = vsnprintf(nullptr, 0, message, argscpy) + 1; - // alloc the buffer (or the max size) - if (allocsize > m_logger->getMaxFormattingBufferSize()) { - allocsize = m_logger->getMaxFormattingBufferSize(); - } - auto buffer = std::unique_ptr(new char[allocsize]); - memset(buffer.get(), 0, static_cast(allocsize)); - // actually format - vsnprintf(buffer.get(), static_cast(allocsize), message, args); - // call (user) providen log function - log(priority, tag, buffer.get()); -} - void Environment::registerComponent(const std::string& typeName, const std::string& componentName, void* component) { std::lock_guard lock(getComponentsMutex()); auto& bucket = getComponents()[typeName]; diff --git a/src/oatpp/Environment.hpp b/src/oatpp/Environment.hpp index 0e60c578..3ab084a5 100644 --- a/src/oatpp/Environment.hpp +++ b/src/oatpp/Environment.hpp @@ -87,8 +87,8 @@ namespace oatpp { /** * Interface for system-wide Logger.
- * All calls to `OATPP_LOGV`, `OATPP_LOGD`, `OATPP_LOGI`, - * `OATPP_LOGW`, `OATPP_LOGE` will come here. + * All calls to `OATPP_LOGv`, `OATPP_LOGd`, `OATPP_LOGi`, + * `OATPP_LOGw`, `OATPP_LOGe` will come here. */ class Logger { public: @@ -358,7 +358,6 @@ public: private: static void registerComponent(const std::string& typeName, const std::string& componentName, void* component); static void unregisterComponent(const std::string& typeName, const std::string& componentName); - static void vlogFormatted(v_uint32 priority, const std::string& tag, const char* message, va_list args) GPP_ATTRIBUTE(format (printf, 3, 0)); public: /** @@ -442,26 +441,6 @@ public: */ static void log(v_uint32 priority, const std::string& tag, const std::string& message); - /** - * Format message and call `Logger::log()`
- * Message is formatted using `vsnprintf` method. - * @param priority - log-priority channel of the message. - * @param tag - tag of the log message. - * @param message - message. - * @param ... - format arguments. - */ - static void logFormatted(v_uint32 priority, const std::string& tag, const char* message, ...) GPP_ATTRIBUTE(format (printf, 3, 4)); - - /** - * Format message and call `Logger::log()`
- * Message is formatted using `vsnprintf` method. - * @param priority - log-priority channel of the message. - * @param category - category of the log message. - * @param message - message. - * @param ... - format arguments. - */ - static void logFormatted(v_uint32 priority, const LogCategory& category, const char* message, ...) GPP_ATTRIBUTE(format (printf, 3, 4)); - /** * Get component object by typeName. * @param typeName - type name of the component. @@ -484,124 +463,6 @@ public: static v_int64 getMicroTickCount(); }; - -/** - * Default oatpp assert method. - * @param FMT - the format string used for the expression - * @param EXP - expression that must be `true`. - */ -#define OATPP_ASSERT_FMT(FMT, EXP) \ -if(!(EXP)) { \ - OATPP_LOGE("\033[1mASSERT\033[0m[\033[1;31mFAILED\033[0m]", FMT, #EXP) \ - exit(EXIT_FAILURE); \ -} - -/** - * Default oatpp assert method. - * @param EXP - expression that must be `true`. - */ -#define OATPP_ASSERT(EXP) \ -if(!(EXP)) { \ - OATPP_LOGE("\033[1mASSERT\033[0m[\033[1;31mFAILED\033[0m]", #EXP) \ - exit(EXIT_FAILURE); \ -} - -/** - * Convenience macro to declare a logging category directly in a class header. - * @param NAME - variable-name of the category which is later used to reference the category. - */ -#define OATPP_DECLARE_LOG_CATEGORY(NAME) \ - static oatpp::LogCategory NAME; - -/** - * Convenience macro to implement a logging category directly in a class header. - * @param NAME - variable-name of the category which is later used to reference the category. - * @param TAG - tag printed with each message printed usig this category. - * @param ENABLED - enable or disable a category (bool). - */ -#define OATPP_LOG_CATEGORY(NAME, TAG, ENABLED) \ - oatpp::LogCategory NAME = oatpp::LogCategory(TAG, ENABLED); - - -#ifndef OATPP_DISABLE_LOGV - - /** - * Log message with &l:Logger::PRIORITY_V;
- * *To disable this log compile oatpp with `#define OATPP_DISABLE_LOGV`* - * @param TAG - message tag. - * @param ...(1) - message. - * @param ... - optional format parameter. - */ - #define OATPP_LOGV(TAG, ...) \ - oatpp::Environment::logFormatted(oatpp::Logger::PRIORITY_V, TAG, __VA_ARGS__); - -#else - #define OATPP_LOGV(TAG, ...) -#endif - -#ifndef OATPP_DISABLE_LOGD - - /** - * Log message with &l:Logger::PRIORITY_D;
- * *To disable this log compile oatpp with `#define OATPP_DISABLE_LOGD`* - * @param TAG - message tag. - * @param ...(1) - message. - * @param ... - optional format parameter. - */ - #define OATPP_LOGD(TAG, ...) \ - oatpp::Environment::logFormatted(oatpp::Logger::PRIORITY_D, TAG, __VA_ARGS__); - -#else - #define OATPP_LOGD(TAG, ...) -#endif - -#ifndef OATPP_DISABLE_LOGI - - /** - * Log message with &l:Logger::PRIORITY_I;
- * *To disable this log compile oatpp with `#define OATPP_DISABLE_LOGI`* - * @param TAG - message tag. - * @param ...(1) - message. - * @param ... - optional format parameter. - */ - #define OATPP_LOGI(TAG, ...) \ - oatpp::Environment::logFormatted(oatpp::Logger::PRIORITY_I, TAG, __VA_ARGS__); - -#else - #define OATPP_LOGI(TAG, ...) -#endif - -#ifndef OATPP_DISABLE_LOGW - - /** - * Log message with &l:Logger::PRIORITY_W;
- * *To disable this log compile oatpp with `#define OATPP_DISABLE_LOGW`* - * @param TAG - message tag. - * @param ...(1) - message. - * @param ... - optional format parameter. - */ - #define OATPP_LOGW(TAG, ...) \ - oatpp::Environment::logFormatted(oatpp::Logger::PRIORITY_W, TAG, __VA_ARGS__); - -#else - #define OATPP_LOGW(TAG, ...) -#endif - -#ifndef OATPP_DISABLE_LOGE - - /** - * Log message with &l:Logger::PRIORITY_E;
- * *To disable this log compile oatpp with `#define OATPP_DISABLE_LOGE`* - * @param TAG - message tag. - * @param ...(1) - message. - * @param ... - optional format parameter. - */ - #define OATPP_LOGE(TAG, ...) \ - oatpp::Environment::logFormatted(oatpp::Logger::PRIORITY_E, TAG, __VA_ARGS__); - -#else - #define OATPP_LOGE(TAG, ...) -#endif } diff --git a/src/oatpp/async/worker/IOEventWorker_epoll.cpp b/src/oatpp/async/worker/IOEventWorker_epoll.cpp index ee9d5086..4078c1f7 100644 --- a/src/oatpp/async/worker/IOEventWorker_epoll.cpp +++ b/src/oatpp/async/worker/IOEventWorker_epoll.cpp @@ -46,22 +46,22 @@ void IOEventWorker::initEventQueue() { #endif if(m_eventQueueHandle == -1) { - OATPP_LOGE("[oatpp::async::worker::IOEventWorker::initEventQueue()]", "Error. Call to ::epoll_create1() failed. errno=%d", errno) + OATPP_LOGe("[oatpp::async::worker::IOEventWorker::initEventQueue()]", "Error. Call to ::epoll_create1() failed. errno={}", errno) throw std::runtime_error("[oatpp::async::worker::IOEventWorker::initEventQueue()]: Error. Call to ::epoll_create1() failed."); } m_outEvents = std::unique_ptr(new (std::nothrow) v_char8[MAX_EVENTS * sizeof(epoll_event)]); if(!m_outEvents) { - OATPP_LOGE("[oatpp::async::worker::IOEventWorker::initEventQueue()]", - "Error. Unable to allocate %lu bytes for events.", MAX_EVENTS * sizeof(epoll_event)) + OATPP_LOGe("[oatpp::async::worker::IOEventWorker::initEventQueue()]", + "Error. Unable to allocate {} bytes for events.", MAX_EVENTS * sizeof(epoll_event)) throw std::runtime_error("[oatpp::async::worker::IOEventWorker::initEventQueue()]: Error. Unable to allocate memory for events."); } m_wakeupTrigger = ::eventfd(0, EFD_NONBLOCK); if(m_wakeupTrigger == -1) { - OATPP_LOGE("[oatpp::async::worker::IOEventWorker::initEventQueue()]", "Error. Call to ::eventfd() failed. errno=%d", errno) + OATPP_LOGe("[oatpp::async::worker::IOEventWorker::initEventQueue()]", "Error. Call to ::eventfd() failed. errno={}", errno) throw std::runtime_error("[oatpp::async::worker::IOEventWorker::initEventQueue()]: Error. Call to ::eventfd() failed."); } @@ -78,7 +78,7 @@ void IOEventWorker::initEventQueue() { auto res = ::epoll_ctl(m_eventQueueHandle, EPOLL_CTL_ADD, m_wakeupTrigger, &event); if(res == -1) { - OATPP_LOGE("[oatpp::async::worker::IOEventWorker::initEventQueue()]", "Error. Call to ::epoll_ctl failed. errno=%d", errno) + OATPP_LOGe("[oatpp::async::worker::IOEventWorker::initEventQueue()]", "Error. Call to ::epoll_ctl failed. errno={}", errno) throw std::runtime_error("[oatpp::async::worker::IOEventWorker::initEventQueue()]: Error. Call to ::epoll_ctl() failed."); } @@ -104,7 +104,7 @@ void IOEventWorker::setCoroutineEvent(CoroutineHandle* coroutine, int operation, case Action::TYPE_IO_REPEAT: break; default: - OATPP_LOGE("[oatpp::async::worker::IOEventWorker::pushCoroutineToQueue()]", "Error. Unknown Action. action.getType()==%d", action.getType()) + OATPP_LOGe("[oatpp::async::worker::IOEventWorker::pushCoroutineToQueue()]", "Error. Unknown Action. action.getType()=={}", action.getType()) throw std::runtime_error("[oatpp::async::worker::IOEventWorker::pushCoroutineToQueue()]: Error. Unknown Action."); } @@ -131,7 +131,7 @@ void IOEventWorker::setCoroutineEvent(CoroutineHandle* coroutine, int operation, auto res = epoll_ctl(m_eventQueueHandle, operation, action.getIOHandle(), &event); if(res == -1) { - OATPP_LOGE("[oatpp::async::worker::IOEventWorker::setEpollEvent()]", "Error. Call to epoll_ctl failed. operation=%d, errno=%d", operation, errno) + OATPP_LOGe("[oatpp::async::worker::IOEventWorker::setEpollEvent()]", "Error. Call to epoll_ctl failed. operation={}, errno={}", operation, errno) throw std::runtime_error("[oatpp::async::worker::IOEventWorker::setEpollEvent()]: Error. Call to epoll_ctl failed."); } @@ -159,12 +159,12 @@ void IOEventWorker::waitEvents() { auto eventsCount = epoll_wait(m_eventQueueHandle, outEvents, MAX_EVENTS, -1); if((eventsCount < 0) && (errno != EINTR)) { - OATPP_LOGE("[oatpp::async::worker::IOEventWorker::waitEvents()]", "Error:\n" - "errno=%d\n" - "in-events=%d\n" - "foreman=%lx\n" - "this=%lx\n" - "specialization=%d", + OATPP_LOGe("[oatpp::async::worker::IOEventWorker::waitEvents()]", "Error:\n" + "errno={}\n" + "in-events={}\n" + "foreman={}\n" + "this={}\n" + "specialization={}", errno, m_inEventsCount, reinterpret_cast(m_foreman), reinterpret_cast(this), m_specialization) throw std::runtime_error("[oatpp::async::worker::IOEventWorker::waitEvents()]: Error. Event loop failed."); } @@ -216,9 +216,9 @@ void IOEventWorker::waitEvents() { res = epoll_ctl(m_eventQueueHandle, EPOLL_CTL_DEL, action.getIOHandle(), nullptr); if(res == -1) { - OATPP_LOGE( + OATPP_LOGe( "[oatpp::async::worker::IOEventWorker::waitEvents()]", - "Error. Call to epoll_ctl failed. operation=%d, errno=%d. action_code=%d, worker_specialization=%d", + "Error. Call to epoll_ctl failed. operation={}, errno={}. action_code={}, worker_specialization={}", EPOLL_CTL_DEL, errno, action.getIOEventCode(), m_specialization ) throw std::runtime_error("[oatpp::async::worker::IOEventWorker::waitEvents()]: Error. Call to epoll_ctl failed."); @@ -233,9 +233,9 @@ void IOEventWorker::waitEvents() { res = epoll_ctl(m_eventQueueHandle, EPOLL_CTL_DEL, action.getIOHandle(), nullptr); if(res == -1) { - OATPP_LOGE( + OATPP_LOGe( "[oatpp::async::worker::IOEventWorker::waitEvents()]", - "Error. Call to epoll_ctl failed. operation=%d, errno=%d. action_code=%d, worker_specialization=%d", + "Error. Call to epoll_ctl failed. operation={}, errno={}. action_code={}, worker_specialization={}", EPOLL_CTL_DEL, errno, action.getIOEventCode(), m_specialization ) throw std::runtime_error("[oatpp::async::worker::IOEventWorker::waitEvents()]: Error. Call to epoll_ctl failed."); @@ -253,7 +253,7 @@ void IOEventWorker::waitEvents() { res = epoll_ctl(m_eventQueueHandle, EPOLL_CTL_DEL, prevAction.getIOHandle(), nullptr); if(res == -1) { - OATPP_LOGE("[oatpp::async::worker::IOEventWorker::waitEvents()]", "Error. Call to epoll_ctl failed. operation=%d, errno=%d", EPOLL_CTL_DEL, errno) + OATPP_LOGe("[oatpp::async::worker::IOEventWorker::waitEvents()]", "Error. Call to epoll_ctl failed. operation={}, errno={}", EPOLL_CTL_DEL, errno) throw std::runtime_error("[oatpp::async::worker::IOEventWorker::waitEvents()]: Error. Call to epoll_ctl failed."); } diff --git a/src/oatpp/async/worker/IOEventWorker_kqueue.cpp b/src/oatpp/async/worker/IOEventWorker_kqueue.cpp index d2e1614b..91c6345c 100644 --- a/src/oatpp/async/worker/IOEventWorker_kqueue.cpp +++ b/src/oatpp/async/worker/IOEventWorker_kqueue.cpp @@ -30,6 +30,7 @@ // kqueue based implementation #include "oatpp/async/Processor.hpp" +#include "oatpp/base/Log.hpp" #include @@ -44,8 +45,8 @@ void IOEventWorker::initEventQueue() { m_outEvents = std::unique_ptr(new (std::nothrow) v_char8[MAX_EVENTS * sizeof(struct kevent)]); if(!m_outEvents) { - OATPP_LOGE("[oatpp::async::worker::IOEventWorker::initEventQueue()]", - "Error. Unable to allocate %d bytes for events.", MAX_EVENTS * sizeof(struct kevent)) + OATPP_LOGe("[oatpp::async::worker::IOEventWorker::initEventQueue()]", + "Error. Unable to allocate {} bytes for events.", v_int32(MAX_EVENTS * sizeof(struct kevent))) throw std::runtime_error("[oatpp::async::worker::IOEventWorker::initEventQueue()]: Error. Unable to allocate memory for events."); } @@ -128,10 +129,10 @@ void IOEventWorker::consumeBacklog() { m_inEventsCapacity = m_inEventsCount; - m_inEvents = std::unique_ptr(new (std::nothrow) v_char8[m_inEventsCapacity * sizeof(struct kevent)]); + m_inEvents = std::unique_ptr(new (std::nothrow) v_char8[static_cast(m_inEventsCapacity) * sizeof(struct kevent)]); if(!m_inEvents) { - OATPP_LOGE("[oatpp::async::worker::IOEventWorker::consumeBacklog()]", - "Error. Unable to allocate %d bytes for events.", m_inEventsCapacity * sizeof(struct kevent)) + OATPP_LOGe("[oatpp::async::worker::IOEventWorker::consumeBacklog()]", + "Error. Unable to allocate {} bytes for events.", v_uint64(static_cast(m_inEventsCapacity) * sizeof(struct kevent))) throw std::runtime_error("[oatpp::async::worker::IOEventWorker::consumeBacklog()]: Error. Unable to allocate memory for events."); } @@ -158,12 +159,12 @@ void IOEventWorker::waitEvents() { auto eventsCount = kevent(m_eventQueueHandle, (struct kevent*)m_inEvents.get(), m_inEventsCount, (struct kevent*)m_outEvents.get(), MAX_EVENTS,nullptr); if((eventsCount < 0) && (errno != EINTR)) { - OATPP_LOGE("[oatpp::async::worker::IOEventWorker::waitEvents()]", "Error:\n" - "errno=%d\n" - "in-events=%d\n" - "foreman=%d\n" - "this=%d\n" - "specialization=%d", + OATPP_LOGe("[oatpp::async::worker::IOEventWorker::waitEvents()]", "Error:\n" + "errno={}\n" + "in-events={}\n" + "foreman={}\n" + "this={}\n" + "specialization={}", errno, m_inEventsCount, m_foreman, this, m_specialization) throw std::runtime_error("[oatpp::async::worker::IOEventWorker::waitEvents()]: Error. Event loop failed."); } @@ -177,7 +178,7 @@ void IOEventWorker::waitEvents() { auto coroutine = (CoroutineHandle*) event->udata; if((event->flags & EV_ERROR) > 0) { - OATPP_LOGD("Error", "data='%s'", strerror((int)event->data)) + OATPP_LOGd("Error", "data='{}'", strerror(static_cast(event->data))) continue; } diff --git a/src/oatpp/base/Log.cpp b/src/oatpp/base/Log.cpp index 9c078941..edc5859d 100644 --- a/src/oatpp/base/Log.cpp +++ b/src/oatpp/base/Log.cpp @@ -149,6 +149,20 @@ LogMessage& LogMessage::operator << (v_uint64 value) { return *this; } +LogMessage& LogMessage::operator << (v_buff_size value) { + if(writeNextChunk()) { + m_stream.writeAsString(static_cast(value)); + } + return *this; +} + +LogMessage& LogMessage::operator << (v_buff_usize value) { + if(writeNextChunk()) { + m_stream.writeAsString(static_cast(value)); + } + return *this; +} + LogMessage& LogMessage::operator << (v_float32 value) { if(writeNextChunk()) { m_stream.writeAsString(value); @@ -299,4 +313,10 @@ void LogMessage::log(v_uint32 priority, const std::string& tag, const LogMessage oatpp::Environment::log(priority, tag, message.toStdString()); } +void LogMessage::log(v_uint32 priority, const LogCategory& category, const LogMessage& message) { + if (category.categoryEnabled && (category.enabledPriorities & (1U << priority))) { + log(priority, category.tag, message); + } +} + } diff --git a/src/oatpp/base/Log.hpp b/src/oatpp/base/Log.hpp index 0d4b66ec..08892a1f 100644 --- a/src/oatpp/base/Log.hpp +++ b/src/oatpp/base/Log.hpp @@ -26,6 +26,7 @@ #define oatpp_base_Log_hpp #include "oatpp/data/stream/BufferStream.hpp" +#include "oatpp/macro/basic.hpp" namespace oatpp::base{ @@ -60,6 +61,8 @@ public: LogMessage& operator << (v_uint32 value); LogMessage& operator << (v_int64 value); LogMessage& operator << (v_uint64 value); + LogMessage& operator << (v_buff_size value); + LogMessage& operator << (v_buff_usize value); LogMessage& operator << (v_float32 value); LogMessage& operator << (v_float64 value); @@ -79,6 +82,7 @@ public: public: static void log(v_uint32 priority, const std::string& tag, const LogMessage& message); + static void log(v_uint32 priority, const LogCategory& category, const LogMessage& message); }; @@ -88,10 +92,10 @@ public: << P #define OATPP_LOG_MACRO_0(PRIORITY, TAG, MSG) \ -oatpp::base::LogMessage::log(PRIORITY, TAG, LogMessage(MSG)); +oatpp::base::LogMessage::log(PRIORITY, TAG, oatpp::base::LogMessage(MSG)); #define OATPP_LOG_MACRO_1(PRIORITY, TAG, MSG, ...) \ -oatpp::base::LogMessage::log(PRIORITY, TAG, LogMessage(MSG) OATPP_MACRO_FOREACH_OR_EMPTY(OATPP_LOG_PARAMS, __VA_ARGS__)); +oatpp::base::LogMessage::log(PRIORITY, TAG, oatpp::base::LogMessage(MSG) OATPP_MACRO_FOREACH_OR_EMPTY(OATPP_LOG_PARAMS, __VA_ARGS__)); /** * General LOG macro @@ -116,7 +120,7 @@ OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_LOG_MACRO_, (__VA_ARG * @param ... - optional format parameter. */ #define OATPP_LOGv(TAG, ...) \ - OATPP_LOG(oatpp::Logger::PRIORITY_V, TAG, __VA_ARGS__); + OATPP_LOG(oatpp::Logger::PRIORITY_V, TAG, __VA_ARGS__) #else #define OATPP_LOGv(TAG, ...) @@ -132,7 +136,7 @@ OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_LOG_MACRO_, (__VA_ARG * @param ... - optional format parameter. */ #define OATPP_LOGd(TAG, ...) \ - OATPP_LOG(oatpp::Logger::PRIORITY_D, TAG, __VA_ARGS__); + OATPP_LOG(oatpp::Logger::PRIORITY_D, TAG, __VA_ARGS__) #else #define OATPP_LOGd(TAG, ...) @@ -148,7 +152,7 @@ OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_LOG_MACRO_, (__VA_ARG * @param ... - optional format parameter. */ #define OATPP_LOGi(TAG, ...) \ - OATPP_LOG(oatpp::Logger::PRIORITY_I, TAG, __VA_ARGS__); + OATPP_LOG(oatpp::Logger::PRIORITY_I, TAG, __VA_ARGS__) #else #define OATPP_LOGi(TAG, ...) @@ -164,7 +168,7 @@ OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_LOG_MACRO_, (__VA_ARG * @param ... - optional format parameter. */ #define OATPP_LOGw(TAG, ...) \ - OATPP_LOG(oatpp::Logger::PRIORITY_W, TAG, __VA_ARGS__); + OATPP_LOG(oatpp::Logger::PRIORITY_W, TAG, __VA_ARGS__) #else #define OATPP_LOGw(TAG, ...) @@ -180,10 +184,57 @@ OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_LOG_MACRO_, (__VA_ARG * @param ... - optional format parameter. */ #define OATPP_LOGe(TAG, ...) \ - OATPP_LOG(oatpp::Logger::PRIORITY_E, TAG, __VA_ARGS__); + OATPP_LOG(oatpp::Logger::PRIORITY_E, TAG, __VA_ARGS__) #else #define OATPP_LOGe(TAG, ...) #endif +////////////////////// +////////////////////// +////////////////////// + + +/** + * Convenience macro to declare a logging category directly in a class header. + * @param NAME - variable-name of the category which is later used to reference the category. + */ +#define OATPP_DECLARE_LOG_CATEGORY(NAME) \ + static oatpp::LogCategory NAME; + +/** + * Convenience macro to implement a logging category directly in a class header. + * @param NAME - variable-name of the category which is later used to reference the category. + * @param TAG - tag printed with each message printed usig this category. + * @param ENABLED - enable or disable a category (bool). + */ +#define OATPP_LOG_CATEGORY(NAME, TAG, ENABLED) \ + oatpp::LogCategory NAME = oatpp::LogCategory(TAG, ENABLED); + + +////////////////////// +////////////////////// +////////////////////// + +/** + * Default oatpp assert method. + * @param FMT - the format string used for the expression + * @param EXP - expression that must be `true`. + */ +#define OATPP_ASSERT_FMT(FMT, EXP) \ +if(!(EXP)) { \ + OATPP_LOGe("\033[1mASSERT\033[0m[\033[1;31mFAILED\033[0m]", FMT, #EXP) \ + exit(EXIT_FAILURE); \ +} + +/** + * Default oatpp assert method. + * @param EXP - expression that must be `true`. + */ +#define OATPP_ASSERT(EXP) \ +if(!(EXP)) { \ + OATPP_LOGe("\033[1mASSERT\033[0m[\033[1;31mFAILED\033[0m]", #EXP) \ + exit(EXIT_FAILURE); \ +} + #endif /* oatpp_base_Log_hpp */ diff --git a/src/oatpp/concurrency/Utils.cpp b/src/oatpp/concurrency/Utils.cpp index 963b80e8..620e8cfe 100644 --- a/src/oatpp/concurrency/Utils.cpp +++ b/src/oatpp/concurrency/Utils.cpp @@ -23,6 +23,7 @@ ***************************************************************************/ #include "Utils.hpp" +#include "oatpp/base/Log.hpp" namespace oatpp { namespace concurrency { @@ -53,7 +54,7 @@ v_int32 Utils::setThreadAffinityToCpuRange(std::thread::native_handle_type nativ v_int32 result = pthread_setaffinity_np(nativeHandle, sizeof(cpu_set_t), &cpuset); if (result != 0) { - OATPP_LOGD("[oatpp::concurrency::Thread::assignThreadToCpu(...)]", "error code - %d", result) + OATPP_LOGd("[oatpp::concurrency::Thread::assignThreadToCpu(...)]", "error code - {}", result) } return result; @@ -74,7 +75,7 @@ v_int32 Utils::calcHardwareConcurrency() { #if !defined(OATPP_THREAD_HARDWARE_CONCURRENCY) v_int32 concurrency = static_cast(std::thread::hardware_concurrency()); if(concurrency == 0) { - OATPP_LOGD("[oatpp::concurrency:Thread::calcHardwareConcurrency()]", "Warning - failed to get hardware_concurrency. Setting hardware_concurrency=1") + OATPP_LOGd("[oatpp::concurrency:Thread::calcHardwareConcurrency()]", "Warning - failed to get hardware_concurrency. Setting hardware_concurrency=1") concurrency = 1; } return concurrency; diff --git a/src/oatpp/data/stream/FileStream.cpp b/src/oatpp/data/stream/FileStream.cpp index 299f126d..1cf8924a 100644 --- a/src/oatpp/data/stream/FileStream.cpp +++ b/src/oatpp/data/stream/FileStream.cpp @@ -23,6 +23,7 @@ ***************************************************************************/ #include "FileStream.hpp" +#include "oatpp/base/Log.hpp" namespace oatpp { namespace data{ namespace stream { @@ -52,7 +53,7 @@ FileInputStream::FileInputStream(const char* filename, const std::shared_ptr ConnectionProviderSwitch::getCurrentProvider if(!provider) { const char* const TAG = "[oatpp::network::ConnectionProviderSwitch::getCurrentProvider()]"; const char* const msg = "Error. Can't provide connection. There is no provider set."; - OATPP_LOGE(TAG, msg) + OATPP_LOGe(TAG, msg) throw std::runtime_error(std::string(TAG) + ": " + msg); } diff --git a/src/oatpp/network/Server.cpp b/src/oatpp/network/Server.cpp index 2e02bd2c..46e3819d 100644 --- a/src/oatpp/network/Server.cpp +++ b/src/oatpp/network/Server.cpp @@ -24,6 +24,8 @@ #include "Server.hpp" +#include "oatpp/base/Log.hpp" + #include #include @@ -62,7 +64,7 @@ void Server::conditionalMainLoop() { setStatus(STATUS_STOPPING); } } else { - OATPP_LOGD("[oatpp::network::server::mainLoop()]", "Error. Server already stopped - closing connection...") + OATPP_LOGd("[oatpp::network::server::mainLoop()]", "Error. Server already stopped - closing connection...") } } @@ -86,7 +88,7 @@ void Server::mainLoop(Server *instance) { if (instance->getStatus() == STATUS_RUNNING) { instance->m_connectionHandler->handleConnection(connectionHandle, params /* null params */); } else { - OATPP_LOGD("[oatpp::network::server::mainLoop()]", "Error. Server already stopped - closing connection...") + OATPP_LOGd("[oatpp::network::server::mainLoop()]", "Error. Server already stopped - closing connection...") } } } @@ -121,7 +123,7 @@ void Server::run(std::function conditional) { void Server::run(bool startAsNewThread) { std::unique_lock ul(m_mutex); - OATPP_LOGW("[oatpp::network::server::run(bool)]", "Using oatpp::network::server::run(bool) is deprecated and will be removed in the next release. Please implement your own threading (See https://github.com/oatpp/oatpp-threaded-starter).") + OATPP_LOGw("[oatpp::network::server::run(bool)]", "Using oatpp::network::server::run(bool) is deprecated and will be removed in the next release. Please implement your own threading (See https://github.com/oatpp/oatpp-threaded-starter).") switch (getStatus()) { case STATUS_STARTING: throw std::runtime_error("[oatpp::network::server::run()] Error. Server already starting"); diff --git a/src/oatpp/network/monitor/ConnectionMonitor.cpp b/src/oatpp/network/monitor/ConnectionMonitor.cpp index c3f98acc..2d802084 100644 --- a/src/oatpp/network/monitor/ConnectionMonitor.cpp +++ b/src/oatpp/network/monitor/ConnectionMonitor.cpp @@ -24,6 +24,8 @@ #include "ConnectionMonitor.hpp" +#include "oatpp/base/Log.hpp" + #include #include @@ -59,8 +61,8 @@ ConnectionMonitor::ConnectionProxy::~ConnectionProxy() { if(m_stats.metricsData.size() > 0) { for(auto& pair : m_stats.metricsData) { - OATPP_LOGE("[oatpp::network::ConnectionMonitor::ConnectionProxy::~ConnectionProxy()]", - "Error. Memory leak. Metric data was not deleted: Metric name - '%s'", pair.first->c_str()) + OATPP_LOGe("[oatpp::network::ConnectionMonitor::ConnectionProxy::~ConnectionProxy()]", + "Error. Memory leak. Metric data was not deleted: Metric name - '{}'", pair.first->c_str()) } } @@ -186,8 +188,8 @@ void ConnectionMonitor::Monitor::freeConnectionStats(ConnectionStats& stats) { if(it != m_statCollectors.end()) { it->second->deleteMetricData(metric.second); } else { - OATPP_LOGE("[oatpp::network::ConnectionMonitor::Monitor::freeConnectionStats]", - "Error. Can't free Metric data. Unknown Metric: name - '%s'", metric.first->c_str()) + OATPP_LOGe("[oatpp::network::ConnectionMonitor::Monitor::freeConnectionStats]", + "Error. Can't free Metric data. Unknown Metric: name - '{}'", metric.first->c_str()) } } diff --git a/src/oatpp/network/tcp/Connection.cpp b/src/oatpp/network/tcp/Connection.cpp index f89fcef8..6b100e29 100644 --- a/src/oatpp/network/tcp/Connection.cpp +++ b/src/oatpp/network/tcp/Connection.cpp @@ -101,7 +101,7 @@ v_io_size Connection::write(const void *buff, v_buff_size count, async::Action& } else if(e == WSAECONNRESET) { return IOError::BROKEN_PIPE; } else { - //OATPP_LOGD("Connection", "write errno=%d", e) + //OATPP_LOGd("Connection", "write errno={}", e) return IOError::BROKEN_PIPE; // Consider all other errors as a broken pipe. } } @@ -138,7 +138,7 @@ v_io_size Connection::write(const void *buff, v_buff_size count, async::Action& return IOError::BROKEN_PIPE; } - //OATPP_LOGD("Connection", "write errno=%d", e) + //OATPP_LOGd("Connection", "write errno={}", e) return IOError::BROKEN_PIPE; // Consider all other errors as a broken pipe. } return result; @@ -176,7 +176,7 @@ v_io_size Connection::read(void *buff, v_buff_size count, async::Action& action) } else if(e == WSAECONNRESET) { return IOError::BROKEN_PIPE; } else { - //OATPP_LOGD("Connection", "write errno=%d", e) + //OATPP_LOGd("Connection", "write errno={}", e) return IOError::BROKEN_PIPE; // Consider all other errors as a broken pipe. } } @@ -208,7 +208,7 @@ v_io_size Connection::read(void *buff, v_buff_size count, async::Action& action) return IOError::BROKEN_PIPE; } - //OATPP_LOGD("Connection", "write errno=%d", e) + //OATPP_LOGd("Connection", "write errno={}", e) return IOError::BROKEN_PIPE; // Consider all other errors as a broken pipe. } return result; diff --git a/src/oatpp/network/tcp/client/ConnectionProvider.cpp b/src/oatpp/network/tcp/client/ConnectionProvider.cpp index 24a247a2..24af2463 100644 --- a/src/oatpp/network/tcp/client/ConnectionProvider.cpp +++ b/src/oatpp/network/tcp/client/ConnectionProvider.cpp @@ -26,6 +26,7 @@ #include "oatpp/network/tcp/Connection.hpp" #include "oatpp/utils/Conversion.hpp" +#include "oatpp/base/Log.hpp" #include #include @@ -151,7 +152,7 @@ provider::ResourceHandle ConnectionProvider::get() { int yes = 1; v_int32 ret = setsockopt(clientHandle, SOL_SOCKET, SO_NOSIGPIPE, &yes, sizeof(int)); if(ret < 0) { - OATPP_LOGD("[oatpp::network::tcp::client::ConnectionProvider::getConnection()]", "Warning. Failed to set %s for socket", "SO_NOSIGPIPE") + OATPP_LOGd("[oatpp::network::tcp::client::ConnectionProvider::getConnection()]", "Warning. Failed to set {} for socket", "SO_NOSIGPIPE") } #endif @@ -266,7 +267,7 @@ oatpp::async::CoroutineStarterForResult @@ -178,7 +179,7 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){ const int iResult = getaddrinfo(m_address.host->c_str(), portStr->c_str(), &hints, &result); if (iResult != 0) { - OATPP_LOGE("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]", "Error. Call to getaddrinfo() failed with result=%d", iResult) + OATPP_LOGe("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]", "Error. Call to getaddrinfo() failed with result={}", iResult) throw std::runtime_error("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]: Error. Call to getaddrinfo() failed."); } @@ -195,8 +196,8 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){ if (setsockopt(serverHandle, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&no, sizeof( int ) ) != 0 ) { const size_t buflen = 500; char buf[buflen]; - OATPP_LOGW("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]", - "Warning. Failed to set %s for accepting socket: %s", "IPV6_V6ONLY", + OATPP_LOGw("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]", + "Warning. Failed to set {} for accepting socket: {}", "IPV6_V6ONLY", strerror_s(buf, buflen, errno)) } } @@ -218,8 +219,8 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){ freeaddrinfo(result); if (currResult == nullptr) { - OATPP_LOGE("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]", - "Error. Couldn't bind. WSAGetLastError=%ld", WSAGetLastError()) + OATPP_LOGe("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]", + "Error. Couldn't bind. WSAGetLastError={}", WSAGetLastError()) throw std::runtime_error("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]: " "Error. Couldn't bind "); } @@ -268,7 +269,7 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){ ret = getaddrinfo(m_address.host->c_str(), portStr->c_str(), &hints, &result); if (ret != 0) { - OATPP_LOGE("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]", "Error. Call to getaddrinfo() failed with result=%d: %s", ret, strerror(errno)) + OATPP_LOGe("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]", "Error. Call to getaddrinfo() failed with result={}: {}", ret, strerror(errno)) throw std::runtime_error("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]: Error. Call to getaddrinfo() failed."); } @@ -280,8 +281,8 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){ if (serverHandle >= 0) { if (setsockopt(serverHandle, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) != 0) { - OATPP_LOGW("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]", - "Warning. Failed to set %s for accepting socket: %s", "SO_REUSEADDR", strerror(errno)) + OATPP_LOGw("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]", + "Warning. Failed to set {} for accepting socket: {}", "SO_REUSEADDR", strerror(errno)) } if (bind(serverHandle, currResult->ai_addr, static_cast(currResult->ai_addrlen)) == 0 && @@ -302,8 +303,8 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){ if (currResult == nullptr) { std::string err = strerror(errno); - OATPP_LOGE("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]", - "Error. Couldn't bind. %s", err.c_str()) + OATPP_LOGe("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]", + "Error. Couldn't bind. {}", err.c_str()) throw std::runtime_error("[oatpp::network::tcp::server::ConnectionProvider::instantiateServer()]: " "Error. Couldn't bind " + err); } @@ -329,7 +330,7 @@ void ConnectionProvider::prepareConnectionHandle(oatpp::v_io_handle handle) { int yes = 1; v_int32 ret = setsockopt(handle, SOL_SOCKET, SO_NOSIGPIPE, &yes, sizeof(int)); if(ret < 0) { - OATPP_LOGD("[oatpp::network::tcp::server::ConnectionProvider::prepareConnectionHandle()]", "Warning. Failed to set %s for socket", "SO_NOSIGPIPE") + OATPP_LOGd("[oatpp::network::tcp::server::ConnectionProvider::prepareConnectionHandle()]", "Warning. Failed to set {} for socket", "SO_NOSIGPIPE") } #endif @@ -397,7 +398,7 @@ provider::ResourceHandle ConnectionProvider::getExtended ::close(handle); #endif - OATPP_LOGE("[oatpp::network::tcp::server::ConnectionProvider::getExtendedConnection()]", "Error. Unknown address family.") + OATPP_LOGe("[oatpp::network::tcp::server::ConnectionProvider::getExtendedConnection()]", "Error. Unknown address family.") return nullptr; } diff --git a/src/oatpp/network/virtual_/Interface.cpp b/src/oatpp/network/virtual_/Interface.cpp index 8958e3c2..1c5c36bc 100644 --- a/src/oatpp/network/virtual_/Interface.cpp +++ b/src/oatpp/network/virtual_/Interface.cpp @@ -23,6 +23,7 @@ ***************************************************************************/ #include "Interface.hpp" +#include "oatpp/base/Log.hpp" namespace oatpp { namespace network { namespace virtual_ { @@ -85,7 +86,7 @@ Interface::~Interface() { { std::lock_guard lock(m_listenerMutex); if (m_listenerLock != nullptr) { - OATPP_LOGE("[oatpp::network::virtual_::Interface::~Interface()]", + OATPP_LOGe("[oatpp::network::virtual_::Interface::~Interface()]", "Error! Interface destructor called, but listener is still bonded!!!") m_listenerLock.load()->m_interface = nullptr; } @@ -175,7 +176,7 @@ void Interface::unbindListener(ListenerLock* listenerLock) { m_listenerLock = nullptr; dropAllConnection(); } else { - OATPP_LOGE("[oatpp::network::virtual_::Interface::unbindListener()]", "Error! Unbinding wrong listener!!!") + OATPP_LOGe("[oatpp::network::virtual_::Interface::unbindListener()]", "Error! Unbinding wrong listener!!!") } } diff --git a/src/oatpp/web/client/ApiClient.hpp b/src/oatpp/web/client/ApiClient.hpp index 3d9e3de9..ea53fd3d 100644 --- a/src/oatpp/web/client/ApiClient.hpp +++ b/src/oatpp/web/client/ApiClient.hpp @@ -37,6 +37,7 @@ #include "oatpp/Types.hpp" #include "oatpp/utils/Conversion.hpp" +#include "oatpp/base/Log.hpp" #include #include @@ -230,8 +231,8 @@ public: (void) parameter; - OATPP_LOGE("[oatpp::web::client::ApiClient::TypeInterpretation::toString()]", - "Error. No conversion from '%s' to '%s' is defined.", typeName->c_str(), "oatpp::String") + OATPP_LOGe("[oatpp::web::client::ApiClient::TypeInterpretation::toString()]", + "Error. No conversion from '{}' to '{}' is defined.", typeName, "oatpp::String") throw std::runtime_error( "[oatpp::web::client::ApiClient::TypeInterpretation::toString()]: Error. " diff --git a/src/oatpp/web/mime/multipart/PartReader.cpp b/src/oatpp/web/mime/multipart/PartReader.cpp index 2dd97a04..ea77d453 100644 --- a/src/oatpp/web/mime/multipart/PartReader.cpp +++ b/src/oatpp/web/mime/multipart/PartReader.cpp @@ -23,6 +23,7 @@ ***************************************************************************/ #include "PartReader.hpp" +#include "oatpp/base/Log.hpp" namespace oatpp { namespace web { namespace mime { namespace multipart { @@ -73,12 +74,12 @@ void StreamPartReader::onPartData(const std::shared_ptr& part, const char* if(size > 0) { if(m_maxDataSize > 0 && tagObject->size + size > m_maxDataSize) { - OATPP_LOGE("[oatpp::web::mime::multipart::StreamPartReader::onPartData()]", "Error. Part size exceeds specified maxDataSize=%ld", m_maxDataSize) + OATPP_LOGe("[oatpp::web::mime::multipart::StreamPartReader::onPartData()]", "Error. Part size exceeds specified maxDataSize={}", m_maxDataSize) throw std::runtime_error("[oatpp::web::mime::multipart::StreamPartReader::onPartData()]: Error. Part size exceeds specified maxDataSize"); } auto res = tagObject->outputStream->writeExactSizeDataSimple(data, size); if(res != size) { - OATPP_LOGE("[oatpp::web::mime::multipart::StreamPartReader::onPartData()]", "Error. Failed to stream all data. Streamed %ld/%ld", res, size) + OATPP_LOGe("[oatpp::web::mime::multipart::StreamPartReader::onPartData()]", "Error. Failed to stream all data. Streamed {}/{}", res, size) throw std::runtime_error("[oatpp::web::mime::multipart::StreamPartReader::onPartData()]: Error. Failed to stream all data."); } tagObject->size += res; @@ -163,7 +164,7 @@ async::CoroutineStarter AsyncStreamPartReader::onPartDataAsync(const std::shared if(size > 0) { if(m_maxDataSize > 0 && tagObject->size + size > m_maxDataSize) { - OATPP_LOGE("[oatpp::web::mime::multipart::AsyncStreamPartReader::onPartDataAsync()]", "Error. Part size exceeds specified maxDataSize=%ld", m_maxDataSize) + OATPP_LOGe("[oatpp::web::mime::multipart::AsyncStreamPartReader::onPartDataAsync()]", "Error. Part size exceeds specified maxDataSize={}", m_maxDataSize) throw std::runtime_error("[oatpp::web::mime::multipart::AsyncStreamPartReader::onPartDataAsync()]: Error. Part size exceeds specified maxDataSize"); } return tagObject->outputStream->writeExactSizeDataAsync(data, size); diff --git a/src/oatpp/web/protocol/http/incoming/RequestHeadersReader.cpp b/src/oatpp/web/protocol/http/incoming/RequestHeadersReader.cpp index 7f8cba3a..47c46071 100644 --- a/src/oatpp/web/protocol/http/incoming/RequestHeadersReader.cpp +++ b/src/oatpp/web/protocol/http/incoming/RequestHeadersReader.cpp @@ -23,6 +23,7 @@ ***************************************************************************/ #include "RequestHeadersReader.hpp" +#include "oatpp/base/Log.hpp" namespace oatpp { namespace web { namespace protocol { namespace http { namespace incoming { @@ -78,7 +79,7 @@ RequestHeadersReader::Result RequestHeadersReader::readHeaders(data::stream::Inp error.ioStatus = readHeadersSectionIterative(iteration, stream, action); if(!action.isNone()) { - OATPP_LOGE("[oatpp::web::protocol::http::incoming::RequestHeadersReader::readHeaders]", "Error. Async action is unexpected.") + OATPP_LOGe("[oatpp::web::protocol::http::incoming::RequestHeadersReader::readHeaders]", "Error. Async action is unexpected.") throw std::runtime_error("[oatpp::web::protocol::http::incoming::RequestHeadersReader::readHeaders]: Error. Async action is unexpected."); } diff --git a/src/oatpp/web/protocol/http/outgoing/MultipartBody.cpp b/src/oatpp/web/protocol/http/outgoing/MultipartBody.cpp index 72952d5e..5ee867ae 100644 --- a/src/oatpp/web/protocol/http/outgoing/MultipartBody.cpp +++ b/src/oatpp/web/protocol/http/outgoing/MultipartBody.cpp @@ -24,13 +24,14 @@ #include "MultipartBody.hpp" #include "oatpp/data/stream/BufferStream.hpp" +#include "oatpp/base/Log.hpp" namespace oatpp { namespace web { namespace protocol { namespace http { namespace outgoing { v_io_size MultipartBody::readBody(void *buffer, v_buff_size count, async::Action& action) { const auto& stream = m_iterator.getPartInputStream(); if(!stream) { - OATPP_LOGW("[oatpp::web::protocol::http::outgoing::MultipartBody::MultipartReadCallback::readBody()]", "Warning. Part has no input stream.") + OATPP_LOGw("[oatpp::web::protocol::http::outgoing::MultipartBody::MultipartReadCallback::readBody()]", "Warning. Part has no input stream.") return 0; } return stream->read(buffer, count, action); @@ -81,7 +82,7 @@ v_io_size MultipartBody::read(void *buffer, v_buff_size count, async::Action& ac break; default: - OATPP_LOGE("[oatpp::web::protocol::http::outgoing::MultipartBody::MultipartReadCallback::read()]", "Error. Invalid state %d", m_state) + OATPP_LOGe("[oatpp::web::protocol::http::outgoing::MultipartBody::MultipartReadCallback::read()]", "Error. Invalid state {}", m_state) return 0; } @@ -107,7 +108,7 @@ v_io_size MultipartBody::read(void *buffer, v_buff_size count, async::Action& ac } } else if(action.isNone()) { - OATPP_LOGE("[oatpp::web::protocol::http::outgoing::MultipartBody::MultipartReadCallback::read()]", "Error. Invalid read result %ld. State=%d", res, m_state) + OATPP_LOGe("[oatpp::web::protocol::http::outgoing::MultipartBody::MultipartReadCallback::read()]", "Error. Invalid read result {}. State={}", res, m_state) return 0; } diff --git a/src/oatpp/web/server/HttpProcessor.cpp b/src/oatpp/web/server/HttpProcessor.cpp index 57ab5be8..38ed67b9 100644 --- a/src/oatpp/web/server/HttpProcessor.cpp +++ b/src/oatpp/web/server/HttpProcessor.cpp @@ -204,7 +204,7 @@ HttpProcessor::ConnectionState HttpProcessor::processNextRequest(ProcessingResou handler->handleConnection(resources.connection, response->getConnectionUpgradeParameters()); connectionState = ConnectionState::DELEGATED; } else { - OATPP_LOGW("[oatpp::web::server::HttpProcessor::processNextRequest()]", "Warning. ConnectionUpgradeHandler not set!") + OATPP_LOGw("[oatpp::web::server::HttpProcessor::processNextRequest()]", "Warning. ConnectionUpgradeHandler not set!") connectionState = ConnectionState::CLOSING; } } @@ -396,7 +396,7 @@ HttpProcessor::Coroutine::Action HttpProcessor::Coroutine::onRequestDone() { handler->handleConnection(m_connection, m_currentResponse->getConnectionUpgradeParameters()); m_connectionState = ConnectionState::DELEGATED; } else { - OATPP_LOGW("[oatpp::web::server::HttpProcessor::Coroutine::onResponseFormed()]", "Warning. ConnectionUpgradeHandler not set!") + OATPP_LOGw("[oatpp::web::server::HttpProcessor::Coroutine::onResponseFormed()]", "Warning. ConnectionUpgradeHandler not set!") m_connectionState = ConnectionState::CLOSING; } break; @@ -425,7 +425,7 @@ HttpProcessor::Coroutine::Action HttpProcessor::Coroutine::handleError(Error* er } if(m_currentResponse) { - //OATPP_LOGE("[oatpp::web::server::HttpProcessor::Coroutine::handleError()]", "Unhandled error. '%s'. Dropping connection", error->what()) + //OATPP_LOGe("[oatpp::web::server::HttpProcessor::Coroutine::handleError()]", "Unhandled error. '{}'. Dropping connection", error->what()) return error; } diff --git a/src/oatpp/web/server/api/ApiController.hpp b/src/oatpp/web/server/api/ApiController.hpp index 388b4523..367c5242 100644 --- a/src/oatpp/web/server/api/ApiController.hpp +++ b/src/oatpp/web/server/api/ApiController.hpp @@ -36,6 +36,7 @@ #include "oatpp/web/protocol/http/outgoing/ResponseFactory.hpp" #include "oatpp/utils/Conversion.hpp" +#include "oatpp/base/Log.hpp" #include #include @@ -453,8 +454,8 @@ public: static T fromString(const oatpp::String& typeName, const oatpp::String& text, bool& success) { (void) text; success = false; - OATPP_LOGE("[oatpp::web::server::api::ApiController::TypeInterpretation::fromString()]", - "Error. No conversion from '%s' to '%s' is defined.", "oatpp::String", typeName->c_str()) + OATPP_LOGe("[oatpp::web::server::api::ApiController::TypeInterpretation::fromString()]", + "Error. No conversion from '{}' to '{}' is defined.", "oatpp::String", typeName) throw std::runtime_error("[oatpp::web::server::api::ApiController::TypeInterpretation::fromString()]: Error. " "No conversion from 'oatpp::String' to '" + *typeName + "' is defined. " "Please define type conversion."); diff --git a/src/oatpp/web/url/mapping/Router.hpp b/src/oatpp/web/url/mapping/Router.hpp index fbf8eb5d..2f4a76e4 100644 --- a/src/oatpp/web/url/mapping/Router.hpp +++ b/src/oatpp/web/url/mapping/Router.hpp @@ -148,7 +148,7 @@ public: for(auto& pair : m_endpointsByPattern) { auto mapping = pair.first->toString(); - OATPP_LOGD("Router", "url '%s %s' -> mapped", reinterpret_cast(branch.getData()), mapping->c_str()) + OATPP_LOGd("Router", "url '{} {}' -> mapped", reinterpret_cast(branch.getData()), mapping) } } diff --git a/test/oatpp/AllTestsMain.cpp b/test/oatpp/AllTestsMain.cpp index c9c0d1f4..6e1ebdd6 100644 --- a/test/oatpp/AllTestsMain.cpp +++ b/test/oatpp/AllTestsMain.cpp @@ -82,182 +82,175 @@ namespace { -//#define LOG_PARAMS \ -//<< P - - - void runTests() { - //LOG("AAA", "MSG: {}", param1, param2); + oatpp::Environment::printCompilationConfig(); -// oatpp::Environment::printCompilationConfig(); -// -// OATPP_LOGD("Tests", "oatpp::String size={}", sizeof(oatpp::String)) -// -// OATPP_LOGD("Tests", "oatpp::String size=%lu", sizeof(oatpp::String)) -// OATPP_LOGD("Tests", "std::string size=%lu", sizeof(std::string)) -// OATPP_LOGD("Tests", "Vector size=%lu", sizeof(std::vector)) -// OATPP_LOGD("Tests", "Map size=%lu", sizeof(std::unordered_map)) -// OATPP_LOGD("Tests", "Tree size=%lu", sizeof(oatpp::data::mapping::Tree)) -// -// //return; -// -// OATPP_LOGD("Tests", "coroutine handle size=%lu", sizeof(oatpp::async::CoroutineHandle)) -// OATPP_LOGD("Tests", "coroutine size=%lu", sizeof(oatpp::async::AbstractCoroutine)) -// OATPP_LOGD("Tests", "action size=%lu", sizeof(oatpp::async::Action)) -// OATPP_LOGD("Tests", "class count=%d", oatpp::data::type::ClassId::getClassCount()) -// -// auto names = oatpp::data::type::ClassId::getRegisteredClassNames(); -// v_int32 i = 0; -// for(auto& name : names) { -// OATPP_LOGD("CLASS", "%d --> '%s'", i, name) -// i ++; -// } -// -// OATPP_RUN_TEST(oatpp::test::LoggerTest); -// OATPP_RUN_TEST(oatpp::base::CommandLineArgumentsTest); + OATPP_LOGd("Tests", "oatpp::String size={}", sizeof(oatpp::String)) + + OATPP_LOGd("Tests", "oatpp::String size={}", sizeof(oatpp::String)) + OATPP_LOGd("Tests", "std::string size={}", sizeof(std::string)) + OATPP_LOGd("Tests", "Vector size={}", sizeof(std::vector)) + OATPP_LOGd("Tests", "Map size={}", sizeof(std::unordered_map)) + OATPP_LOGd("Tests", "Tree size={}", sizeof(oatpp::data::mapping::Tree)) + + //return; + + OATPP_LOGd("Tests", "coroutine handle size={}", sizeof(oatpp::async::CoroutineHandle)) + OATPP_LOGd("Tests", "coroutine size={}", sizeof(oatpp::async::AbstractCoroutine)) + OATPP_LOGd("Tests", "action size={}", sizeof(oatpp::async::Action)) + OATPP_LOGd("Tests", "class count={}", oatpp::data::type::ClassId::getClassCount()) + + auto names = oatpp::data::type::ClassId::getRegisteredClassNames(); + v_int32 i = 0; + for(auto& name : names) { + OATPP_LOGd("CLASS", "{} --> '{}'", i, name) + i ++; + } + + OATPP_RUN_TEST(oatpp::test::LoggerTest); + OATPP_RUN_TEST(oatpp::base::CommandLineArgumentsTest); OATPP_RUN_TEST(oatpp::base::LogTest); -// -// OATPP_RUN_TEST(oatpp::data::share::MemoryLabelTest); -// OATPP_RUN_TEST(oatpp::data::share::LazyStringMapTest); -// OATPP_RUN_TEST(oatpp::data::share::StringTemplateTest); -// -// OATPP_RUN_TEST(oatpp::data::buffer::ProcessorTest); -// OATPP_RUN_TEST(oatpp::data::stream::BufferStreamTest); -// -// OATPP_RUN_TEST(oatpp::data::mapping::TreeTest); -// OATPP_RUN_TEST(oatpp::data::mapping::ObjectToTreeMapperTest); -// OATPP_RUN_TEST(oatpp::data::mapping::TreeToObjectMapperTest); -// OATPP_RUN_TEST(oatpp::data::mapping::ObjectRemapperTest); -// -// OATPP_RUN_TEST(oatpp::data::type::ObjectWrapperTest); -// OATPP_RUN_TEST(oatpp::data::type::TypeTest); -// -// OATPP_RUN_TEST(oatpp::data::type::StringTest); -// -// OATPP_RUN_TEST(oatpp::data::type::PrimitiveTest); -// OATPP_RUN_TEST(oatpp::data::type::ListTest); -// OATPP_RUN_TEST(oatpp::data::type::VectorTest); -// OATPP_RUN_TEST(oatpp::data::type::UnorderedSetTest); -// OATPP_RUN_TEST(oatpp::data::type::PairListTest); -// OATPP_RUN_TEST(oatpp::data::type::UnorderedMapTest); -// OATPP_RUN_TEST(oatpp::data::type::AnyTest); -// OATPP_RUN_TEST(oatpp::data::type::EnumTest); -// -// OATPP_RUN_TEST(oatpp::data::type::ObjectTest); -// -// OATPP_RUN_TEST(oatpp::data::type::InterpretationTest); -// OATPP_RUN_TEST(oatpp::data::mapping::TypeResolverTest); -// -// OATPP_RUN_TEST(oatpp::data::resource::InMemoryDataTest); -// -// OATPP_RUN_TEST(oatpp::async::ConditionVariableTest); -// OATPP_RUN_TEST(oatpp::async::LockTest); -// -// OATPP_RUN_TEST(oatpp::utils::parser::CaretTest); -// -// OATPP_RUN_TEST(oatpp::provider::PoolTest); -// OATPP_RUN_TEST(oatpp::provider::PoolTemplateTest); -// -// OATPP_RUN_TEST(oatpp::json::EnumTest); -// OATPP_RUN_TEST(oatpp::json::BooleanTest); -// -// OATPP_RUN_TEST(oatpp::json::UnorderedSetTest); -// -// OATPP_RUN_TEST(oatpp::json::DeserializerTest); -// -// OATPP_RUN_TEST(oatpp::json::DTOMapperPerfTest); -// -// OATPP_RUN_TEST(oatpp::json::DTOMapperTest); -// OATPP_RUN_TEST(oatpp::test::encoding::Base64Test); -// OATPP_RUN_TEST(oatpp::test::encoding::UnicodeTest); -// OATPP_RUN_TEST(oatpp::test::encoding::UrlTest); -// -// OATPP_RUN_TEST(oatpp::test::network::UrlTest); -// OATPP_RUN_TEST(oatpp::test::network::ConnectionPoolTest); -// OATPP_RUN_TEST(oatpp::test::network::monitor::ConnectionMonitorTest); -// OATPP_RUN_TEST(oatpp::test::network::virtual_::PipeTest); -// OATPP_RUN_TEST(oatpp::test::network::virtual_::InterfaceTest); -// -// OATPP_RUN_TEST(oatpp::test::web::protocol::http::encoding::ChunkedTest); -// -// OATPP_RUN_TEST(oatpp::test::web::mime::multipart::StatefulParserTest); -// OATPP_RUN_TEST(oatpp::web::mime::ContentMappersTest); -// -// OATPP_RUN_TEST(oatpp::test::web::server::HttpRouterTest); -// OATPP_RUN_TEST(oatpp::test::web::server::api::ApiControllerTest); -// OATPP_RUN_TEST(oatpp::test::web::server::handler::AuthorizationHandlerTest); -// -// { -// -// oatpp::test::web::server::ServerStopTest test_virtual(0); -// test_virtual.run(); -// -// oatpp::test::web::server::ServerStopTest test_port(8000); -// test_port.run(); -// -// } -// -// { -// -// oatpp::test::web::PipelineTest test_virtual(0, 3000); -// test_virtual.run(); -// -// oatpp::test::web::PipelineTest test_port(8000, 3000); -// test_port.run(); -// -// } -// -// { -// -// oatpp::test::web::PipelineAsyncTest test_virtual(0, 3000); -// test_virtual.run(); -// -// oatpp::test::web::PipelineAsyncTest test_port(8000, 3000); -// test_port.run(); -// -// } -// -// { -// -// oatpp::test::web::FullTest test_virtual(0, 1000); -// test_virtual.run(); -// -// oatpp::test::web::FullTest test_port(8000, 5); -// test_port.run(); -// -// } -// -// { -// -// oatpp::test::web::FullAsyncTest test_virtual(0, 1000); -// test_virtual.run(); -// -// oatpp::test::web::FullAsyncTest test_port(8000, 5); -// test_port.run(); -// -// } -// -// { -// -// oatpp::test::web::FullAsyncClientTest test_virtual(0, 1000); -// test_virtual.run(20); -// -// oatpp::test::web::FullAsyncClientTest test_port(8000, 5); -// test_port.run(1); -// -// } -// -// { -// -// oatpp::test::web::ClientRetryTest test_virtual(0); -// test_virtual.run(); -// -// oatpp::test::web::ClientRetryTest test_port(8000); -// test_port.run(); -// -// } + + OATPP_RUN_TEST(oatpp::data::share::MemoryLabelTest); + OATPP_RUN_TEST(oatpp::data::share::LazyStringMapTest); + OATPP_RUN_TEST(oatpp::data::share::StringTemplateTest); + + OATPP_RUN_TEST(oatpp::data::buffer::ProcessorTest); + OATPP_RUN_TEST(oatpp::data::stream::BufferStreamTest); + + OATPP_RUN_TEST(oatpp::data::mapping::TreeTest); + OATPP_RUN_TEST(oatpp::data::mapping::ObjectToTreeMapperTest); + OATPP_RUN_TEST(oatpp::data::mapping::TreeToObjectMapperTest); + OATPP_RUN_TEST(oatpp::data::mapping::ObjectRemapperTest); + + OATPP_RUN_TEST(oatpp::data::type::ObjectWrapperTest); + OATPP_RUN_TEST(oatpp::data::type::TypeTest); + + OATPP_RUN_TEST(oatpp::data::type::StringTest); + + OATPP_RUN_TEST(oatpp::data::type::PrimitiveTest); + OATPP_RUN_TEST(oatpp::data::type::ListTest); + OATPP_RUN_TEST(oatpp::data::type::VectorTest); + OATPP_RUN_TEST(oatpp::data::type::UnorderedSetTest); + OATPP_RUN_TEST(oatpp::data::type::PairListTest); + OATPP_RUN_TEST(oatpp::data::type::UnorderedMapTest); + OATPP_RUN_TEST(oatpp::data::type::AnyTest); + OATPP_RUN_TEST(oatpp::data::type::EnumTest); + + OATPP_RUN_TEST(oatpp::data::type::ObjectTest); + + OATPP_RUN_TEST(oatpp::data::type::InterpretationTest); + OATPP_RUN_TEST(oatpp::data::mapping::TypeResolverTest); + + OATPP_RUN_TEST(oatpp::data::resource::InMemoryDataTest); + + OATPP_RUN_TEST(oatpp::async::ConditionVariableTest); + OATPP_RUN_TEST(oatpp::async::LockTest); + + OATPP_RUN_TEST(oatpp::utils::parser::CaretTest); + + OATPP_RUN_TEST(oatpp::provider::PoolTest); + OATPP_RUN_TEST(oatpp::provider::PoolTemplateTest); + + OATPP_RUN_TEST(oatpp::json::EnumTest); + OATPP_RUN_TEST(oatpp::json::BooleanTest); + + OATPP_RUN_TEST(oatpp::json::UnorderedSetTest); + + OATPP_RUN_TEST(oatpp::json::DeserializerTest); + + OATPP_RUN_TEST(oatpp::json::DTOMapperPerfTest); + + OATPP_RUN_TEST(oatpp::json::DTOMapperTest); + OATPP_RUN_TEST(oatpp::test::encoding::Base64Test); + OATPP_RUN_TEST(oatpp::test::encoding::UnicodeTest); + OATPP_RUN_TEST(oatpp::test::encoding::UrlTest); + + OATPP_RUN_TEST(oatpp::test::network::UrlTest); + OATPP_RUN_TEST(oatpp::test::network::ConnectionPoolTest); + OATPP_RUN_TEST(oatpp::test::network::monitor::ConnectionMonitorTest); + OATPP_RUN_TEST(oatpp::test::network::virtual_::PipeTest); + OATPP_RUN_TEST(oatpp::test::network::virtual_::InterfaceTest); + + OATPP_RUN_TEST(oatpp::test::web::protocol::http::encoding::ChunkedTest); + + OATPP_RUN_TEST(oatpp::test::web::mime::multipart::StatefulParserTest); + OATPP_RUN_TEST(oatpp::web::mime::ContentMappersTest); + + OATPP_RUN_TEST(oatpp::test::web::server::HttpRouterTest); + OATPP_RUN_TEST(oatpp::test::web::server::api::ApiControllerTest); + OATPP_RUN_TEST(oatpp::test::web::server::handler::AuthorizationHandlerTest); + + { + + oatpp::test::web::server::ServerStopTest test_virtual(0); + test_virtual.run(); + + oatpp::test::web::server::ServerStopTest test_port(8000); + test_port.run(); + + } + + { + + oatpp::test::web::PipelineTest test_virtual(0, 3000); + test_virtual.run(); + + oatpp::test::web::PipelineTest test_port(8000, 3000); + test_port.run(); + + } + + { + + oatpp::test::web::PipelineAsyncTest test_virtual(0, 3000); + test_virtual.run(); + + oatpp::test::web::PipelineAsyncTest test_port(8000, 3000); + test_port.run(); + + } + + { + + oatpp::test::web::FullTest test_virtual(0, 1000); + test_virtual.run(); + + oatpp::test::web::FullTest test_port(8000, 5); + test_port.run(); + + } + + { + + oatpp::test::web::FullAsyncTest test_virtual(0, 1000); + test_virtual.run(); + + oatpp::test::web::FullAsyncTest test_port(8000, 5); + test_port.run(); + + } + + { + + oatpp::test::web::FullAsyncClientTest test_virtual(0, 1000); + test_virtual.run(20); + + oatpp::test::web::FullAsyncClientTest test_port(8000, 5); + test_port.run(1); + + } + + { + + oatpp::test::web::ClientRetryTest test_virtual(0); + test_virtual.run(); + + oatpp::test::web::ClientRetryTest test_port(8000); + test_port.run(); + + } } diff --git a/test/oatpp/LoggerTest.cpp b/test/oatpp/LoggerTest.cpp index 78f38578..89c5ed45 100644 --- a/test/oatpp/LoggerTest.cpp +++ b/test/oatpp/LoggerTest.cpp @@ -33,47 +33,47 @@ void LoggerTest::onRun() { auto logger = std::static_pointer_cast(oatpp::Environment::getLogger()); - OATPP_LOGV("LoggerTest", "Verbose Log") - OATPP_LOGD("LoggerTest", "Debug Log") - OATPP_LOGI("LoggerTest", "Info Log") - OATPP_LOGW("LoggerTest", "Warning Log") - OATPP_LOGE("LoggerTest", "Error Log") + OATPP_LOGv("LoggerTest", "Verbose Log") + OATPP_LOGd("LoggerTest", "Debug Log") + OATPP_LOGi("LoggerTest", "Info Log") + OATPP_LOGw("LoggerTest", "Warning Log") + OATPP_LOGe("LoggerTest", "Error Log") - OATPP_LOGI("LoggerTest", " --- Disabling Debug Log") + OATPP_LOGi("LoggerTest", " --- Disabling Debug Log") logger->disablePriority(oatpp::DefaultLogger::PRIORITY_D); OATPP_ASSERT(!logger->isLogPriorityEnabled(oatpp::DefaultLogger::PRIORITY_D)) - OATPP_LOGV("LoggerTest", "Verbose Log") - OATPP_LOGD("LoggerTest", "Debug Log") - OATPP_LOGI("LoggerTest", "Info Log") - OATPP_LOGW("LoggerTest", "Warning Log") - OATPP_LOGE("LoggerTest", "Error Log") + OATPP_LOGv("LoggerTest", "Verbose Log") + OATPP_LOGd("LoggerTest", "Debug Log") + OATPP_LOGi("LoggerTest", "Info Log") + OATPP_LOGw("LoggerTest", "Warning Log") + OATPP_LOGe("LoggerTest", "Error Log") - OATPP_LOGI("LoggerTest", " --- Enabling Debug Log again") + OATPP_LOGi("LoggerTest", " --- Enabling Debug Log again") logger->enablePriority(oatpp::DefaultLogger::PRIORITY_D); OATPP_ASSERT(logger->isLogPriorityEnabled(oatpp::DefaultLogger::PRIORITY_D)) - OATPP_LOGV("LoggerTest", "Verbose Log") - OATPP_LOGD("LoggerTest", "Debug Log") - OATPP_LOGI("LoggerTest", "Info Log") - OATPP_LOGW("LoggerTest", "Warning Log") - OATPP_LOGE("LoggerTest", "Error Log") + OATPP_LOGv("LoggerTest", "Verbose Log") + OATPP_LOGd("LoggerTest", "Debug Log") + OATPP_LOGi("LoggerTest", "Info Log") + OATPP_LOGw("LoggerTest", "Warning Log") + OATPP_LOGe("LoggerTest", "Error Log") - OATPP_LOGI(TESTCATEGORY, " --- Log-Test with category") - OATPP_LOGV(TESTCATEGORY, "Verbose Log") - OATPP_LOGD(TESTCATEGORY, "Debug Log") - OATPP_LOGI(TESTCATEGORY, "Info Log") - OATPP_LOGW(TESTCATEGORY, "Warning Log") - OATPP_LOGE(TESTCATEGORY, "Error Log") + OATPP_LOGi(TESTCATEGORY, " --- Log-Test with category") + OATPP_LOGv(TESTCATEGORY, "Verbose Log") + OATPP_LOGd(TESTCATEGORY, "Debug Log") + OATPP_LOGi(TESTCATEGORY, "Info Log") + OATPP_LOGw(TESTCATEGORY, "Warning Log") + OATPP_LOGe(TESTCATEGORY, "Error Log") - OATPP_LOGI(TESTCATEGORY, " --- Disabling Debug Log for category") + OATPP_LOGi(TESTCATEGORY, " --- Disabling Debug Log for category") TESTCATEGORY.disablePriority(oatpp::DefaultLogger::PRIORITY_D); OATPP_ASSERT(!TESTCATEGORY.isLogPriorityEnabled(oatpp::DefaultLogger::PRIORITY_D)) - OATPP_LOGV(TESTCATEGORY, "Verbose Log") - OATPP_LOGD(TESTCATEGORY, "Debug Log") - OATPP_LOGI(TESTCATEGORY, "Info Log") - OATPP_LOGW(TESTCATEGORY, "Warning Log") - OATPP_LOGE(TESTCATEGORY, "Error Log") + OATPP_LOGv(TESTCATEGORY, "Verbose Log") + OATPP_LOGd(TESTCATEGORY, "Debug Log") + OATPP_LOGi(TESTCATEGORY, "Info Log") + OATPP_LOGw(TESTCATEGORY, "Warning Log") + OATPP_LOGe(TESTCATEGORY, "Error Log") } diff --git a/test/oatpp/async/ConditionVariableTest.cpp b/test/oatpp/async/ConditionVariableTest.cpp index 7a1d96d6..77290ea8 100644 --- a/test/oatpp/async/ConditionVariableTest.cpp +++ b/test/oatpp/async/ConditionVariableTest.cpp @@ -137,7 +137,7 @@ void ConditionVariableTest::onRun() { for (v_int32 iter = 0; iter < 100; iter++) { - OATPP_LOGD("ITERATION 'WAIT'", "%d", iter) + OATPP_LOGd("ITERATION 'WAIT'", "{}", iter) oatpp::async::Executor executor; @@ -174,7 +174,7 @@ void ConditionVariableTest::onRun() { for (v_int32 iter = 0; iter < 100; iter++) { - OATPP_LOGD("ITERATION 'WAIT-WITH-TIMEOUT'", "%d", iter) + OATPP_LOGd("ITERATION 'WAIT-WITH-TIMEOUT'", "{}", iter) oatpp::async::Executor executor; @@ -211,7 +211,7 @@ void ConditionVariableTest::onRun() { for (v_int32 iter = 0; iter < 5; iter++) { - OATPP_LOGD("ITERATION 'TIMEOUT'", "%d", iter) + OATPP_LOGd("ITERATION 'TIMEOUT'", "{}", iter) oatpp::async::Executor executor; diff --git a/test/oatpp/async/LockTest.cpp b/test/oatpp/async/LockTest.cpp index 7fffff04..51175c7e 100644 --- a/test/oatpp/async/LockTest.cpp +++ b/test/oatpp/async/LockTest.cpp @@ -141,7 +141,7 @@ bool checkSymbol(char symbol, const char* data, v_buff_size size) { for (v_buff_size j = 0; j < NUM_SYMBOLS; j++) { if (data[i + j] != symbol) { - OATPP_LOGD("aaa", "j pos=%ld", j) + OATPP_LOGd("aaa", "j pos={}", j) return false; } @@ -153,7 +153,7 @@ bool checkSymbol(char symbol, const char* data, v_buff_size size) { } - OATPP_LOGD("aaa", "No symbol found") + OATPP_LOGd("aaa", "No symbol found") return false; } @@ -202,7 +202,7 @@ void LockTest::onRun() { if(!check) { v_int32 code = c; auto str = oatpp::String(reinterpret_cast(&c), 1); - OATPP_LOGE(TAG, "Failed for symbol %d, '%s'", code, str->data()) + OATPP_LOGe(TAG, "Failed for symbol {}, '{}'", code, str->data()) } OATPP_ASSERT(check) } diff --git a/test/oatpp/data/buffer/ProcessorTest.cpp b/test/oatpp/data/buffer/ProcessorTest.cpp index 75de1d46..86ee0d02 100644 --- a/test/oatpp/data/buffer/ProcessorTest.cpp +++ b/test/oatpp/data/buffer/ProcessorTest.cpp @@ -28,6 +28,7 @@ #include "oatpp/data/buffer/Processor.hpp" #include "oatpp/async/Executor.hpp" +#include "oatpp/base/Log.hpp" namespace oatpp { namespace data { namespace buffer { @@ -213,7 +214,7 @@ void ProcessorTest::onRun() { auto result = runTestCase(data, p1N, p2N, p3N, buffSize); if (result != etalon) { - OATPP_LOGD(TAG, "error[%d, %d, %d, b=%d] result='%s'", p1N, p2N, p3N, buffSize, result->data()) + OATPP_LOGd(TAG, "error[{}, {}, {}, b={}] result='{}'", p1N, p2N, p3N, buffSize, result->data()) } OATPP_ASSERT(result == etalon) diff --git a/test/oatpp/data/mapping/ObjectRemapperTest.cpp b/test/oatpp/data/mapping/ObjectRemapperTest.cpp index dd8c3000..bb23fe90 100644 --- a/test/oatpp/data/mapping/ObjectRemapperTest.cpp +++ b/test/oatpp/data/mapping/ObjectRemapperTest.cpp @@ -82,7 +82,7 @@ void ObjectRemapperTest::onRun() { { - OATPP_LOGD(TAG, "Remap. useUnqualifiedFieldNames = false; useUnqualifiedEnumNames = true") + OATPP_LOGd(TAG, "Remap. useUnqualifiedFieldNames = false; useUnqualifiedEnumNames = true") remapper.objectToTreeConfig().useUnqualifiedFieldNames = false; remapper.treeToObjectConfig().useUnqualifiedFieldNames = false; @@ -112,7 +112,7 @@ void ObjectRemapperTest::onRun() { { - OATPP_LOGD(TAG, "Remap. useUnqualifiedFieldNames = true; useUnqualifiedEnumNames = true") + OATPP_LOGd(TAG, "Remap. useUnqualifiedFieldNames = true; useUnqualifiedEnumNames = true") remapper.objectToTreeConfig().useUnqualifiedFieldNames = true; remapper.treeToObjectConfig().useUnqualifiedFieldNames = true; @@ -141,7 +141,7 @@ void ObjectRemapperTest::onRun() { } { - OATPP_LOGD(TAG, "Remap. Object to Vector") + OATPP_LOGd(TAG, "Remap. Object to Vector") remapper.objectToTreeConfig().useUnqualifiedFieldNames = false; remapper.treeToObjectConfig().useUnqualifiedFieldNames = false; @@ -170,7 +170,7 @@ void ObjectRemapperTest::onRun() { { - OATPP_LOGD(TAG, "Remap tree fragments") + OATPP_LOGd(TAG, "Remap tree fragments") Tree tree; tree.setVector(3); diff --git a/test/oatpp/data/mapping/ObjectToTreeMapperTest.cpp b/test/oatpp/data/mapping/ObjectToTreeMapperTest.cpp index 3f50e320..5113ca67 100644 --- a/test/oatpp/data/mapping/ObjectToTreeMapperTest.cpp +++ b/test/oatpp/data/mapping/ObjectToTreeMapperTest.cpp @@ -75,7 +75,7 @@ void ObjectToTreeMapperTest::onRun() { ObjectToTreeMapper::Config config; { - OATPP_LOGD(TAG, "Map String") + OATPP_LOGd(TAG, "Map String") Tree tree; ObjectToTreeMapper::State state; state.tree = &tree; @@ -92,7 +92,7 @@ void ObjectToTreeMapperTest::onRun() { } { - OATPP_LOGD(TAG, "Map String in Any") + OATPP_LOGd(TAG, "Map String in Any") Tree tree; ObjectToTreeMapper::State state; state.tree = &tree; @@ -110,7 +110,7 @@ void ObjectToTreeMapperTest::onRun() { } { - OATPP_LOGD(TAG, "Map Object qualified") + OATPP_LOGd(TAG, "Map Object qualified") config.useUnqualifiedFieldNames = false; Tree tree; @@ -180,7 +180,7 @@ void ObjectToTreeMapperTest::onRun() { } { - OATPP_LOGD(TAG, "Map Object unqualified") + OATPP_LOGd(TAG, "Map Object unqualified") config.useUnqualifiedFieldNames = true; Tree tree; @@ -250,7 +250,7 @@ void ObjectToTreeMapperTest::onRun() { } { - OATPP_LOGD(TAG, "Map Enum qualified") + OATPP_LOGd(TAG, "Map Enum qualified") config.useUnqualifiedEnumNames = false; Tree tree; @@ -268,7 +268,7 @@ void ObjectToTreeMapperTest::onRun() { } { - OATPP_LOGD(TAG, "Map Enum Unqualified") + OATPP_LOGd(TAG, "Map Enum Unqualified") config.useUnqualifiedEnumNames = true; Tree tree; diff --git a/test/oatpp/data/mapping/TreeTest.cpp b/test/oatpp/data/mapping/TreeTest.cpp index 62a44f35..c334e208 100644 --- a/test/oatpp/data/mapping/TreeTest.cpp +++ b/test/oatpp/data/mapping/TreeTest.cpp @@ -36,7 +36,7 @@ namespace { template void testTreeValue(T value) { - OATPP_LOGD("TEST", "Test value retrieval for '%s'", Tree::NodePrimitiveType::name) + OATPP_LOGd("TEST", "Test value retrieval for '{}'", Tree::NodePrimitiveType::name) Tree node; @@ -72,7 +72,7 @@ void TreeTest::onRun() { testTreeValue(16); { - OATPP_LOGD(TAG, "Case 1") + OATPP_LOGd(TAG, "Case 1") Tree node; oatpp::String original = "Hello World!"; node.setString(original); @@ -82,7 +82,7 @@ void TreeTest::onRun() { } { - OATPP_LOGD(TAG, "Case 2") + OATPP_LOGd(TAG, "Case 2") Tree node1; Tree node2; @@ -97,7 +97,7 @@ void TreeTest::onRun() { } { - OATPP_LOGD(TAG, "Case 3") + OATPP_LOGd(TAG, "Case 3") Tree node1; Tree node2; @@ -110,7 +110,7 @@ void TreeTest::onRun() { } { - OATPP_LOGD(TAG, "Case 4") + OATPP_LOGd(TAG, "Case 4") std::vector originalVector(10); for(v_uint32 i = 0; i < 10; i ++) { originalVector.at(i).setValue(i); @@ -138,7 +138,7 @@ void TreeTest::onRun() { } { - OATPP_LOGD(TAG, "Case 5") + OATPP_LOGd(TAG, "Case 5") TreeMap originalMap; for(v_uint32 i = 0; i < 10; i ++) { originalMap["node_" + utils::Conversion::int32ToStr(static_cast(i))].setValue(i); @@ -163,7 +163,7 @@ void TreeTest::onRun() { } { - OATPP_LOGD(TAG, "Case 6") + OATPP_LOGd(TAG, "Case 6") Tree article; oatpp::Tree ot; @@ -180,14 +180,14 @@ void TreeTest::onRun() { v_int32 value = article["pages"]; oatpp::String author = article["references"][0]["author"]; - OATPP_LOGD(TAG, "pages=%d', refs='%s', node_type=%d", value, author->c_str(), static_cast(article.getType())) + OATPP_LOGd(TAG, "pages={}', refs='{}', node_type={}", value, author, static_cast(article.getType())) } { - OATPP_LOGD(TAG, "Attributes Case 1") - OATPP_LOGD(TAG, "size of Tree::Attributes='%lu'", sizeof(Tree::Attributes)) + OATPP_LOGd(TAG, "Attributes Case 1") + OATPP_LOGd(TAG, "size of Tree::Attributes='{}'", sizeof(Tree::Attributes)) Tree::Attributes attr; @@ -211,7 +211,7 @@ void TreeTest::onRun() { { - OATPP_LOGD(TAG, "Attributes Case 2") + OATPP_LOGd(TAG, "Attributes Case 2") Tree::Attributes attr1; Tree::Attributes attr2; @@ -254,7 +254,7 @@ void TreeTest::onRun() { { - OATPP_LOGD(TAG, "Attributes Case 3") + OATPP_LOGd(TAG, "Attributes Case 3") Tree tree1; Tree tree2; diff --git a/test/oatpp/data/mapping/TreeToObjectMapperTest.cpp b/test/oatpp/data/mapping/TreeToObjectMapperTest.cpp index adc354d3..508f6b5e 100644 --- a/test/oatpp/data/mapping/TreeToObjectMapperTest.cpp +++ b/test/oatpp/data/mapping/TreeToObjectMapperTest.cpp @@ -84,7 +84,7 @@ void TreeToObjectMapperTest::onRun() { ObjectToTreeMapper::Config reverseConfig; { - OATPP_LOGD(TAG, "Map Object qualified") + OATPP_LOGd(TAG, "Map Object qualified") config.useUnqualifiedFieldNames = false; Tree tree; @@ -161,7 +161,7 @@ void TreeToObjectMapperTest::onRun() { } { - OATPP_LOGD(TAG, "Map Object unqualified") + OATPP_LOGd(TAG, "Map Object unqualified") config.useUnqualifiedFieldNames = true; Tree tree; @@ -238,7 +238,7 @@ void TreeToObjectMapperTest::onRun() { } { - OATPP_LOGD(TAG, "Map Enum qualified") + OATPP_LOGd(TAG, "Map Enum qualified") config.useUnqualifiedEnumNames = false; Tree tree; @@ -261,7 +261,7 @@ void TreeToObjectMapperTest::onRun() { } { - OATPP_LOGD(TAG, "Map Enum unqualified") + OATPP_LOGd(TAG, "Map Enum unqualified") config.useUnqualifiedEnumNames = true; Tree tree; diff --git a/test/oatpp/data/share/MemoryLabelTest.cpp b/test/oatpp/data/share/MemoryLabelTest.cpp index 2ee3081c..abf27ae2 100644 --- a/test/oatpp/data/share/MemoryLabelTest.cpp +++ b/test/oatpp/data/share/MemoryLabelTest.cpp @@ -36,7 +36,7 @@ namespace oatpp { namespace data { namespace share { void MemoryLabelTest::onRun() { { - OATPP_LOGI(TAG, "StringKeyLabel default constructor...") + OATPP_LOGi(TAG, "StringKeyLabel default constructor...") StringKeyLabel s; StringKeyLabel s0; OATPP_ASSERT(!s) @@ -44,21 +44,21 @@ void MemoryLabelTest::onRun() { OATPP_ASSERT(s == s0) OATPP_ASSERT(s != "text") OATPP_ASSERT(s != oatpp::String("text")) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "StringKeyLabel nullptr constructor...") + OATPP_LOGi(TAG, "StringKeyLabel nullptr constructor...") StringKeyLabel s(nullptr); OATPP_ASSERT(!s) OATPP_ASSERT(s == nullptr) OATPP_ASSERT(s != "text") OATPP_ASSERT(s != oatpp::String("text")) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "StringKeyLabel const char* constructor...") + OATPP_LOGi(TAG, "StringKeyLabel const char* constructor...") StringKeyLabel s("hello"); StringKeyLabel s0; OATPP_ASSERT(s) @@ -69,11 +69,11 @@ void MemoryLabelTest::onRun() { OATPP_ASSERT(s == oatpp::String("hello")) OATPP_ASSERT(s != "text") OATPP_ASSERT(s != oatpp::String("text")) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "StringKeyLabel oatpp::String constructor...") + OATPP_LOGi(TAG, "StringKeyLabel oatpp::String constructor...") StringKeyLabel s(oatpp::String("hello")); OATPP_ASSERT(s) OATPP_ASSERT(s != nullptr) @@ -81,11 +81,11 @@ void MemoryLabelTest::onRun() { OATPP_ASSERT(s == oatpp::String("hello")) OATPP_ASSERT(s != "text") OATPP_ASSERT(s != oatpp::String("text")) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "StringKeyLabelCI default constructor...") + OATPP_LOGi(TAG, "StringKeyLabelCI default constructor...") StringKeyLabelCI s; StringKeyLabelCI s0; OATPP_ASSERT(!s) @@ -93,21 +93,21 @@ void MemoryLabelTest::onRun() { OATPP_ASSERT(s == s0) OATPP_ASSERT(s != "teXt") OATPP_ASSERT(s != oatpp::String("teXt")) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "StringKeyLabelCI nullptr constructor...") + OATPP_LOGi(TAG, "StringKeyLabelCI nullptr constructor...") StringKeyLabelCI s(nullptr); OATPP_ASSERT(!s) OATPP_ASSERT(s == nullptr) OATPP_ASSERT(s != "teXt") OATPP_ASSERT(s != oatpp::String("teXt")) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "StringKeyLabelCI const char* constructor...") + OATPP_LOGi(TAG, "StringKeyLabelCI const char* constructor...") StringKeyLabelCI s("hello"); StringKeyLabelCI s0; OATPP_ASSERT(s) @@ -118,11 +118,11 @@ void MemoryLabelTest::onRun() { OATPP_ASSERT(s == oatpp::String("helLO")) OATPP_ASSERT(s != "text") OATPP_ASSERT(s != oatpp::String("teXt")) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "StringKeyLabelCI oatpp::String constructor...") + OATPP_LOGi(TAG, "StringKeyLabelCI oatpp::String constructor...") StringKeyLabelCI s(oatpp::String("hello")); OATPP_ASSERT(s) OATPP_ASSERT(s != nullptr) @@ -130,11 +130,11 @@ void MemoryLabelTest::onRun() { OATPP_ASSERT(s == oatpp::String("helLO")) OATPP_ASSERT(s != "text") OATPP_ASSERT(s != oatpp::String("teXt")) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "general test...") + OATPP_LOGi(TAG, "general test...") oatpp::String sharedData = "big text goes here"; oatpp::String key1 = "key1"; @@ -240,7 +240,7 @@ void MemoryLabelTest::onRun() { } - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } @@ -270,7 +270,7 @@ void MemoryLabelTest::onRun() { for(auto& h : headers.getAll()) { auto key = h.first.toString(); auto val = h.second.toString(); - OATPP_LOGD(TAG, "'%s': '%s'", key->c_str(), val->c_str()) + OATPP_LOGd(TAG, "'{}': '{}'", key->c_str(), val->c_str()) } } diff --git a/test/oatpp/data/share/StringTemplateTest.cpp b/test/oatpp/data/share/StringTemplateTest.cpp index 5072c63d..f7e6431d 100644 --- a/test/oatpp/data/share/StringTemplateTest.cpp +++ b/test/oatpp/data/share/StringTemplateTest.cpp @@ -33,79 +33,79 @@ void StringTemplateTest::onRun() { typedef oatpp::data::share::StringTemplate StringTemplate; { - OATPP_LOGI(TAG, "Case1 ...") + OATPP_LOGi(TAG, "Case1 ...") StringTemplate t("{} World!", {{0, 1, "p1", nullptr}}); auto result = t.format(std::vector({"Hello"})); OATPP_ASSERT(result == "Hello World!") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Case2 ...") + OATPP_LOGi(TAG, "Case2 ...") StringTemplate t("{} World!", {{0, 1, "p1", nullptr}}); auto result = t.format(std::unordered_map({{"p1", "Hello"}})); OATPP_ASSERT(result == "Hello World!") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Case3 ...") + OATPP_LOGi(TAG, "Case3 ...") StringTemplate t("Hello {}", {{6, 7, "p1", nullptr}}); auto result = t.format(std::vector({"World!"})); OATPP_ASSERT(result == "Hello World!") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Case4 ...") + OATPP_LOGi(TAG, "Case4 ...") StringTemplate t("Hello {}", {{6, 7, "p1", nullptr}}); auto result = t.format(std::unordered_map({{"p1", "World!"}})); OATPP_ASSERT(result == "Hello World!") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Case5 ...") + OATPP_LOGi(TAG, "Case5 ...") StringTemplate t("Hello {} World!", {{6, 7, "p1", nullptr}}); auto result = t.format(std::vector({"My"})); OATPP_ASSERT(result == "Hello My World!") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Case6 ...") + OATPP_LOGi(TAG, "Case6 ...") StringTemplate t("Hello {} World!", {{6, 7, "p1", nullptr}}); auto result = t.format(std::unordered_map({{"p1", "My"}})); OATPP_ASSERT(result == "Hello My World!") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Case7 ...") + OATPP_LOGi(TAG, "Case7 ...") StringTemplate t("? ? ?", {{0, 0, "p1", nullptr}, {2, 2, "p2", nullptr}, {4, 4, "p3", nullptr}}); auto result = t.format(std::vector({"Hello", "World", "Oat++!"})); OATPP_ASSERT(result == "Hello World Oat++!") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Case8 ...") + OATPP_LOGi(TAG, "Case8 ...") StringTemplate t("? ? ?", {{0, 0, "p1", nullptr}, {2, 2, "p2", nullptr}, {4, 4, "p3", nullptr}}); auto result = t.format(std::unordered_map({{"p3", "Hello"}, {"p2", "World"}, {"p1", "Oat++!"}})); OATPP_ASSERT(result == "Oat++! World Hello") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Case9 ...") + OATPP_LOGi(TAG, "Case9 ...") StringTemplate t("? ? ?", {{0, 0, "p1", nullptr}, {2, 2, "p2", nullptr}, {4, 4, "p3", nullptr}}); auto result = t.format("A"); OATPP_ASSERT(result == "A A A") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Case10 ...") + OATPP_LOGi(TAG, "Case10 ...") StringTemplate t("? ? ?", { {0, 0, "p1", std::make_shared()}, @@ -115,7 +115,7 @@ void StringTemplateTest::onRun() { ); auto result = t.format("(A)"); OATPP_ASSERT(result == "(A) (A) (A)") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } } diff --git a/test/oatpp/data/stream/BufferStreamTest.cpp b/test/oatpp/data/stream/BufferStreamTest.cpp index 568ae44a..fb9ea30b 100644 --- a/test/oatpp/data/stream/BufferStreamTest.cpp +++ b/test/oatpp/data/stream/BufferStreamTest.cpp @@ -38,7 +38,7 @@ void BufferStreamTest::onRun() { stream << "int=" << 1 << ", float=" << 1.1 << ", " << "bool=" << true << " or " << false; - OATPP_LOGV(TAG, "str='%s'", stream.toString()->c_str()) + OATPP_LOGv(TAG, "str='{}'", stream.toString()->c_str()) stream.setCurrentPosition(0); stream << 101; diff --git a/test/oatpp/data/type/AnyTest.cpp b/test/oatpp/data/type/AnyTest.cpp index 200ac7ba..a34c246a 100644 --- a/test/oatpp/data/type/AnyTest.cpp +++ b/test/oatpp/data/type/AnyTest.cpp @@ -58,36 +58,36 @@ class Test : public oatpp::DTO { void AnyTest::onRun() { { - OATPP_LOGI(TAG, "Test default constructor...") + OATPP_LOGi(TAG, "Test default constructor...") oatpp::Any any; OATPP_ASSERT(!any) OATPP_ASSERT(any.getValueType() == oatpp::data::type::__class::Any::getType()) OATPP_ASSERT(any.getStoredType() == nullptr) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test nullptr constructor...") + OATPP_LOGi(TAG, "Test nullptr constructor...") oatpp::Any any(nullptr); OATPP_ASSERT(!any) OATPP_ASSERT(any.getValueType() == oatpp::data::type::__class::Any::getType()) OATPP_ASSERT(any.getStoredType() == nullptr) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test retrieve()...") + OATPP_LOGi(TAG, "Test retrieve()...") oatpp::Any any(oatpp::String("Hello Any!")); OATPP_ASSERT(any) OATPP_ASSERT(any.getValueType() == oatpp::data::type::__class::Any::getType()) OATPP_ASSERT(any.getStoredType() == oatpp::data::type::__class::String::getType()) auto str = any.retrieve(); OATPP_ASSERT(str == "Hello Any!") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test store()...") + OATPP_LOGi(TAG, "Test store()...") oatpp::Any any(oatpp::Int32(32)); OATPP_ASSERT(any) @@ -102,11 +102,11 @@ void AnyTest::onRun() { auto str = any.retrieve(); OATPP_ASSERT(str == "Hello Any!") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test retrieve() class check...") + OATPP_LOGi(TAG, "Test retrieve() class check...") oatpp::Any any(Dto1::createShared()); OATPP_ASSERT(any) OATPP_ASSERT(any.getValueType() == oatpp::data::type::__class::Any::getType()) @@ -121,11 +121,11 @@ void AnyTest::onRun() { } OATPP_ASSERT(wasError) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test copy-assign operator...") + OATPP_LOGi(TAG, "Test copy-assign operator...") oatpp::Any any1(oatpp::String("Hello!")); oatpp::Any any2; @@ -148,11 +148,11 @@ void AnyTest::onRun() { OATPP_ASSERT(str1 == str2) OATPP_ASSERT(str1.get() == str2.get() && str1 == "Hello!") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test move-assign operator...") + OATPP_LOGi(TAG, "Test move-assign operator...") oatpp::Any any1(oatpp::String("Hello!")); oatpp::Any any2; @@ -175,7 +175,7 @@ void AnyTest::onRun() { OATPP_ASSERT(str1 != str2) OATPP_ASSERT(str2 == "Hello!") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } } diff --git a/test/oatpp/data/type/EnumTest.cpp b/test/oatpp/data/type/EnumTest.cpp index a025fee7..68514c19 100644 --- a/test/oatpp/data/type/EnumTest.cpp +++ b/test/oatpp/data/type/EnumTest.cpp @@ -58,7 +58,7 @@ ENUM(Enum3, v_int32, void EnumTest::onRun() { { - OATPP_LOGI(TAG, "Check Hash...") + OATPP_LOGi(TAG, "Check Hash...") { auto v = std::hash>{}(oatpp::Enum()); @@ -91,11 +91,11 @@ void EnumTest::onRun() { OATPP_ASSERT(map[Enum1::V2] == "v2") OATPP_ASSERT(map[Enum1::V3] == "v3") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Check Meta...") + OATPP_LOGi(TAG, "Check Meta...") { const auto &entries = oatpp::Enum::getEntries(); OATPP_ASSERT(entries.size() == 0) @@ -125,11 +125,11 @@ void EnumTest::onRun() { OATPP_ASSERT(v[2].index == 2 && v[2].name == "v-3" && v[2].value == Enum3::V_3 && v[2].description == "description_3") } - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Declaration...") + OATPP_LOGi(TAG, "Declaration...") OATPP_ASSERT(oatpp::Enum::Interpreter::notNull == false) OATPP_ASSERT(oatpp::Enum::NotNull::Interpreter::notNull == true) @@ -159,11 +159,11 @@ void EnumTest::onRun() { OATPP_ASSERT(interEnum[0].getStoredType() == oatpp::String::Class::getType()) } - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test Interpreter AsString (Qualified)...") + OATPP_LOGi(TAG, "Test Interpreter AsString (Qualified)...") oatpp::data::type::EnumInterpreterError e = oatpp::data::type::EnumInterpreterError::OK; auto inter = oatpp::Enum::AsString::Interpreter::toInterpretation(oatpp::Enum::AsString(Enum2::NAME_1), false, e); OATPP_ASSERT(inter.getValueType() == oatpp::String::Class::getType()) @@ -178,11 +178,11 @@ void EnumTest::onRun() { auto value = voidValue.cast::AsString>(); OATPP_ASSERT(value == Enum2::NAME_1) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test Interpreter AsString (Unqualified)...") + OATPP_LOGi(TAG, "Test Interpreter AsString (Unqualified)...") oatpp::data::type::EnumInterpreterError e = oatpp::data::type::EnumInterpreterError::OK; auto inter = oatpp::Enum::AsString::Interpreter::toInterpretation(oatpp::Enum::AsString(Enum2::NAME_1), true, e); OATPP_ASSERT(inter.getValueType() == oatpp::String::Class::getType()) @@ -197,11 +197,11 @@ void EnumTest::onRun() { auto value = voidValue.cast::AsString>(); OATPP_ASSERT(value == Enum2::NAME_1) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test Interpreter AsNumber (Qualified)...") + OATPP_LOGi(TAG, "Test Interpreter AsNumber (Qualified)...") oatpp::data::type::EnumInterpreterError e = oatpp::data::type::EnumInterpreterError::OK; auto inter = oatpp::Enum::AsNumber::Interpreter::toInterpretation(oatpp::Enum::AsNumber(Enum2::NAME_1), false, e); OATPP_ASSERT(inter.getValueType() == oatpp::Int32::Class::getType()) @@ -216,11 +216,11 @@ void EnumTest::onRun() { auto value = voidValue.cast::AsNumber>(); OATPP_ASSERT(value == Enum2::NAME_1) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test Interpreter AsNumber (Unualified)...") + OATPP_LOGi(TAG, "Test Interpreter AsNumber (Unualified)...") oatpp::data::type::EnumInterpreterError e = oatpp::data::type::EnumInterpreterError::OK; auto inter = oatpp::Enum::AsNumber::Interpreter::toInterpretation(oatpp::Enum::AsNumber(Enum2::NAME_1), true, e); OATPP_ASSERT(inter.getValueType() == oatpp::Int32::Class::getType()) @@ -235,11 +235,11 @@ void EnumTest::onRun() { auto value = voidValue.cast::AsNumber>(); OATPP_ASSERT(value == Enum2::NAME_1) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test default constructors and == operators...") + OATPP_LOGi(TAG, "Test default constructors and == operators...") oatpp::Enum::AsString e1; oatpp::Enum::AsString e2; @@ -261,11 +261,11 @@ void EnumTest::onRun() { OATPP_ASSERT(e1.getValueType() != e4.getValueType()) // Types are not equal because interpreters are different OATPP_ASSERT(e1.getValueType()->classId.id == e4.getValueType()->classId.id) // But classId is the same - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test value constructor and == operators...") + OATPP_LOGi(TAG, "Test value constructor and == operators...") oatpp::Enum e1(Enum2::NAME_1); oatpp::Enum e2(Enum2::NAME_1); oatpp::Enum e3; @@ -280,11 +280,11 @@ void EnumTest::onRun() { OATPP_ASSERT(e1 != Enum2::NAME_2) OATPP_ASSERT(e3 != Enum2::NAME_1) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test copy-assignment operator...") + OATPP_LOGi(TAG, "Test copy-assignment operator...") oatpp::Enum::AsString e1; oatpp::Enum::AsNumber e2(Enum2::NAME_1); Enum2 ve; @@ -320,11 +320,11 @@ void EnumTest::onRun() { OATPP_ASSERT(ve == Enum2::NAME_1) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test move-assignment operator...") + OATPP_LOGi(TAG, "Test move-assignment operator...") oatpp::Enum::AsString e1; oatpp::Enum::AsNumber e2(Enum2::NAME_1); @@ -335,7 +335,7 @@ void EnumTest::onRun() { OATPP_ASSERT(e1 == Enum2::NAME_1) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } diff --git a/test/oatpp/data/type/InterpretationTest.cpp b/test/oatpp/data/type/InterpretationTest.cpp index 3ae6d0e8..cd8cf00c 100644 --- a/test/oatpp/data/type/InterpretationTest.cpp +++ b/test/oatpp/data/type/InterpretationTest.cpp @@ -73,7 +73,7 @@ namespace __class { public: oatpp::Object interpret(const Point& value) const override { - OATPP_LOGD("Point::Interpretation", "interpret") + OATPP_LOGd("Point::Interpretation", "interpret") auto dto = PointDto::createShared(); dto->x = value->x; dto->y = value->y; @@ -82,7 +82,7 @@ namespace __class { } Point reproduce(const oatpp::Object& value) const override { - OATPP_LOGD("Point::Interpretation", "reproduce") + OATPP_LOGd("Point::Interpretation", "reproduce") return Point({value->x, value->y, value->z}); } @@ -127,7 +127,7 @@ namespace __class { public: oatpp::Object interpret(const Line& value) const override { - OATPP_LOGD("Line::Interpretation", "interpret") + OATPP_LOGd("Line::Interpretation", "interpret") auto dto = LineDto::createShared(); dto->p1 = {value->p1.x, value->p1.y, value->p1.z}; dto->p2 = {value->p2.x, value->p2.y, value->p2.z}; @@ -135,7 +135,7 @@ namespace __class { } Line reproduce(const oatpp::Object& value) const override { - OATPP_LOGD("Line::Interpretation", "reproduce") + OATPP_LOGd("Line::Interpretation", "reproduce") return Line({{value->p1->x, value->p1->y, value->p1->z}, {value->p2->x, value->p2->y, value->p2->z}}); } @@ -193,13 +193,13 @@ void InterpretationTest::onRun() { auto json1 = mapper.writeToString(l); - OATPP_LOGD(TAG, "json1='%s'", json1->c_str()) + OATPP_LOGd(TAG, "json1='{}'", json1) auto rl = mapper.readFromString(json1); auto json2 = mapper.writeToString(rl); - OATPP_LOGD(TAG, "json2='%s'", json2->c_str()) + OATPP_LOGd(TAG, "json2='{}'", json2) OATPP_ASSERT(json1 == json2) diff --git a/test/oatpp/data/type/ListTest.cpp b/test/oatpp/data/type/ListTest.cpp index e0bc40cf..fb328615 100644 --- a/test/oatpp/data/type/ListTest.cpp +++ b/test/oatpp/data/type/ListTest.cpp @@ -31,7 +31,7 @@ namespace oatpp { namespace data { namespace type { void ListTest::onRun() { { - OATPP_LOGI(TAG, "test default constructor...") + OATPP_LOGi(TAG, "test default constructor...") oatpp::List list; OATPP_ASSERT(!list) @@ -41,11 +41,11 @@ void ListTest::onRun() { OATPP_ASSERT(list.getValueType()->classId.id == oatpp::data::type::__class::AbstractList::CLASS_ID.id) OATPP_ASSERT(list.getValueType()->params.size() == 1) OATPP_ASSERT(list.getValueType()->params.front() == oatpp::String::Class::getType()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test empty ilist constructor...") + OATPP_LOGi(TAG, "test empty ilist constructor...") oatpp::List list({}); OATPP_ASSERT(list) @@ -56,11 +56,11 @@ void ListTest::onRun() { OATPP_ASSERT(list.getValueType()->classId.id == oatpp::data::type::__class::AbstractList::CLASS_ID.id) OATPP_ASSERT(list.getValueType()->params.size() == 1) OATPP_ASSERT(list.getValueType()->params.front() == oatpp::String::Class::getType()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test createShared()...") + OATPP_LOGi(TAG, "test createShared()...") oatpp::List list = oatpp::List::createShared(); OATPP_ASSERT(list) @@ -69,11 +69,11 @@ void ListTest::onRun() { OATPP_ASSERT(list.get() != nullptr) OATPP_ASSERT(list.getValueType()->classId.id == oatpp::data::type::__class::AbstractList::CLASS_ID.id) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test copy-assignment operator...") + OATPP_LOGi(TAG, "test copy-assignment operator...") oatpp::List list1({}); oatpp::List list2; @@ -99,11 +99,11 @@ void ListTest::onRun() { OATPP_ASSERT(list2[0] == "b") OATPP_ASSERT(list2[1] == "c") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test move-assignment operator...") + OATPP_LOGi(TAG, "test move-assignment operator...") oatpp::List list1({}); oatpp::List list2; @@ -111,11 +111,11 @@ void ListTest::onRun() { OATPP_ASSERT(!list1) OATPP_ASSERT(list2) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test get element by index...") + OATPP_LOGi(TAG, "test get element by index...") oatpp::List list = {"a", "b", "c"}; OATPP_ASSERT(list) @@ -133,11 +133,11 @@ void ListTest::onRun() { OATPP_ASSERT(list[0] == "a") OATPP_ASSERT(list[1] == "Hello!") OATPP_ASSERT(list[2] == "c") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test polymorphicDispatcher...") + OATPP_LOGi(TAG, "test polymorphicDispatcher...") oatpp::List list = {"a", "b", "c"}; auto polymorphicDispatcher = static_cast( @@ -152,7 +152,7 @@ void ListTest::onRun() { OATPP_ASSERT(list[1] == "b") OATPP_ASSERT(list[2] == "c") OATPP_ASSERT(list[3] == "d") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } } diff --git a/test/oatpp/data/type/ObjectTest.cpp b/test/oatpp/data/type/ObjectTest.cpp index d8e352a8..26a86b57 100644 --- a/test/oatpp/data/type/ObjectTest.cpp +++ b/test/oatpp/data/type/ObjectTest.cpp @@ -197,7 +197,7 @@ void ObjectTest::onRun() { } { - OATPP_LOGI(TAG, "Test Meta 1...") + OATPP_LOGi(TAG, "Test Meta 1...") auto type = Object::Class::getType(); auto dispatcher = static_cast(type->polymorphicDispatcher); @@ -210,11 +210,11 @@ void ObjectTest::onRun() { OATPP_ASSERT(it->second->info.description == "identifier") OATPP_ASSERT(it->second->info.pattern == "^[a-z0-9]+$") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test Meta 2...") + OATPP_LOGi(TAG, "Test Meta 2...") auto type = Object::Class::getType(); auto dispatcher = static_cast(type->polymorphicDispatcher); @@ -234,28 +234,28 @@ void ObjectTest::onRun() { OATPP_ASSERT(it->second->info.description == "some field with a qualified name") } - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test 1...") + OATPP_LOGi(TAG, "Test 1...") Object a; OATPP_ASSERT(!a) OATPP_ASSERT(a == nullptr) OATPP_ASSERT(a.getValueType()->classId.id == oatpp::data::type::__class::AbstractObject::CLASS_ID.id) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test 2...") + OATPP_LOGi(TAG, "Test 2...") Object a; Object b; OATPP_ASSERT(a == b) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test 3...") + OATPP_LOGi(TAG, "Test 3...") auto a = DtoA::createShared(); Object b; OATPP_ASSERT(a != b) @@ -263,20 +263,20 @@ void ObjectTest::onRun() { auto ohc = a->hashCode(); auto whc = std::hash>{}(a); OATPP_ASSERT(ohc == whc) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test 4...") + OATPP_LOGi(TAG, "Test 4...") auto a = Dto0::createShared(); auto b = Dto0::createShared(); OATPP_ASSERT(a != b) OATPP_ASSERT(a->hashCode() != b->hashCode()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test 5...") + OATPP_LOGi(TAG, "Test 5...") auto a = DtoA::createShared(); auto b = DtoA::createShared(); @@ -292,11 +292,11 @@ void ObjectTest::onRun() { OATPP_ASSERT(a == b) OATPP_ASSERT(a->hashCode() == b->hashCode()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test 6...") + OATPP_LOGi(TAG, "Test 6...") auto a = DtoB::createShared(); auto b = DtoB::createShared(); @@ -318,11 +318,11 @@ void ObjectTest::onRun() { OATPP_ASSERT(a == b) OATPP_ASSERT(a->hashCode() == b->hashCode()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test 7...") + OATPP_LOGi(TAG, "Test 7...") auto a = DtoC::createShared(); auto b = DtoC::createShared(); @@ -346,11 +346,11 @@ void ObjectTest::onRun() { OATPP_ASSERT(a == b) OATPP_ASSERT(a->hashCode() == b->hashCode()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test 8...") + OATPP_LOGi(TAG, "Test 8...") auto a = DtoB::createShared(); auto b = DtoB::createShared(); auto c = DtoB::createShared(); @@ -374,20 +374,20 @@ void ObjectTest::onRun() { OATPP_ASSERT(set[c] == true) OATPP_ASSERT(set[d] == true) OATPP_ASSERT(set[e] == true) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test 9...") + OATPP_LOGi(TAG, "Test 9...") auto dto = DtoD::createShared(); OATPP_ASSERT(dto->a.getValueType() == oatpp::Int32::Class::getType()) OATPP_ASSERT(dto->a) OATPP_ASSERT(dto->a == 64) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test 10...") + OATPP_LOGi(TAG, "Test 10...") OATPP_ASSERT(oatpp::Object::Class::getType()->extends(oatpp::Object::Class::getType())) OATPP_ASSERT(oatpp::Object::Class::getType()->extends(oatpp::Object::Class::getType())) OATPP_ASSERT(oatpp::Object::Class::getType()->extends(oatpp::Object::Class::getType())) @@ -395,11 +395,11 @@ void ObjectTest::onRun() { OATPP_ASSERT(oatpp::Object::Class::getType()->extends(oatpp::Object::Class::getType())) OATPP_ASSERT(oatpp::Object::Class::getType()->extends(oatpp::Object::Class::getType())) OATPP_ASSERT(!oatpp::Object::Class::getType()->extends(oatpp::Object::Class::getType())) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test 11...") + OATPP_LOGi(TAG, "Test 11...") auto map = oatpp::Object::getPropertiesMap(); auto p = map["polymorph"]; @@ -407,11 +407,11 @@ void ObjectTest::onRun() { OATPP_ASSERT(p->info.description == "") OATPP_ASSERT(p->info.typeSelector != nullptr) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test 12...") + OATPP_LOGi(TAG, "Test 12...") auto map = oatpp::Object::getPropertiesMap(); auto p = map["polymorph"]; @@ -419,11 +419,11 @@ void ObjectTest::onRun() { OATPP_ASSERT(p->info.description == "description") OATPP_ASSERT(p->info.typeSelector != nullptr) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test 13...") + OATPP_LOGi(TAG, "Test 13...") auto dto = oatpp::Object::createShared(); OATPP_ASSERT(dto->type == nullptr) @@ -435,11 +435,11 @@ void ObjectTest::onRun() { OATPP_ASSERT(dto->type == "hello") OATPP_ASSERT(dto->type.getValueType() == oatpp::String::Class::getType()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test 14...") + OATPP_LOGi(TAG, "Test 14...") auto dto = oatpp::Object::createShared(); bool thrown = false; @@ -447,17 +447,17 @@ void ObjectTest::onRun() { try{ dto["type"] = oatpp::Int32(32); } catch(std::runtime_error const& e) { - OATPP_LOGD(TAG, "error='%s'", e.what()) + OATPP_LOGd(TAG, "error='{}'", e.what()) thrown = true; } OATPP_ASSERT(thrown) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test 15...") + OATPP_LOGi(TAG, "Test 15...") auto dto = oatpp::Object::createShared(); bool thrown = false; @@ -465,17 +465,17 @@ void ObjectTest::onRun() { try{ dto["non-existing"]; } catch(std::out_of_range const& e) { - OATPP_LOGD(TAG, "error='%s'", e.what()) + OATPP_LOGd(TAG, "error='{}'", e.what()) thrown = true; } OATPP_ASSERT(thrown) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test 16...") + OATPP_LOGi(TAG, "Test 16...") oatpp::json::ObjectMapper mapper; @@ -487,12 +487,12 @@ void ObjectTest::onRun() { OATPP_ASSERT(dto->polymorph.getValueType() == oatpp::Any::Class::getType()) auto json = mapper.writeToString(dto); - OATPP_LOGD(TAG, "json0='%s'", json->c_str()) + OATPP_LOGd(TAG, "json0='{}'", json) auto dtoClone = mapper.readFromString>(json); auto jsonClone = mapper.writeToString(dtoClone); - OATPP_LOGD(TAG, "json1='%s'", jsonClone->c_str()) + OATPP_LOGd(TAG, "json1='{}'", jsonClone) OATPP_ASSERT(json == jsonClone) @@ -503,11 +503,11 @@ void ObjectTest::onRun() { OATPP_ASSERT(polymorphClone->fieldA == "type-A") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test 17...") + OATPP_LOGi(TAG, "Test 17...") oatpp::json::ObjectMapper mapper; @@ -519,12 +519,12 @@ void ObjectTest::onRun() { OATPP_ASSERT(dto->polymorph.getValueType() == oatpp::Any::Class::getType()) auto json = mapper.writeToString(dto); - OATPP_LOGD(TAG, "json0='%s'", json->c_str()) + OATPP_LOGd(TAG, "json0='{}'", json) auto dtoClone = mapper.readFromString>(json); auto jsonClone = mapper.writeToString(dtoClone); - OATPP_LOGD(TAG, "json1='%s'", jsonClone->c_str()) + OATPP_LOGd(TAG, "json1='{}'", jsonClone) OATPP_ASSERT(json == jsonClone) @@ -535,11 +535,11 @@ void ObjectTest::onRun() { OATPP_ASSERT(polymorphClone == "Hello World!") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test 18...") + OATPP_LOGi(TAG, "Test 18...") oatpp::json::ObjectMapper mapper; @@ -551,12 +551,12 @@ void ObjectTest::onRun() { OATPP_ASSERT(dto->polymorph.getValueType() == oatpp::Any::Class::getType()) auto json = mapper.writeToString(dto); - OATPP_LOGD(TAG, "json0='%s'", json->c_str()) + OATPP_LOGd(TAG, "json0='{}'", json) auto dtoClone = mapper.readFromString>(json); auto jsonClone = mapper.writeToString(dtoClone); - OATPP_LOGD(TAG, "json1='%s'", jsonClone->c_str()) + OATPP_LOGd(TAG, "json1='{}'", jsonClone) OATPP_ASSERT(json == jsonClone) @@ -569,7 +569,7 @@ void ObjectTest::onRun() { OATPP_ASSERT(polymorphClone == nullptr) OATPP_ASSERT(polymorphClone.getValueType() == oatpp::String::Class::getType()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } } diff --git a/test/oatpp/data/type/ObjectWrapperTest.cpp b/test/oatpp/data/type/ObjectWrapperTest.cpp index 214564f3..6244790f 100644 --- a/test/oatpp/data/type/ObjectWrapperTest.cpp +++ b/test/oatpp/data/type/ObjectWrapperTest.cpp @@ -37,50 +37,50 @@ namespace { void ObjectWrapperTest::onRun() { { - OATPP_LOGI(TAG, "Check default valueType is assigned (default tparam Clazz)...") + OATPP_LOGi(TAG, "Check default valueType is assigned (default tparam Clazz)...") TestWrapper pw; OATPP_ASSERT(!pw) OATPP_ASSERT(pw == nullptr) OATPP_ASSERT(pw.getValueType() == oatpp::data::type::__class::Void::getType()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Check default valueType is assigned (specified tparam Clazz)...") + OATPP_LOGi(TAG, "Check default valueType is assigned (specified tparam Clazz)...") TestWrapper pw; OATPP_ASSERT(!pw) OATPP_ASSERT(pw == nullptr) OATPP_ASSERT(pw.getValueType() == oatpp::data::type::__class::String::getType()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Check valueType is assigned from constructor...") + OATPP_LOGi(TAG, "Check valueType is assigned from constructor...") TestWrapper pw(oatpp::data::type::__class::String::getType()); OATPP_ASSERT(!pw) OATPP_ASSERT(pw == nullptr) OATPP_ASSERT(pw.getValueType() == oatpp::data::type::__class::String::getType()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Check valueType is assigned from copy constructor...") + OATPP_LOGi(TAG, "Check valueType is assigned from copy constructor...") TestWrapper pw1(oatpp::data::type::__class::String::getType()); TestWrapper pw2(pw1); OATPP_ASSERT(pw2.getValueType() == oatpp::data::type::__class::String::getType()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Check valueType is assigned from move constructor...") + OATPP_LOGi(TAG, "Check valueType is assigned from move constructor...") TestWrapper pw1(oatpp::data::type::__class::String::getType()); TestWrapper pw2(std::move(pw1)); OATPP_ASSERT(pw2.getValueType() == oatpp::data::type::__class::String::getType()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Check valueType is NOT assigned from copy-assign operator...") + OATPP_LOGi(TAG, "Check valueType is NOT assigned from copy-assign operator...") TestWrapper pw1(oatpp::data::type::__class::String::getType()); TestWrapper pw2; bool throws = false; @@ -91,11 +91,11 @@ void ObjectWrapperTest::onRun() { } OATPP_ASSERT(pw2.getValueType() == oatpp::data::type::__class::Void::getType()) OATPP_ASSERT(throws) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Check valueType is NOT assigned from move-assign operator...") + OATPP_LOGi(TAG, "Check valueType is NOT assigned from move-assign operator...") TestWrapper pw1(oatpp::data::type::__class::String::getType()); TestWrapper pw2; bool throws = false; @@ -106,11 +106,11 @@ void ObjectWrapperTest::onRun() { } OATPP_ASSERT(pw2.getValueType() == oatpp::data::type::__class::Void::getType()) OATPP_ASSERT(throws) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Check copy-assign operator. Check == operator...") + OATPP_LOGi(TAG, "Check copy-assign operator. Check == operator...") TestWrapper pw1; OATPP_ASSERT(!pw1) OATPP_ASSERT(pw1 == nullptr) @@ -131,11 +131,11 @@ void ObjectWrapperTest::onRun() { OATPP_ASSERT(pw1 == pw2) OATPP_ASSERT(pw1.get() == pw2.get()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Check != operator...") + OATPP_LOGi(TAG, "Check != operator...") TestWrapper pw1(std::make_shared("Hello!")); OATPP_ASSERT(pw1) OATPP_ASSERT(pw1 != nullptr) @@ -148,11 +148,11 @@ void ObjectWrapperTest::onRun() { OATPP_ASSERT(pw1 != pw2) OATPP_ASSERT(pw1.get() != pw2.get()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Check move-assign operator. Check != operator...") + OATPP_LOGi(TAG, "Check move-assign operator. Check != operator...") TestWrapper pw1; OATPP_ASSERT(!pw1) OATPP_ASSERT(pw1 == nullptr) @@ -173,11 +173,11 @@ void ObjectWrapperTest::onRun() { OATPP_ASSERT(pw1 != pw2) OATPP_ASSERT(pw1.get() != pw2.get()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Check oatpp::Void type reassigned") + OATPP_LOGi(TAG, "Check oatpp::Void type reassigned") oatpp::Void v; v = oatpp::String("test"); diff --git a/test/oatpp/data/type/PairListTest.cpp b/test/oatpp/data/type/PairListTest.cpp index d1c57146..b0cebd9b 100644 --- a/test/oatpp/data/type/PairListTest.cpp +++ b/test/oatpp/data/type/PairListTest.cpp @@ -31,7 +31,7 @@ namespace oatpp { namespace data { namespace type { void PairListTest::onRun() { { - OATPP_LOGI(TAG, "test default constructor...") + OATPP_LOGi(TAG, "test default constructor...") oatpp::Fields map; OATPP_ASSERT(!map) @@ -43,11 +43,11 @@ void PairListTest::onRun() { auto it = map.getValueType()->params.begin(); OATPP_ASSERT(*it++ == oatpp::String::Class::getType()) OATPP_ASSERT(*it++ == oatpp::String::Class::getType()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test empty ilist constructor...") + OATPP_LOGi(TAG, "test empty ilist constructor...") oatpp::Fields map({}); OATPP_ASSERT(map) @@ -60,11 +60,11 @@ void PairListTest::onRun() { auto it = map.getValueType()->params.begin(); OATPP_ASSERT(*it++ == oatpp::String::Class::getType()) OATPP_ASSERT(*it++ == oatpp::String::Class::getType()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test createShared()...") + OATPP_LOGi(TAG, "test createShared()...") oatpp::Fields map = oatpp::Fields::createShared(); OATPP_ASSERT(map) @@ -73,11 +73,11 @@ void PairListTest::onRun() { OATPP_ASSERT(map.get() != nullptr) OATPP_ASSERT(map.getValueType()->classId.id == oatpp::data::type::__class::AbstractPairList::CLASS_ID.id) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test copy-assignment operator...") + OATPP_LOGi(TAG, "test copy-assignment operator...") oatpp::Fields map1({}); oatpp::Fields map2; @@ -107,11 +107,11 @@ void PairListTest::onRun() { OATPP_ASSERT(map2.getValueByKey("key2") == "c") OATPP_ASSERT(map2.getValueByKey("key3") == nullptr) OATPP_ASSERT(map2.getValueByKey("key3", "default-val") == "default-val") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test move-assignment operator...") + OATPP_LOGi(TAG, "test move-assignment operator...") oatpp::Fields map1({}); oatpp::Fields map2; @@ -119,11 +119,11 @@ void PairListTest::onRun() { OATPP_ASSERT(!map1) OATPP_ASSERT(map2) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test get element by index...") + OATPP_LOGi(TAG, "test get element by index...") oatpp::Fields map = {{"key1", "a"}, {"key2", "b"}, {"key3", "c"}}; OATPP_ASSERT(map) @@ -141,11 +141,11 @@ void PairListTest::onRun() { OATPP_ASSERT(map["key1"] == "a") OATPP_ASSERT(map["key2"] == "Hello!") OATPP_ASSERT(map["key3"] == "c") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test polymorphicDispatcher...") + OATPP_LOGi(TAG, "test polymorphicDispatcher...") oatpp::Fields map = {{"key1", "a"}, {"key2", "b"}, {"key3", "c"}}; auto polymorphicDispatcher = static_cast( @@ -160,7 +160,7 @@ void PairListTest::onRun() { OATPP_ASSERT(map[1].first == "key2" && map[1].second == "b") OATPP_ASSERT(map[2].first == "key3" && map[2].second == "c") OATPP_ASSERT(map[3].first == "key1" && map[3].second == "d") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } } diff --git a/test/oatpp/data/type/PrimitiveTest.cpp b/test/oatpp/data/type/PrimitiveTest.cpp index 5dd3f7c4..121d70be 100644 --- a/test/oatpp/data/type/PrimitiveTest.cpp +++ b/test/oatpp/data/type/PrimitiveTest.cpp @@ -33,7 +33,7 @@ namespace { template void checkHash(const T& val) { auto h = std::hash{}(val); - OATPP_LOGI("HASH", "type='%s', hash=%lu", val.getValueType()->classId.name, h) + OATPP_LOGi("HASH", "type='{}', hash={}", val.getValueType()->classId.name, h) } } @@ -55,36 +55,36 @@ void PrimitiveTest::onRun() { } { - OATPP_LOGI(TAG, "test default constructor") + OATPP_LOGi(TAG, "test default constructor") oatpp::Int32 i; OATPP_ASSERT(!i) OATPP_ASSERT(i == nullptr) OATPP_ASSERT(i.getValueType() == oatpp::Int32::Class::getType()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test value constructor") + OATPP_LOGi(TAG, "test value constructor") oatpp::Int32 i(0); OATPP_ASSERT(i) OATPP_ASSERT(i != nullptr) OATPP_ASSERT(i == 0) OATPP_ASSERT(i.getValueType() == oatpp::Int32::Class::getType()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test implicit value constructor") + OATPP_LOGi(TAG, "test implicit value constructor") oatpp::Int32 i = 0; OATPP_ASSERT(i) OATPP_ASSERT(i != nullptr) OATPP_ASSERT(i == 0) OATPP_ASSERT(i.getValueType() == oatpp::Int32::Class::getType()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test '==' and '!=' operators") + OATPP_LOGi(TAG, "test '==' and '!=' operators") oatpp::Int32 i1 = 0; oatpp::Int32 i2; @@ -109,11 +109,11 @@ void PrimitiveTest::onRun() { OATPP_ASSERT(i1 == i2) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test copy-assign operator") + OATPP_LOGi(TAG, "test copy-assign operator") oatpp::Int32 i1 = 0; oatpp::Int32 i2; @@ -134,7 +134,7 @@ void PrimitiveTest::onRun() { } { - OATPP_LOGI(TAG, "test move-assign operator") + OATPP_LOGi(TAG, "test move-assign operator") oatpp::Int32 i1 = 0; oatpp::Int32 i2; @@ -149,58 +149,58 @@ void PrimitiveTest::onRun() { } { - OATPP_LOGI(TAG, "test move-assign operator") + OATPP_LOGi(TAG, "test move-assign operator") oatpp::Int32 i = 0; v_int32 v = i; OATPP_ASSERT(v == i) } { - OATPP_LOGI(TAG, "Test Boolean [nullptr]") + OATPP_LOGi(TAG, "Test Boolean [nullptr]") oatpp::Boolean b; OATPP_ASSERT(!b) OATPP_ASSERT(b == nullptr) OATPP_ASSERT(b != false) OATPP_ASSERT(b != true) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test Boolean nullptr constructor") + OATPP_LOGi(TAG, "Test Boolean nullptr constructor") oatpp::Boolean b = nullptr; OATPP_ASSERT(!b) OATPP_ASSERT(b == nullptr) OATPP_ASSERT(b != false) OATPP_ASSERT(b != true) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test Boolean [false]") + OATPP_LOGi(TAG, "Test Boolean [false]") oatpp::Boolean b = false; OATPP_ASSERT(!b) // <--- still !b OATPP_ASSERT(b != nullptr) OATPP_ASSERT(b == false) OATPP_ASSERT(b != true) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test Boolean [true]") + OATPP_LOGi(TAG, "Test Boolean [true]") oatpp::Boolean b = true; OATPP_ASSERT(b) OATPP_ASSERT(b != nullptr) OATPP_ASSERT(b != false) OATPP_ASSERT(b == true) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test Boolean copy-assign operator") + OATPP_LOGi(TAG, "Test Boolean copy-assign operator") oatpp::Boolean b1 = true; oatpp::Boolean b2; @@ -228,11 +228,11 @@ void PrimitiveTest::onRun() { OATPP_ASSERT(b1 == b2) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Test Boolean move-assign operator") + OATPP_LOGi(TAG, "Test Boolean move-assign operator") oatpp::Boolean b1 = true; oatpp::Boolean b2; @@ -241,11 +241,11 @@ void PrimitiveTest::onRun() { OATPP_ASSERT(b2 != nullptr) OATPP_ASSERT(b1 == nullptr) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "check default value") + OATPP_LOGi(TAG, "check default value") oatpp::UInt8 s0; oatpp::UInt8 s1 = 255; OATPP_ASSERT(s0.getValue(128) == 128) diff --git a/test/oatpp/data/type/StringTest.cpp b/test/oatpp/data/type/StringTest.cpp index 0d1f10e6..e7853b8f 100644 --- a/test/oatpp/data/type/StringTest.cpp +++ b/test/oatpp/data/type/StringTest.cpp @@ -38,37 +38,37 @@ void StringTest::onRun() { } { - OATPP_LOGI(TAG, "test default constructor") + OATPP_LOGi(TAG, "test default constructor") oatpp::String s; OATPP_ASSERT(!s) OATPP_ASSERT(s == nullptr) OATPP_ASSERT(s == static_cast(nullptr)) OATPP_ASSERT(s.getValueType() == oatpp::String::Class::getType()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test nullptr constructor") + OATPP_LOGi(TAG, "test nullptr constructor") oatpp::String s(nullptr); OATPP_ASSERT(!s) OATPP_ASSERT(s == nullptr) OATPP_ASSERT(s.getValueType() == oatpp::String::Class::getType()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test const char* constructor") + OATPP_LOGi(TAG, "test const char* constructor") oatpp::String s("abc\0xyz"); OATPP_ASSERT(s) OATPP_ASSERT(s != nullptr) OATPP_ASSERT(s->size() == 3) OATPP_ASSERT(s == "abc") OATPP_ASSERT(s == "abc\0xyz") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test std::string constructor") + OATPP_LOGi(TAG, "test std::string constructor") std::string a("abc\0xyz", 7); oatpp::String s(a); OATPP_ASSERT(s) @@ -78,11 +78,11 @@ void StringTest::onRun() { OATPP_ASSERT(s != "abc\0xyz") OATPP_ASSERT(s == std::string("abc\0xyz", 7)) OATPP_ASSERT(s == a) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test std::string move constructor") + OATPP_LOGi(TAG, "test std::string move constructor") std::string a("abc\0xyz", 7); oatpp::String s(std::move(a)); OATPP_ASSERT(s) @@ -92,11 +92,11 @@ void StringTest::onRun() { OATPP_ASSERT(s != "abc\0xyz") OATPP_ASSERT(s == std::string("abc\0xyz", 7)) OATPP_ASSERT(a == "") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test const char* assign operator") + OATPP_LOGi(TAG, "test const char* assign operator") oatpp::String s; s = "abc\0xyz"; OATPP_ASSERT(s) @@ -104,11 +104,11 @@ void StringTest::onRun() { OATPP_ASSERT(s->size() == 3) OATPP_ASSERT(s == "abc") OATPP_ASSERT(s == "abc\0xyz") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test std::string assign operator") + OATPP_LOGi(TAG, "test std::string assign operator") oatpp::String s; std::string a = std::string("abc\0xyz", 7); s = a; @@ -119,11 +119,11 @@ void StringTest::onRun() { OATPP_ASSERT(s != "abc\0xyz") OATPP_ASSERT(s == std::string("abc\0xyz", 7)) OATPP_ASSERT(s == a) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test std::string move assign operator") + OATPP_LOGi(TAG, "test std::string move assign operator") oatpp::String s; std::string a = std::string("abc\0xyz", 7); s = std::move(a); @@ -134,20 +134,20 @@ void StringTest::onRun() { OATPP_ASSERT(s != "abc\0xyz") OATPP_ASSERT(s == std::string("abc\0xyz", 7)) OATPP_ASSERT(a == "") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test const char* implicit constructor") + OATPP_LOGi(TAG, "test const char* implicit constructor") oatpp::String s = ""; OATPP_ASSERT(s) OATPP_ASSERT(s != nullptr) OATPP_ASSERT(s->size() == 0) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test '==', '!=' operators") + OATPP_LOGi(TAG, "test '==', '!=' operators") oatpp::String s1 = "a"; oatpp::String s2; @@ -162,11 +162,11 @@ void StringTest::onRun() { OATPP_ASSERT(s1 != s2) OATPP_ASSERT(s2 != s1) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test copy-asssign operator") + OATPP_LOGi(TAG, "test copy-asssign operator") oatpp::String s1 = "s1"; oatpp::String s2; @@ -179,11 +179,11 @@ void StringTest::onRun() { OATPP_ASSERT(s1 != s2) OATPP_ASSERT(s2 != s1) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test const char* assign operator") + OATPP_LOGi(TAG, "test const char* assign operator") oatpp::String s1 = "s1"; oatpp::String s2(s1); @@ -194,11 +194,11 @@ void StringTest::onRun() { OATPP_ASSERT(s1 != s2) OATPP_ASSERT(s2 != s1) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test move assign operator") + OATPP_LOGi(TAG, "test move assign operator") oatpp::String s1 = "s1"; oatpp::String s2; @@ -210,11 +210,11 @@ void StringTest::onRun() { OATPP_ASSERT(s1 != s2) OATPP_ASSERT(s1.get() != s2.get()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test compareCI_ASCII methods 1") + OATPP_LOGi(TAG, "test compareCI_ASCII methods 1") oatpp::String s1 = "hello"; @@ -231,7 +231,7 @@ void StringTest::onRun() { } { - OATPP_LOGI(TAG, "test compareCI_ASCII methods 2") + OATPP_LOGi(TAG, "test compareCI_ASCII methods 2") oatpp::String s1; @@ -281,7 +281,7 @@ void StringTest::onRun() { } { - OATPP_LOGI(TAG, "test compareCI_ASCII methods 3") + OATPP_LOGi(TAG, "test compareCI_ASCII methods 3") oatpp::String s1 = "hello"; @@ -307,7 +307,7 @@ void StringTest::onRun() { } { - OATPP_LOGI(TAG, "check default value") + OATPP_LOGi(TAG, "check default value") oatpp::String s0; oatpp::String s1 = "hello"; OATPP_ASSERT(s0.getValue("def") == "def") diff --git a/test/oatpp/data/type/TypeTest.cpp b/test/oatpp/data/type/TypeTest.cpp index df5e4a43..ab714b93 100644 --- a/test/oatpp/data/type/TypeTest.cpp +++ b/test/oatpp/data/type/TypeTest.cpp @@ -67,52 +67,52 @@ void TypeTest::onRun() { auto obj = TestDto::createShared(); - OATPP_LOGV(TAG, "type: '%s'", obj->field_string.getValueType()->classId.name) + OATPP_LOGv(TAG, "type: '{}'", obj->field_string.getValueType()->classId.name) OATPP_ASSERT(obj->field_string.getValueType()->classId == oatpp::data::type::__class::String::CLASS_ID) - OATPP_LOGV(TAG, "type: '%s'", obj->field_int8.getValueType()->classId.name) + OATPP_LOGv(TAG, "type: '{}'", obj->field_int8.getValueType()->classId.name) OATPP_ASSERT(obj->field_int8.getValueType()->classId == oatpp::data::type::__class::Int8::CLASS_ID) - OATPP_LOGV(TAG, "type: '%s'", obj->field_int16.getValueType()->classId.name) + OATPP_LOGv(TAG, "type: '{}'", obj->field_int16.getValueType()->classId.name) OATPP_ASSERT(obj->field_int16.getValueType()->classId == oatpp::data::type::__class::Int16::CLASS_ID) - OATPP_LOGV(TAG, "type: '%s'", obj->field_int32.getValueType()->classId.name) + OATPP_LOGv(TAG, "type: '{}'", obj->field_int32.getValueType()->classId.name) OATPP_ASSERT(obj->field_int32.getValueType()->classId == oatpp::data::type::__class::Int32::CLASS_ID) - OATPP_LOGV(TAG, "type: '%s'", obj->field_int64.getValueType()->classId.name) + OATPP_LOGv(TAG, "type: '{}'", obj->field_int64.getValueType()->classId.name) OATPP_ASSERT(obj->field_int64.getValueType()->classId == oatpp::data::type::__class::Int64::CLASS_ID) - OATPP_LOGV(TAG, "type: '%s'", obj->field_float32.getValueType()->classId.name) + OATPP_LOGv(TAG, "type: '{}'", obj->field_float32.getValueType()->classId.name) OATPP_ASSERT(obj->field_float32.getValueType()->classId == oatpp::data::type::__class::Float32::CLASS_ID) - OATPP_LOGV(TAG, "type: '%s'", obj->field_float64.getValueType()->classId.name) + OATPP_LOGv(TAG, "type: '{}'", obj->field_float64.getValueType()->classId.name) OATPP_ASSERT(obj->field_float64.getValueType()->classId == oatpp::data::type::__class::Float64::CLASS_ID) - OATPP_LOGV(TAG, "type: '%s'", obj->field_boolean.getValueType()->classId.name) + OATPP_LOGv(TAG, "type: '{}'", obj->field_boolean.getValueType()->classId.name) OATPP_ASSERT(obj->field_boolean.getValueType()->classId == oatpp::data::type::__class::Boolean::CLASS_ID) - OATPP_LOGV(TAG, "type: '%s'", obj->field_list_string.getValueType()->classId.name) + OATPP_LOGv(TAG, "type: '{}'", obj->field_list_string.getValueType()->classId.name) OATPP_ASSERT(obj->field_list_string.getValueType()->classId == oatpp::data::type::__class::AbstractList::CLASS_ID) - OATPP_LOGV(TAG, "type: '%s'", obj->field_list_int32.getValueType()->classId.name) + OATPP_LOGv(TAG, "type: '{}'", obj->field_list_int32.getValueType()->classId.name) OATPP_ASSERT(obj->field_list_int32.getValueType()->classId == oatpp::data::type::__class::AbstractList::CLASS_ID) - OATPP_LOGV(TAG, "type: '%s'", obj->field_list_int64.getValueType()->classId.name) + OATPP_LOGv(TAG, "type: '{}'", obj->field_list_int64.getValueType()->classId.name) OATPP_ASSERT(obj->field_list_int64.getValueType()->classId == oatpp::data::type::__class::AbstractList::CLASS_ID) - OATPP_LOGV(TAG, "type: '%s'", obj->field_list_float32.getValueType()->classId.name) + OATPP_LOGv(TAG, "type: '{}'", obj->field_list_float32.getValueType()->classId.name) OATPP_ASSERT(obj->field_list_float32.getValueType()->classId == oatpp::data::type::__class::AbstractList::CLASS_ID) - OATPP_LOGV(TAG, "type: '%s'", obj->field_list_float64.getValueType()->classId.name) + OATPP_LOGv(TAG, "type: '{}'", obj->field_list_float64.getValueType()->classId.name) OATPP_ASSERT(obj->field_list_float64.getValueType()->classId == oatpp::data::type::__class::AbstractList::CLASS_ID) - OATPP_LOGV(TAG, "type: '%s'", obj->field_list_boolean.getValueType()->classId.name) + OATPP_LOGv(TAG, "type: '{}'", obj->field_list_boolean.getValueType()->classId.name) OATPP_ASSERT(obj->field_list_boolean.getValueType()->classId == oatpp::data::type::__class::AbstractList::CLASS_ID) - OATPP_LOGV(TAG, "type: '%s'", obj->field_map_string_string.getValueType()->classId.name) + OATPP_LOGv(TAG, "type: '{}'", obj->field_map_string_string.getValueType()->classId.name) OATPP_ASSERT(obj->field_map_string_string.getValueType()->classId == oatpp::data::type::__class::AbstractPairList::CLASS_ID) - OATPP_LOGV(TAG, "type: '%s'", obj->obj1.getValueType()->classId.name) + OATPP_LOGv(TAG, "type: '{}'", obj->obj1.getValueType()->classId.name) OATPP_ASSERT(obj->obj1.getValueType()->classId == oatpp::data::type::__class::AbstractObject::CLASS_ID) OATPP_ASSERT(oatpp::String::Class::getType()->extends(oatpp::String::Class::getType())) diff --git a/test/oatpp/data/type/UnorderedMapTest.cpp b/test/oatpp/data/type/UnorderedMapTest.cpp index f4851a20..758e8ed2 100644 --- a/test/oatpp/data/type/UnorderedMapTest.cpp +++ b/test/oatpp/data/type/UnorderedMapTest.cpp @@ -31,7 +31,7 @@ namespace oatpp { namespace data { namespace type { void UnorderedMapTest::onRun() { { - OATPP_LOGI(TAG, "test default constructor...") + OATPP_LOGi(TAG, "test default constructor...") oatpp::UnorderedFields map; OATPP_ASSERT(!map) @@ -43,11 +43,11 @@ void UnorderedMapTest::onRun() { auto it = map.getValueType()->params.begin(); OATPP_ASSERT(*it++ == oatpp::String::Class::getType()) OATPP_ASSERT(*it++ == oatpp::String::Class::getType()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test empty ilist constructor...") + OATPP_LOGi(TAG, "test empty ilist constructor...") oatpp::UnorderedFields map({}); OATPP_ASSERT(map) @@ -60,11 +60,11 @@ void UnorderedMapTest::onRun() { auto it = map.getValueType()->params.begin(); OATPP_ASSERT(*it++ == oatpp::String::Class::getType()) OATPP_ASSERT(*it++ == oatpp::String::Class::getType()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test createShared()...") + OATPP_LOGi(TAG, "test createShared()...") oatpp::UnorderedFields map = oatpp::UnorderedFields::createShared(); OATPP_ASSERT(map) @@ -73,11 +73,11 @@ void UnorderedMapTest::onRun() { OATPP_ASSERT(map.get() != nullptr) OATPP_ASSERT(map.getValueType()->classId.id == oatpp::data::type::__class::AbstractUnorderedMap::CLASS_ID.id) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test copy-assignment operator...") + OATPP_LOGi(TAG, "test copy-assignment operator...") oatpp::UnorderedFields map1({}); oatpp::UnorderedFields map2; @@ -103,11 +103,11 @@ void UnorderedMapTest::onRun() { OATPP_ASSERT(map2["key1"] == "b") OATPP_ASSERT(map2["key2"] == "c") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test move-assignment operator...") + OATPP_LOGi(TAG, "test move-assignment operator...") oatpp::UnorderedFields map1({}); oatpp::UnorderedFields map2; @@ -115,11 +115,11 @@ void UnorderedMapTest::onRun() { OATPP_ASSERT(!map1) OATPP_ASSERT(map2) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test get element by index...") + OATPP_LOGi(TAG, "test get element by index...") oatpp::UnorderedFields map = {{"key1", "a"}, {"key2", "b"}, {"key3", "c"}}; OATPP_ASSERT(map) @@ -137,11 +137,11 @@ void UnorderedMapTest::onRun() { OATPP_ASSERT(map["key1"] == "a") OATPP_ASSERT(map["key2"] == "Hello!") OATPP_ASSERT(map["key3"] == "c") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test polymorphicDispatcher...") + OATPP_LOGi(TAG, "test polymorphicDispatcher...") oatpp::UnorderedFields map = {{"key1", "a"}, {"key2", "b"}, {"key3", "c"}}; auto polymorphicDispatcher = static_cast( @@ -155,7 +155,7 @@ void UnorderedMapTest::onRun() { OATPP_ASSERT(map["key1"] == "d") OATPP_ASSERT(map["key2"] == "b") OATPP_ASSERT(map["key3"] == "c") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } } diff --git a/test/oatpp/data/type/UnorderedSetTest.cpp b/test/oatpp/data/type/UnorderedSetTest.cpp index 90c523a9..8cbe82e8 100644 --- a/test/oatpp/data/type/UnorderedSetTest.cpp +++ b/test/oatpp/data/type/UnorderedSetTest.cpp @@ -25,6 +25,7 @@ #include "UnorderedSetTest.hpp" #include "oatpp/Types.hpp" +#include "oatpp/base/Log.hpp" namespace oatpp { namespace data { namespace type { @@ -32,7 +33,7 @@ void UnorderedSetTest::onRun() { { - OATPP_LOGI(TAG, "test default constructor...") + OATPP_LOGi(TAG, "test default constructor...") oatpp::UnorderedSet set; OATPP_ASSERT(!set) @@ -42,11 +43,11 @@ void UnorderedSetTest::onRun() { OATPP_ASSERT(set.getValueType()->classId.id == oatpp::data::type::__class::AbstractUnorderedSet::CLASS_ID.id) OATPP_ASSERT(set.getValueType()->params.size() == 1) OATPP_ASSERT(set.getValueType()->params.front() == oatpp::String::Class::getType()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test empty ilist constructor...") + OATPP_LOGi(TAG, "test empty ilist constructor...") oatpp::UnorderedSet set({}); OATPP_ASSERT(set) @@ -57,11 +58,11 @@ void UnorderedSetTest::onRun() { OATPP_ASSERT(set.getValueType()->classId.id == oatpp::data::type::__class::AbstractUnorderedSet::CLASS_ID.id) OATPP_ASSERT(set.getValueType()->params.size() == 1) OATPP_ASSERT(set.getValueType()->params.front() == oatpp::String::Class::getType()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test createShared()...") + OATPP_LOGi(TAG, "test createShared()...") oatpp::UnorderedSet set = oatpp::UnorderedSet::createShared(); OATPP_ASSERT(set) @@ -70,11 +71,11 @@ void UnorderedSetTest::onRun() { OATPP_ASSERT(set.get() != nullptr) OATPP_ASSERT(set.getValueType()->classId.id == oatpp::data::type::__class::AbstractUnorderedSet::CLASS_ID.id) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test copy-assignment operator...") + OATPP_LOGi(TAG, "test copy-assignment operator...") oatpp::UnorderedSet set1({}); oatpp::UnorderedSet set2; @@ -101,11 +102,11 @@ void UnorderedSetTest::onRun() { OATPP_ASSERT(set2["b"] == true) OATPP_ASSERT(set2["c"] == true) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test move-assignment operator...") + OATPP_LOGi(TAG, "test move-assignment operator...") oatpp::UnorderedSet set1({}); oatpp::UnorderedSet set2; @@ -113,11 +114,11 @@ void UnorderedSetTest::onRun() { OATPP_ASSERT(!set1) OATPP_ASSERT(set2) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test polymorphicDispatcher...") + OATPP_LOGi(TAG, "test polymorphicDispatcher...") oatpp::UnorderedSet set = {"a", "b", "c"}; auto polymorphicDispatcher = static_cast( @@ -136,7 +137,7 @@ void UnorderedSetTest::onRun() { OATPP_ASSERT(set["b"]) OATPP_ASSERT(set["c"]) OATPP_ASSERT(set["d"]) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } } diff --git a/test/oatpp/data/type/VectorTest.cpp b/test/oatpp/data/type/VectorTest.cpp index 5dd3cec3..4cce4485 100644 --- a/test/oatpp/data/type/VectorTest.cpp +++ b/test/oatpp/data/type/VectorTest.cpp @@ -25,13 +25,14 @@ #include "VectorTest.hpp" #include "oatpp/Types.hpp" +#include "oatpp/base/Log.hpp" namespace oatpp { namespace data { namespace type { void VectorTest::onRun() { { - OATPP_LOGI(TAG, "test default constructor...") + OATPP_LOGi(TAG, "test default constructor...") oatpp::Vector vector; OATPP_ASSERT(!vector) @@ -41,11 +42,11 @@ void VectorTest::onRun() { OATPP_ASSERT(vector.getValueType()->classId.id == oatpp::data::type::__class::AbstractVector::CLASS_ID.id) OATPP_ASSERT(vector.getValueType()->params.size() == 1) OATPP_ASSERT(vector.getValueType()->params.front() == oatpp::String::Class::getType()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test empty ilist constructor...") + OATPP_LOGi(TAG, "test empty ilist constructor...") oatpp::Vector vector({}); OATPP_ASSERT(vector) @@ -56,11 +57,11 @@ void VectorTest::onRun() { OATPP_ASSERT(vector.getValueType()->classId.id == oatpp::data::type::__class::AbstractVector::CLASS_ID.id) OATPP_ASSERT(vector.getValueType()->params.size() == 1) OATPP_ASSERT(vector.getValueType()->params.front() == oatpp::String::Class::getType()) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test createShared()...") + OATPP_LOGi(TAG, "test createShared()...") oatpp::Vector vector = oatpp::Vector::createShared(); OATPP_ASSERT(vector) @@ -69,11 +70,11 @@ void VectorTest::onRun() { OATPP_ASSERT(vector.get() != nullptr) OATPP_ASSERT(vector.getValueType()->classId.id == oatpp::data::type::__class::AbstractVector::CLASS_ID.id) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test copy-assignment operator...") + OATPP_LOGi(TAG, "test copy-assignment operator...") oatpp::Vector vector1({}); oatpp::Vector vector2; @@ -99,11 +100,11 @@ void VectorTest::onRun() { OATPP_ASSERT(vector2[0] == "b") OATPP_ASSERT(vector2[1] == "c") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test move-assignment operator...") + OATPP_LOGi(TAG, "test move-assignment operator...") oatpp::Vector vector1({}); oatpp::Vector vector2; @@ -111,11 +112,11 @@ void VectorTest::onRun() { OATPP_ASSERT(!vector1) OATPP_ASSERT(vector2) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test get element by index...") + OATPP_LOGi(TAG, "test get element by index...") oatpp::Vector vector = {"a", "b", "c"}; OATPP_ASSERT(vector) @@ -133,11 +134,11 @@ void VectorTest::onRun() { OATPP_ASSERT(vector[0] == "a") OATPP_ASSERT(vector[1] == "Hello!") OATPP_ASSERT(vector[2] == "c") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "test polymorphicDispatcher...") + OATPP_LOGi(TAG, "test polymorphicDispatcher...") oatpp::Vector vector = {"a", "b", "c"}; auto polymorphicDispatcher = static_cast( @@ -152,7 +153,7 @@ void VectorTest::onRun() { OATPP_ASSERT(vector[1] == "b") OATPP_ASSERT(vector[2] == "c") OATPP_ASSERT(vector[3] == "d") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } } diff --git a/test/oatpp/encoding/Base64Test.cpp b/test/oatpp/encoding/Base64Test.cpp index 12dbeb88..ef4788f8 100644 --- a/test/oatpp/encoding/Base64Test.cpp +++ b/test/oatpp/encoding/Base64Test.cpp @@ -25,6 +25,7 @@ #include "Base64Test.hpp" #include "oatpp/encoding/Base64.hpp" +#include "oatpp/base/Log.hpp" namespace oatpp { namespace test { namespace encoding { @@ -35,7 +36,7 @@ void Base64Test::onRun() { { oatpp::String encoded = oatpp::encoding::Base64::encode(message); - OATPP_LOGV(TAG, "encoded='%s'", encoded->c_str()) + OATPP_LOGv(TAG, "encoded='{}'", encoded->c_str()) OATPP_ASSERT(encoded == messageEncoded) oatpp::String decoded = oatpp::encoding::Base64::decode(encoded); OATPP_ASSERT(message == decoded) @@ -43,7 +44,7 @@ void Base64Test::onRun() { { oatpp::String encoded = oatpp::encoding::Base64::encode(message, oatpp::encoding::Base64::ALPHABET_BASE64_URL_SAFE); - OATPP_LOGV(TAG, "encoded='%s'", encoded->c_str()) + OATPP_LOGv(TAG, "encoded='{}'", encoded->c_str()) oatpp::String decoded = oatpp::encoding::Base64::decode(encoded, oatpp::encoding::Base64::ALPHABET_BASE64_URL_SAFE_AUXILIARY_CHARS); OATPP_ASSERT(message == decoded) } diff --git a/test/oatpp/encoding/UnicodeTest.cpp b/test/oatpp/encoding/UnicodeTest.cpp index 2033047a..148f9730 100644 --- a/test/oatpp/encoding/UnicodeTest.cpp +++ b/test/oatpp/encoding/UnicodeTest.cpp @@ -26,6 +26,7 @@ #include "oatpp/encoding/Hex.hpp" #include "oatpp/encoding/Unicode.hpp" +#include "oatpp/base/Log.hpp" namespace oatpp { namespace test { namespace encoding { @@ -50,7 +51,7 @@ void writeBinaryInt(v_int32 value){ } } - OATPP_LOGV("bin", "value='%s'", reinterpret_cast(&buff)) + OATPP_LOGv("bin", "value='{}'", reinterpret_cast(&buff)) } diff --git a/test/oatpp/encoding/UrlTest.cpp b/test/oatpp/encoding/UrlTest.cpp index 4e048034..844883cd 100644 --- a/test/oatpp/encoding/UrlTest.cpp +++ b/test/oatpp/encoding/UrlTest.cpp @@ -26,6 +26,7 @@ #include "oatpp/utils/Random.hpp" #include "oatpp/encoding/Url.hpp" +#include "oatpp/base/Log.hpp" namespace oatpp { namespace test { namespace encoding { @@ -61,7 +62,7 @@ void UrlTest::onRun(){ oatpp::encoding::Url::Config config; config.spaceToPlus = false; auto encoded = oatpp::encoding::Url::encode(" ", config); - OATPP_ASSERT_FMT("%s", encoded == "%20") + OATPP_ASSERT_FMT("{}", encoded == "%20") } { @@ -75,14 +76,14 @@ void UrlTest::onRun(){ oatpp::encoding::Url::Config config; config.spaceToPlus = false; auto encoded = oatpp::encoding::Url::encode("Смачна Овсяночка!", config); - OATPP_ASSERT_FMT("%s", encoded == "%D0%A1%D0%BC%D0%B0%D1%87%D0%BD%D0%B0%20%D0%9E%D0%B2%D1%81%D1%8F%D0%BD%D0%BE%D1%87%D0%BA%D0%B0%21") + OATPP_ASSERT_FMT("{}", encoded == "%D0%A1%D0%BC%D0%B0%D1%87%D0%BD%D0%B0%20%D0%9E%D0%B2%D1%81%D1%8F%D0%BD%D0%BE%D1%87%D0%BA%D0%B0%21") } { oatpp::encoding::Url::Config config; config.spaceToPlus = true; auto encoded = oatpp::encoding::Url::encode("Смачна Овсяночка!", config); - OATPP_ASSERT_FMT("%s", encoded == "%D0%A1%D0%BC%D0%B0%D1%87%D0%BD%D0%B0+%D0%9E%D0%B2%D1%81%D1%8F%D0%BD%D0%BE%D1%87%D0%BA%D0%B0%21") + OATPP_ASSERT_FMT("{}", encoded == "%D0%A1%D0%BC%D0%B0%D1%87%D0%BD%D0%B0+%D0%9E%D0%B2%D1%81%D1%8F%D0%BD%D0%BE%D1%87%D0%BA%D0%B0%21") } } diff --git a/test/oatpp/json/BooleanTest.cpp b/test/oatpp/json/BooleanTest.cpp index 585bff39..72193fd1 100644 --- a/test/oatpp/json/BooleanTest.cpp +++ b/test/oatpp/json/BooleanTest.cpp @@ -25,6 +25,7 @@ #include "BooleanTest.hpp" #include "oatpp/json/ObjectMapper.hpp" +#include "oatpp/base/Log.hpp" namespace oatpp { namespace json { @@ -32,31 +33,31 @@ void BooleanTest::onRun() { oatpp::json::ObjectMapper mapper; { - OATPP_LOGI(TAG, "Serialize true to string...") + OATPP_LOGd(TAG, "Serialize true to string...") auto value = mapper.writeToString(Boolean(true)); OATPP_ASSERT(value == "true") - OATPP_LOGI(TAG, "OK") + OATPP_LOGd(TAG, "OK") } { - OATPP_LOGI(TAG, "Serialize false to string...") + OATPP_LOGd(TAG, "Serialize false to string...") auto value = mapper.writeToString(Boolean(false)); OATPP_ASSERT(value == "false") - OATPP_LOGI(TAG, "OK") + OATPP_LOGd(TAG, "OK") } { - OATPP_LOGI(TAG, "Deserialize true string...") + OATPP_LOGd(TAG, "Deserialize true string...") Boolean value = mapper.readFromString("true"); OATPP_ASSERT(static_cast(value)) - OATPP_LOGI(TAG, "OK") + OATPP_LOGd(TAG, "OK") } { - OATPP_LOGI(TAG, "Deserialize false string...") + OATPP_LOGd(TAG, "Deserialize false string...") Boolean value = mapper.readFromString("false"); OATPP_ASSERT(!static_cast(value)) - OATPP_LOGI(TAG, "OK") + OATPP_LOGd(TAG, "OK") } } diff --git a/test/oatpp/json/DTOMapperPerfTest.cpp b/test/oatpp/json/DTOMapperPerfTest.cpp index a4572056..23cc731c 100644 --- a/test/oatpp/json/DTOMapperPerfTest.cpp +++ b/test/oatpp/json/DTOMapperPerfTest.cpp @@ -32,6 +32,7 @@ #include "oatpp/macro/basic.hpp" #include "oatpp/macro/codegen.hpp" +#include "oatpp/base/Log.hpp" #include "oatpp-test/Checker.hpp" @@ -77,7 +78,7 @@ void DTOMapperPerfTest::onRun() { auto test1 = Test1::createTestInstance(); auto test1_Text = mapper.writeToString(test1); - OATPP_LOGV(TAG, "json='%s'", test1_Text->c_str()) + OATPP_LOGv(TAG, "json='{}'", test1_Text->c_str()) { oatpp::test::PerformanceChecker checker("Serializer"); diff --git a/test/oatpp/json/DTOMapperTest.cpp b/test/oatpp/json/DTOMapperTest.cpp index 4e4e58b6..ec15e60f 100644 --- a/test/oatpp/json/DTOMapperTest.cpp +++ b/test/oatpp/json/DTOMapperTest.cpp @@ -35,6 +35,7 @@ #include "oatpp/utils/Conversion.hpp" #include "oatpp/macro/codegen.hpp" +#include "oatpp/base/Log.hpp" namespace oatpp { namespace json { @@ -269,11 +270,11 @@ void DTOMapperTest::onRun(){ auto result = mapper.writeToString(test1); - OATPP_LOGV(TAG, "json='%s'", result->c_str()) + OATPP_LOGv(TAG, "json='{}'", result->c_str()) - OATPP_LOGV(TAG, "...") - OATPP_LOGV(TAG, "...") - OATPP_LOGV(TAG, "...") + OATPP_LOGv(TAG, "...") + OATPP_LOGv(TAG, "...") + OATPP_LOGv(TAG, "...") oatpp::utils::parser::Caret caret(result); auto obj1 = mapper.readFromCaret>(caret); @@ -322,7 +323,7 @@ void DTOMapperTest::onRun(){ result = mapper.writeToString(obj1); - OATPP_LOGV(TAG, "json='%s'", result->c_str()) + OATPP_LOGv(TAG, "json='{}'", result->c_str()) } { @@ -331,7 +332,7 @@ void DTOMapperTest::onRun(){ try { result = mapper.writeToString(test2); } catch(std::runtime_error&) { - OATPP_LOGV(TAG, "Test2::field_string is required!") + OATPP_LOGv(TAG, "Test2::field_string is required!") } OATPP_ASSERT(result == nullptr) } @@ -353,7 +354,7 @@ void DTOMapperTest::onRun(){ try { result = mapper.writeToString(test4); } catch(std::runtime_error&) { - OATPP_LOGV(TAG, "TestChild1::name is required!") + OATPP_LOGv(TAG, "TestChild1::name is required!") } OATPP_ASSERT(result == nullptr) } @@ -389,12 +390,12 @@ void DTOMapperTest::onRun(){ obj2->anyList->push_back(map); auto json = mapper.writeToString(obj2); - OATPP_LOGV(TAG, "any json='%s'", json->c_str()) + OATPP_LOGv(TAG, "any json='{}'", json->c_str()) auto deserializedAny = mapper.readFromString>(json); auto json2 = mapper.writeToString(deserializedAny); - OATPP_LOGV(TAG, "any json='%s'", json2->c_str()) + OATPP_LOGv(TAG, "any json='{}'", json2->c_str()) } diff --git a/test/oatpp/json/DeserializerTest.cpp b/test/oatpp/json/DeserializerTest.cpp index 456d8a22..64c47a60 100644 --- a/test/oatpp/json/DeserializerTest.cpp +++ b/test/oatpp/json/DeserializerTest.cpp @@ -27,6 +27,7 @@ #include #include "oatpp/json/ObjectMapper.hpp" +#include "oatpp/base/Log.hpp" #include "oatpp/macro/codegen.hpp" namespace oatpp { namespace json { @@ -241,7 +242,7 @@ void DeserializerTest::onRun(){ try { obj5 = mapper.readFromString>(R"({"strF":null})"); } catch (std::runtime_error& e) { - OATPP_LOGD(TAG, "Test5::strF is required!") + OATPP_LOGd(TAG, "Test5::strF is required!") } OATPP_ASSERT(obj5 == nullptr) @@ -255,7 +256,7 @@ void DeserializerTest::onRun(){ try { obj7 = mapper.readFromString>(R"({"strF":"value1", "child":{"name":null}})"); } catch (std::runtime_error& e) { - OATPP_LOGD(TAG, "TestChild1::name is required!") + OATPP_LOGd(TAG, "TestChild1::name is required!") } OATPP_ASSERT(obj7 == nullptr) @@ -265,56 +266,56 @@ void DeserializerTest::onRun(){ OATPP_ASSERT(false) } - OATPP_LOGD(TAG, "Any: String") + OATPP_LOGd(TAG, "Any: String") { auto dto = mapper.readFromString>(R"({"any":"my_string"})"); OATPP_ASSERT(dto) OATPP_ASSERT(dto->any.getStoredType() == String::Class::getType()) OATPP_ASSERT(dto->any.retrieve() == "my_string") } - OATPP_LOGD(TAG, "Any: Boolean") + OATPP_LOGd(TAG, "Any: Boolean") { auto dto = mapper.readFromString>(R"({"any":false})"); OATPP_ASSERT(dto) OATPP_ASSERT(dto->any.getStoredType() == Boolean::Class::getType()) OATPP_ASSERT(dto->any.retrieve() == false) } - OATPP_LOGD(TAG, "Any: Negative Float") + OATPP_LOGd(TAG, "Any: Negative Float") { auto dto = mapper.readFromString>(R"({"any":-1.23456789,"another":1.1})"); OATPP_ASSERT(dto) OATPP_ASSERT(dto->any.getStoredType() == Float64::Class::getType()) OATPP_ASSERT(fabs(dto->any.retrieve() - -1.23456789) < std::numeric_limits::epsilon()) } - OATPP_LOGD(TAG, "Any: Positive Float") + OATPP_LOGd(TAG, "Any: Positive Float") { auto dto = mapper.readFromString>(R"({"any":1.23456789,"another":1.1})"); OATPP_ASSERT(dto) OATPP_ASSERT(dto->any.getStoredType() == Float64::Class::getType()) OATPP_ASSERT(fabs(dto->any.retrieve() - 1.23456789) < std::numeric_limits::epsilon()) } - OATPP_LOGD(TAG, "Any: Negative exponential Float") + OATPP_LOGd(TAG, "Any: Negative exponential Float") { auto dto = mapper.readFromString>(R"({"any":-1.2345e30,"another":1.1})"); OATPP_ASSERT(dto) OATPP_ASSERT(dto->any.getStoredType() == Float64::Class::getType()) OATPP_ASSERT(fabs(dto->any.retrieve() - -1.2345e30) < std::numeric_limits::epsilon()) } - OATPP_LOGD(TAG, "Any: Positive exponential Float") + OATPP_LOGd(TAG, "Any: Positive exponential Float") { auto dto = mapper.readFromString>(R"({"any":1.2345e30,"another":1.1})"); OATPP_ASSERT(dto) OATPP_ASSERT(dto->any.getStoredType() == Float64::Class::getType()) OATPP_ASSERT(fabs(dto->any.retrieve() - 1.2345e30) < std::numeric_limits::epsilon()) } - OATPP_LOGD(TAG, "Any: Big Integer") + OATPP_LOGd(TAG, "Any: Big Integer") { auto dto = mapper.readFromString>(R"({"any":9223372036854775807,"another":1.1})"); OATPP_ASSERT(dto) OATPP_ASSERT(dto->any.getStoredType() == Int64::Class::getType()) OATPP_ASSERT(dto->any.retrieve() == 9223372036854775807) } - OATPP_LOGD(TAG, "Any: Signed Integer") + OATPP_LOGd(TAG, "Any: Signed Integer") { auto dto = mapper.readFromString>(R"({"any":-1234567890,"another":1.1})"); OATPP_ASSERT(dto) diff --git a/test/oatpp/json/EnumTest.cpp b/test/oatpp/json/EnumTest.cpp index f6364732..b016a82e 100644 --- a/test/oatpp/json/EnumTest.cpp +++ b/test/oatpp/json/EnumTest.cpp @@ -59,127 +59,127 @@ void EnumTest::onRun() { oatpp::json::ObjectMapper mapper; { - OATPP_LOGI(TAG, "Serializer as string...") + OATPP_LOGi(TAG, "Serializer as string...") oatpp::Fields::AsString> map = {{"enum", Enum1::V1}}; auto json = mapper.writeToString(map); - OATPP_LOGD(TAG, "json='%s'", json->c_str()) + OATPP_LOGd(TAG, "json='{}'", json->c_str()) OATPP_ASSERT(json == "{\"enum\":\"enum1-v1\"}") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Serializer as string null...") + OATPP_LOGi(TAG, "Serializer as string null...") oatpp::Fields::AsString> map = {{"enum", nullptr}}; auto json = mapper.writeToString(map); - OATPP_LOGD(TAG, "json='%s'", json->c_str()) + OATPP_LOGd(TAG, "json='{}'", json->c_str()) OATPP_ASSERT(json == "{\"enum\":null}") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Serializer as string error on null...") + OATPP_LOGi(TAG, "Serializer as string error on null...") bool error = false; oatpp::Fields::AsString::NotNull> map = {{"enum", nullptr}}; try { auto json = mapper.writeToString(map); } catch (const data::mapping::MappingError& e) { - OATPP_LOGD(TAG, "error - '%s'\ntrace:\n%s", e.what(), e.errorStack().stacktrace()->c_str()) + OATPP_LOGd(TAG, "error - '{}'\ntrace:\n{}", e.what(), e.errorStack().stacktrace()->c_str()) error = true; } OATPP_ASSERT(error == true) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Serializer as int...") + OATPP_LOGi(TAG, "Serializer as int...") oatpp::Fields::AsNumber> map = {{"enum", Enum1::V1}}; auto json = mapper.writeToString(map); - OATPP_LOGD(TAG, "json='%s'", json->c_str()) + OATPP_LOGd(TAG, "json='{}'", json) OATPP_ASSERT(json == "{\"enum\":10}") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Serializer as int null...") + OATPP_LOGi(TAG, "Serializer as int null...") oatpp::Fields::AsNumber> map = {{"enum", nullptr}}; auto json = mapper.writeToString(map); - OATPP_LOGD(TAG, "json='%s'", json->c_str()) + OATPP_LOGd(TAG, "json='{}'", json) OATPP_ASSERT(json == "{\"enum\":null}") - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Serializer as int error on null...") + OATPP_LOGi(TAG, "Serializer as int error on null...") bool error = false; oatpp::Fields::AsNumber::NotNull> map = {{"enum", nullptr}}; try { auto json = mapper.writeToString(map); } catch (const data::mapping::MappingError& e) { - OATPP_LOGD(TAG, "error - '%s'\ntrace:\n%s", e.what(), e.errorStack().stacktrace()->c_str()) + OATPP_LOGd(TAG, "error - '{}'\ntrace:\n{}", e.what(), e.errorStack().stacktrace()) error = true; } OATPP_ASSERT(error == true) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Deserializer as string...") + OATPP_LOGi(TAG, "Deserializer as string...") oatpp::String json = "{\"enum\":\"enum1-v2\"}"; auto map = mapper.readFromString::AsString>>(json); OATPP_ASSERT(map["enum"] == Enum1::V2) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Deserializer as string null...") + OATPP_LOGi(TAG, "Deserializer as string null...") oatpp::String json = "{\"enum\":null}"; auto map = mapper.readFromString::AsString>>(json); OATPP_ASSERT(map["enum"] == nullptr) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Deserializer as string error on null...") + OATPP_LOGi(TAG, "Deserializer as string error on null...") bool error = false; oatpp::String json = "{\"enum\":null}"; try { auto map = mapper.readFromString::AsString::NotNull>>(json); } catch (const data::mapping::MappingError& e) { - OATPP_LOGD(TAG, "error - '%s'\ntrace:\n%s", e.what(), e.errorStack().stacktrace()->c_str()) + OATPP_LOGd(TAG, "error - '{}'\ntrace:\n{}", e.what(), e.errorStack().stacktrace()->c_str()) error = true; } OATPP_ASSERT(error == true) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Deserializer as int...") + OATPP_LOGi(TAG, "Deserializer as int...") oatpp::String json = "{\"enum\":20}"; auto map = mapper.readFromString::AsNumber>>(json); OATPP_ASSERT(map["enum"] == Enum1::V2) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Deserializer as int null...") + OATPP_LOGi(TAG, "Deserializer as int null...") oatpp::String json = "{\"enum\":null}"; auto map = mapper.readFromString::AsNumber>>(json); OATPP_ASSERT(map["enum"] == nullptr) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } { - OATPP_LOGI(TAG, "Deserializer as int error on null...") + OATPP_LOGi(TAG, "Deserializer as int error on null...") bool error = false; oatpp::String json = "{\"enum\":null}"; try { auto map = mapper.readFromString::AsNumber::NotNull>>(json); } catch (const data::mapping::MappingError& e) { - OATPP_LOGD(TAG, "error - '%s'\ntrace:\n%s", e.what(), e.errorStack().stacktrace()->c_str()) + OATPP_LOGd(TAG, "error - '{}'\ntrace:\n{}", e.what(), e.errorStack().stacktrace()->c_str()) error = true; } OATPP_ASSERT(error == true) - OATPP_LOGI(TAG, "OK") + OATPP_LOGi(TAG, "OK") } } diff --git a/test/oatpp/json/UnorderedSetTest.cpp b/test/oatpp/json/UnorderedSetTest.cpp index 55893d0e..b409f6e3 100644 --- a/test/oatpp/json/UnorderedSetTest.cpp +++ b/test/oatpp/json/UnorderedSetTest.cpp @@ -25,6 +25,7 @@ #include "UnorderedSetTest.hpp" #include "oatpp/json/ObjectMapper.hpp" +#include "oatpp/base/Log.hpp" namespace oatpp { namespace json { @@ -35,7 +36,7 @@ void UnorderedSetTest::onRun() { { oatpp::UnorderedSet set = {"Hello", "World", "!"}; auto json = mapper.writeToString(set); - OATPP_LOGD(TAG, "json='%s'", json->c_str()) + OATPP_LOGd(TAG, "json='{}'", json->c_str()) } { @@ -44,7 +45,7 @@ void UnorderedSetTest::onRun() { OATPP_ASSERT(set) OATPP_ASSERT(set->size() == 3) for(auto& item : *set) { - OATPP_LOGD(TAG, "item='%s'", item->c_str()) + OATPP_LOGd(TAG, "item='{}'", item->c_str()) } } diff --git a/test/oatpp/network/ConnectionPoolTest.cpp b/test/oatpp/network/ConnectionPoolTest.cpp index 043aa774..f7f249bb 100644 --- a/test/oatpp/network/ConnectionPoolTest.cpp +++ b/test/oatpp/network/ConnectionPoolTest.cpp @@ -26,6 +26,7 @@ #include "oatpp/network/ConnectionPool.hpp" #include "oatpp/async/Executor.hpp" +#include "oatpp/base/Log.hpp" namespace oatpp { namespace test { namespace network { @@ -202,7 +203,7 @@ void ConnectionPoolTest::onRun() { executor.waitTasksFinished(); - OATPP_LOGD(TAG, "connections_counter=%ld", connectionProvider->counter.load()) + OATPP_LOGd(TAG, "connections_counter={}", connectionProvider->counter.load()) OATPP_ASSERT(connectionProvider->counter <= 10) pool->stop(); diff --git a/test/oatpp/network/UrlTest.cpp b/test/oatpp/network/UrlTest.cpp index 6c3a1ff0..f755b6f8 100644 --- a/test/oatpp/network/UrlTest.cpp +++ b/test/oatpp/network/UrlTest.cpp @@ -25,6 +25,7 @@ #include "UrlTest.hpp" #include "oatpp/network/Url.hpp" +#include "oatpp/base/Log.hpp" #include "oatpp-test/Checker.hpp" @@ -36,7 +37,7 @@ void UrlTest::onRun() { { const char* urlText = "http://root@127.0.0.1:8000/path/to/resource/?q1=1&q2=2"; - OATPP_LOGV(TAG, "urlText='%s'", urlText) + OATPP_LOGv(TAG, "urlText='{}'", urlText) auto url = Url::Parser::parseUrl(urlText); OATPP_ASSERT(url.scheme && url.scheme == "http") @@ -51,7 +52,7 @@ void UrlTest::onRun() { { const char* urlText = "ftp://root@oatpp.io:8000/path/to/resource?q1=1&q2=2"; - OATPP_LOGV(TAG, "urlText='%s'", urlText) + OATPP_LOGv(TAG, "urlText='{}'", urlText) auto url = Url::Parser::parseUrl(urlText); OATPP_ASSERT(url.scheme && url.scheme == "ftp") @@ -66,7 +67,7 @@ void UrlTest::onRun() { { const char* urlText = "https://oatpp.io/?q1=1&q2=2"; - OATPP_LOGV(TAG, "urlText='%s'", urlText) + OATPP_LOGv(TAG, "urlText='{}'", urlText) auto url = Url::Parser::parseUrl(urlText); OATPP_ASSERT(url.scheme && url.scheme == "https") @@ -81,7 +82,7 @@ void UrlTest::onRun() { { const char* urlText = "https://oatpp.io/"; - OATPP_LOGV(TAG, "urlText='%s'", urlText) + OATPP_LOGv(TAG, "urlText='{}'", urlText) auto url = Url::Parser::parseUrl(urlText); OATPP_ASSERT(url.scheme && url.scheme == "https") @@ -94,7 +95,7 @@ void UrlTest::onRun() { { const char* urlText = "https://oatpp.io"; - OATPP_LOGV(TAG, "urlText='%s'", urlText) + OATPP_LOGv(TAG, "urlText='{}'", urlText) auto url = Url::Parser::parseUrl(urlText); OATPP_ASSERT(url.scheme && url.scheme == "https") @@ -107,7 +108,7 @@ void UrlTest::onRun() { { const char* urlText = "oatpp.io"; - OATPP_LOGV(TAG, "urlText='%s'", urlText) + OATPP_LOGv(TAG, "urlText='{}'", urlText) auto url = Url::Parser::parseUrl(urlText); OATPP_ASSERT(url.scheme == nullptr) @@ -120,7 +121,7 @@ void UrlTest::onRun() { { const char* urlText = "oatpp.io:8000/path"; - OATPP_LOGV(TAG, "urlText='%s'", urlText) + OATPP_LOGv(TAG, "urlText='{}'", urlText) auto url = Url::Parser::parseUrl(urlText); OATPP_ASSERT(url.scheme == nullptr) @@ -133,7 +134,7 @@ void UrlTest::onRun() { { const char* urlText = "?key1=value1&key2=value2&key3=value3"; - OATPP_LOGV(TAG, "urlText='%s'", urlText) + OATPP_LOGv(TAG, "urlText='{}'", urlText) auto params = Url::Parser::parseQueryParams(urlText); OATPP_ASSERT(params.getSize() == 3) OATPP_ASSERT(params.get("key1") == "value1") @@ -143,7 +144,7 @@ void UrlTest::onRun() { { const char *urlText = "?key1=value1&key2&key3=value3"; - OATPP_LOGV(TAG, "urlText='%s'", urlText) + OATPP_LOGv(TAG, "urlText='{}'", urlText) auto params = Url::Parser::parseQueryParams(urlText); OATPP_ASSERT(params.getSize() == 3) OATPP_ASSERT(params.get("key1") == "value1") @@ -153,7 +154,7 @@ void UrlTest::onRun() { { const char *urlText = "?key1=value1&key2&key3"; - OATPP_LOGV(TAG, "urlText='%s'", urlText) + OATPP_LOGv(TAG, "urlText='{}'", urlText) auto params = Url::Parser::parseQueryParams(urlText); OATPP_ASSERT(params.getSize() == 3) OATPP_ASSERT(params.get("key1") == "value1") @@ -163,7 +164,7 @@ void UrlTest::onRun() { { const char *urlText = "label?key1=value1&key2=value2&key3=value3"; - OATPP_LOGV(TAG, "urlText='%s'", urlText) + OATPP_LOGv(TAG, "urlText='{}'", urlText) auto params = Url::Parser::parseQueryParams(urlText); OATPP_ASSERT(params.getSize() == 3) OATPP_ASSERT(params.get("key1") == "value1") @@ -173,7 +174,7 @@ void UrlTest::onRun() { { const char* urlText = "label?key1=value1&key2&key3=value3"; - OATPP_LOGV(TAG, "urlText='%s'", urlText) + OATPP_LOGv(TAG, "urlText='{}'", urlText) auto params = Url::Parser::parseQueryParams(urlText); OATPP_ASSERT(params.getSize() == 3) OATPP_ASSERT(params.get("key1") == "value1") @@ -183,7 +184,7 @@ void UrlTest::onRun() { { const char* urlText = "label?key1=value1&key2&key3"; - OATPP_LOGV(TAG, "urlText='%s'", urlText) + OATPP_LOGv(TAG, "urlText='{}'", urlText) auto params = Url::Parser::parseQueryParams(urlText); OATPP_ASSERT(params.getSize() == 3) OATPP_ASSERT(params.get("key1") == "value1") diff --git a/test/oatpp/network/monitor/ConnectionMonitorTest.cpp b/test/oatpp/network/monitor/ConnectionMonitorTest.cpp index 8bb2a2c7..ccf9f8e6 100644 --- a/test/oatpp/network/monitor/ConnectionMonitorTest.cpp +++ b/test/oatpp/network/monitor/ConnectionMonitorTest.cpp @@ -47,7 +47,7 @@ class ReadCallback : public oatpp::data::stream::ReadCallback { public: v_io_size read(void *buffer, v_buff_size count, async::Action &action) override { - OATPP_LOGI("TEST", "read(...)") + OATPP_LOGi("TEST", "read(...)") std::this_thread::sleep_for(std::chrono::milliseconds(100)); char* data = reinterpret_cast(buffer); data[0] = 'A'; @@ -101,9 +101,9 @@ std::shared_ptr runServer(const std::shared_ptrrun(); - OATPP_LOGD("TEST", "server stopped") + OATPP_LOGd("TEST", "server stopped") connectionHandler->stop(); - OATPP_LOGD("TEST", "connectionHandler stopped") + OATPP_LOGd("TEST", "connectionHandler stopped") }); t.detach(); @@ -124,13 +124,13 @@ std::shared_ptr runAsyncServer(const std::shared_ptrrun(); - OATPP_LOGD("TEST_ASYNC", "server stopped") + OATPP_LOGd("TEST_ASYNC", "server stopped") connectionHandler->stop(); - OATPP_LOGD("TEST_ASYNC", "connectionHandler stopped") + OATPP_LOGd("TEST_ASYNC", "connectionHandler stopped") executor->waitTasksFinished(); executor->stop(); executor->join(); - OATPP_LOGD("TEST_ASYNC", "executor stopped") + OATPP_LOGd("TEST_ASYNC", "executor stopped") }); t.detach(); @@ -150,7 +150,7 @@ void runClient() { auto data = response->readBodyToString(); OATPP_ASSERT(data) - OATPP_LOGD("TEST", "data->size() == %lu", data->size()) + OATPP_LOGd("TEST", "data->size() == {}", data->size()) OATPP_ASSERT(data->size() < 110) // it should be less than 100. But we put 110 for redundancy } @@ -190,7 +190,7 @@ void runAsyncClient() { Action onBody(const oatpp::String& data) { OATPP_ASSERT(data) - OATPP_LOGD("TEST", "data->size() == %lu", data->size()) + OATPP_LOGd("TEST", "data->size() == {}", data->size()) OATPP_ASSERT(data->size() < 60) // it should be less than 50. But we put 60 for redundancy m_monitor->stop(); return finish(); @@ -203,11 +203,11 @@ void runAsyncClient() { executor->execute(); executor->waitTasksFinished(); - OATPP_LOGD("TEST_ASYNC_CLIENT", "task finished") + OATPP_LOGd("TEST_ASYNC_CLIENT", "task finished") executor->stop(); - OATPP_LOGD("TEST_ASYNC_CLIENT", "executor stopped") + OATPP_LOGd("TEST_ASYNC_CLIENT", "executor stopped") executor->join(); - OATPP_LOGD("TEST_ASYNC_CLIENT", "done") + OATPP_LOGd("TEST_ASYNC_CLIENT", "done") } @@ -226,7 +226,7 @@ void ConnectionMonitorTest::onRun() { ); { - OATPP_LOGD(TAG, "run simple API test") + OATPP_LOGd(TAG, "run simple API test") auto server = runServer(monitor); runClient(); server->stop(); @@ -234,7 +234,7 @@ void ConnectionMonitorTest::onRun() { } { - OATPP_LOGD(TAG, "run Async API test") + OATPP_LOGd(TAG, "run Async API test") auto server = runAsyncServer(monitor); runClient(); server->stop(); @@ -242,7 +242,7 @@ void ConnectionMonitorTest::onRun() { } { - OATPP_LOGD(TAG, "run Async Client test") + OATPP_LOGd(TAG, "run Async Client test") auto server = runServer(monitor); runAsyncClient(); server->stop(); diff --git a/test/oatpp/network/virtual_/InterfaceTest.cpp b/test/oatpp/network/virtual_/InterfaceTest.cpp index 1e3c4a39..a34b7fcc 100644 --- a/test/oatpp/network/virtual_/InterfaceTest.cpp +++ b/test/oatpp/network/virtual_/InterfaceTest.cpp @@ -66,7 +66,7 @@ namespace { OATPP_ASSERT(stream.getCurrentPosition() == res) OATPP_ASSERT(stream.toString() == "OK") - //OATPP_LOGV("client", "finished - OK") + //OATPP_LOGv("client", "finished - OK") } diff --git a/test/oatpp/network/virtual_/PipeTest.cpp b/test/oatpp/network/virtual_/PipeTest.cpp index 0d63e268..4f01bdaf 100644 --- a/test/oatpp/network/virtual_/PipeTest.cpp +++ b/test/oatpp/network/virtual_/PipeTest.cpp @@ -66,7 +66,7 @@ namespace { } } } - OATPP_LOGV("WriterTask", "sent %ld bytes", m_transferedBytes) + OATPP_LOGv("WriterTask", "sent {} bytes", m_transferedBytes) } }; @@ -94,14 +94,14 @@ namespace { m_buffer->writeSimple(readBuffer, res); } } - OATPP_LOGV("ReaderTask", "sent %ld bytes", m_buffer->getCurrentPosition()) + OATPP_LOGv("ReaderTask", "sent {} bytes", m_buffer->getCurrentPosition()) } }; void runTransfer(const std::shared_ptr& pipe, v_int64 chunksToTransfer, bool writeNonBlock, bool readerNonBlock) { - OATPP_LOGV("transfer", "writer-nb: %d, reader-nb: %d", writeNonBlock, readerNonBlock) + OATPP_LOGv("transfer", "writer-nb: {}, reader-nb: {}", writeNonBlock, readerNonBlock) auto buffer = std::make_shared(); diff --git a/test/oatpp/provider/PoolTemplateTest.cpp b/test/oatpp/provider/PoolTemplateTest.cpp index f8799337..c7c5f686 100644 --- a/test/oatpp/provider/PoolTemplateTest.cpp +++ b/test/oatpp/provider/PoolTemplateTest.cpp @@ -77,7 +77,7 @@ public: } void stop() override { - OATPP_LOGD("TestProvider", "stop()") + OATPP_LOGd("TestProvider", "stop()") } }; @@ -144,7 +144,7 @@ void PoolTemplateTest::onRun() { const v_int64 maxResources = 1; { - OATPP_LOGD(TAG, "Synchronously with timeout") + OATPP_LOGd(TAG, "Synchronously with timeout") auto poolTemplate = TestPool::createShared(provider, maxResources, std::chrono::seconds(10), std::chrono::milliseconds(500)); oatpp::provider::ResourceHandle resource = TestPool::get(poolTemplate); @@ -156,7 +156,7 @@ void PoolTemplateTest::onRun() { OATPP_ASSERT(TestPool::get(poolTemplate) == nullptr) } { - OATPP_LOGD(TAG, "Synchronously without timeout") + OATPP_LOGd(TAG, "Synchronously without timeout") auto poolTemplate = TestPool::createShared(provider, maxResources, std::chrono::seconds(10), std::chrono::milliseconds::zero()); oatpp::provider::ResourceHandle resource = TestPool::get(poolTemplate); @@ -171,7 +171,7 @@ void PoolTemplateTest::onRun() { OATPP_ASSERT(TestPool::get(poolTemplate) == nullptr) } { - OATPP_LOGD(TAG, "Asynchronously with timeout") + OATPP_LOGd(TAG, "Asynchronously with timeout") oatpp::async::Executor executor(1, 1, 1); auto poolTemplate = TestPool::createShared(provider, maxResources, std::chrono::seconds(10), std::chrono::milliseconds(500)); @@ -200,7 +200,7 @@ void PoolTemplateTest::onRun() { executor.join(); } { - OATPP_LOGD(TAG, "Asynchronously without timeout") + OATPP_LOGd(TAG, "Asynchronously without timeout") oatpp::async::Executor executor(1, 1, 1); auto poolTemplate = TestPool::createShared(provider, maxResources, std::chrono::seconds(10), std::chrono::milliseconds::zero()); diff --git a/test/oatpp/provider/PoolTest.cpp b/test/oatpp/provider/PoolTest.cpp index 1e7b22c3..0bdf5197 100644 --- a/test/oatpp/provider/PoolTest.cpp +++ b/test/oatpp/provider/PoolTest.cpp @@ -105,7 +105,7 @@ public: } void stop() override { - OATPP_LOGD("TestProvider", "stop()") + OATPP_LOGd("TestProvider", "stop()") } v_int64 getIdCounter() { @@ -181,7 +181,7 @@ void PoolTest::onRun() { std::list threads; - OATPP_LOGD(TAG, "Run 1") + OATPP_LOGd(TAG, "Run 1") for(v_int32 i = 0; i < 100; i ++ ) { threads.push_back(std::thread(clientMethod, pool, false)); executor.execute(pool, false); @@ -189,14 +189,14 @@ void PoolTest::onRun() { std::this_thread::sleep_for(std::chrono::milliseconds (200)); - OATPP_LOGD(TAG, "1) pool->getCounter() == %ld", pool->getCounter()) + OATPP_LOGd(TAG, "1) pool->getCounter() == {}", pool->getCounter()) OATPP_ASSERT(pool->getCounter() == 10) - OATPP_LOGD(TAG, "Waiting...") + OATPP_LOGd(TAG, "Waiting...") std::this_thread::sleep_for(std::chrono::seconds(10)); - OATPP_LOGD(TAG, "TestPool counter=%ld", pool->getCounter()) + OATPP_LOGd(TAG, "TestPool counter={}", pool->getCounter()) OATPP_ASSERT(pool->getCounter() == 0) - OATPP_LOGD(TAG, "Run 2") + OATPP_LOGd(TAG, "Run 2") for(v_int32 i = 0; i < 100; i ++ ) { threads.push_back(std::thread(clientMethod, pool, false)); executor.execute(pool, false); @@ -204,11 +204,11 @@ void PoolTest::onRun() { std::this_thread::sleep_for(std::chrono::milliseconds (200)); - OATPP_LOGD(TAG, "2) pool->getCounter() == %ld", pool->getCounter()) + OATPP_LOGd(TAG, "2) pool->getCounter() == {}", pool->getCounter()) OATPP_ASSERT(pool->getCounter() == 10) - OATPP_LOGD(TAG, "Waiting...") + OATPP_LOGd(TAG, "Waiting...") std::this_thread::sleep_for(std::chrono::seconds(10)); - OATPP_LOGD(TAG, "TestPool counter=%ld", pool->getCounter()) + OATPP_LOGd(TAG, "TestPool counter={}", pool->getCounter()) OATPP_ASSERT(pool->getCounter() == 0) for(std::thread& thread : threads) { @@ -217,7 +217,7 @@ void PoolTest::onRun() { executor.waitTasksFinished(); - OATPP_LOGD(TAG, "counter=%ld", provider->getIdCounter()) + OATPP_LOGd(TAG, "counter={}", provider->getIdCounter()) OATPP_ASSERT(provider->getIdCounter() == 20) pool->stop(); diff --git a/test/oatpp/web/ClientRetryTest.cpp b/test/oatpp/web/ClientRetryTest.cpp index 91f5dd41..2d7cd617 100644 --- a/test/oatpp/web/ClientRetryTest.cpp +++ b/test/oatpp/web/ClientRetryTest.cpp @@ -137,7 +137,7 @@ void runServer(v_uint16 port, v_int32 delaySeconds, v_int32 iterations, bool sta std::this_thread::sleep_for(std::chrono::seconds(delaySeconds)); if(!stable) { controller->available = !controller->available; - OATPP_LOGI("Server", "Available=%d", static_cast(controller->available.load())) + OATPP_LOGi("Server", "Available={}", static_cast(controller->available.load())) } } @@ -160,7 +160,7 @@ void ClientRetryTest::onRun() { { - OATPP_LOGI(TAG, "Test: no server available") + OATPP_LOGi(TAG, "Test: no server available") oatpp::test::PerformanceChecker checker("test: no server available"); auto retryPolicy = std::make_shared(2, std::chrono::seconds(1)); @@ -170,7 +170,7 @@ void ClientRetryTest::onRun() { auto response = client->getRoot(); auto ticks = checker.getElapsedTicks(); - OATPP_LOGD(TAG, "ticks=%ld", ticks) + OATPP_LOGd(TAG, "ticks={}", ticks) if(m_port == 0) { @@ -195,7 +195,7 @@ void ClientRetryTest::onRun() { { - OATPP_LOGI(TAG, "Test: server pops up") + OATPP_LOGi(TAG, "Test: server pops up") oatpp::test::PerformanceChecker checker("test: server pops up"); auto retryPolicy = std::make_shared(10 * 10, std::chrono::milliseconds(100)); @@ -214,7 +214,7 @@ void ClientRetryTest::onRun() { })); } - OATPP_LOGD(TAG, "Waiting for server to start...") + OATPP_LOGd(TAG, "Waiting for server to start...") std::this_thread::sleep_for(std::chrono::seconds(3)); runServer(m_port, 2, 2, true, controller); @@ -230,7 +230,7 @@ void ClientRetryTest::onRun() { { - OATPP_LOGI(TAG, "Test: unstable server!") + OATPP_LOGi(TAG, "Test: unstable server!") auto retryPolicy = std::make_shared(-1, std::chrono::seconds(1)); auto connectionPool = oatpp::network::ClientConnectionPool::createShared(connectionProvider, 10, std::chrono::seconds(1)); @@ -255,7 +255,7 @@ void ClientRetryTest::onRun() { counter ++; if(counter % 1000 == 0) { - OATPP_LOGD("client", "requests=%ld", counter) + OATPP_LOGd("client", "requests={}", counter) } } diff --git a/test/oatpp/web/FullAsyncClientTest.cpp b/test/oatpp/web/FullAsyncClientTest.cpp index ac7e2d45..8d4426ed 100644 --- a/test/oatpp/web/FullAsyncClientTest.cpp +++ b/test/oatpp/web/FullAsyncClientTest.cpp @@ -155,9 +155,9 @@ public: Action handleError(Error* error) override { if(error->is()) { auto e = static_cast(error); - OATPP_LOGE("[FullAsyncClientTest::ClientCoroutine_getRootAsync::handleError()]", "AsyncIOError. %s, %ld", e->what(), e->getCode()) + OATPP_LOGe("[FullAsyncClientTest::ClientCoroutine_getRootAsync::handleError()]", "AsyncIOError. {}, {}", e->what(), e->getCode()) } else { - OATPP_LOGE("[FullAsyncClientTest::ClientCoroutine_getRootAsync::handleError()]", "Error. %s", error->what()) + OATPP_LOGe("[FullAsyncClientTest::ClientCoroutine_getRootAsync::handleError()]", "Error. {}", error->what()) } OATPP_ASSERT(!"Error") } @@ -196,9 +196,9 @@ public: Action handleError(Error* error) override { if(error->is()) { auto e = static_cast(error); - OATPP_LOGE("[FullAsyncClientTest::ClientCoroutine_postBodyAsync::handleError()]", "AsyncIOError. %s, %ld", e->what(), e->getCode()) + OATPP_LOGe("[FullAsyncClientTest::ClientCoroutine_postBodyAsync::handleError()]", "AsyncIOError. {}, {}", e->what(), e->getCode()) } else { - OATPP_LOGE("[FullAsyncClientTest::ClientCoroutine_postBodyAsync::handleError()]", "Error. %s", error->what()) + OATPP_LOGe("[FullAsyncClientTest::ClientCoroutine_postBodyAsync::handleError()]", "Error. {}", error->what()) } OATPP_ASSERT(!"Error") } @@ -242,9 +242,9 @@ public: if(error) { if(error->is()) { auto e = static_cast(error); - OATPP_LOGE("[FullAsyncClientTest::ClientCoroutine_echoBodyAsync::handleError()]", "AsyncIOError. %s, %ld", e->what(), e->getCode()) + OATPP_LOGe("[FullAsyncClientTest::ClientCoroutine_echoBodyAsync::handleError()]", "AsyncIOError. {}, {}", e->what(), e->getCode()) } else { - OATPP_LOGE("[FullAsyncClientTest::ClientCoroutine_echoBodyAsync::handleError()]", "Error. %s", error->what()) + OATPP_LOGe("[FullAsyncClientTest::ClientCoroutine_echoBodyAsync::handleError()]", "Error. {}", error->what()) } } OATPP_ASSERT(!"Error") @@ -286,7 +286,7 @@ void FullAsyncClientTest::onRun() { ClientCoroutine_echoBodyAsync::SUCCESS_COUNTER != -1 ) { - OATPP_LOGV("Client", "Root=%d, postBody=%d, echoBody=%d", + OATPP_LOGv("Client", "Root={}, postBody={}, echoBody={}", ClientCoroutine_getRootAsync::SUCCESS_COUNTER.load(), ClientCoroutine_postBodyAsync::SUCCESS_COUNTER.load(), ClientCoroutine_echoBodyAsync::SUCCESS_COUNTER.load() @@ -296,15 +296,15 @@ void FullAsyncClientTest::onRun() { if(ClientCoroutine_getRootAsync::SUCCESS_COUNTER == iterations){ ClientCoroutine_getRootAsync::SUCCESS_COUNTER = -1; - OATPP_LOGV("Client", "getRootAsync - DONE!") + OATPP_LOGv("Client", "getRootAsync - DONE!") } if(ClientCoroutine_postBodyAsync::SUCCESS_COUNTER == iterations){ ClientCoroutine_postBodyAsync::SUCCESS_COUNTER = -1; - OATPP_LOGV("Client", "postBodyAsync - DONE!") + OATPP_LOGv("Client", "postBodyAsync - DONE!") } if(ClientCoroutine_echoBodyAsync::SUCCESS_COUNTER == iterations){ ClientCoroutine_echoBodyAsync::SUCCESS_COUNTER = -1; - OATPP_LOGV("Client", "echoBodyAsync - DONE!") + OATPP_LOGv("Client", "echoBodyAsync - DONE!") } } diff --git a/test/oatpp/web/FullAsyncTest.cpp b/test/oatpp/web/FullAsyncTest.cpp index 9aa06de6..db1f8195 100644 --- a/test/oatpp/web/FullAsyncTest.cpp +++ b/test/oatpp/web/FullAsyncTest.cpp @@ -164,7 +164,7 @@ void FullAsyncTest::onRun() { for(v_int32 i = 0; i < iterationsStep * 10; i ++) { - //OATPP_LOGV("i", "%d", i) + //OATPP_LOGv("i", "{}", i) { // test simple GET auto response = client->getRoot(connection); @@ -281,7 +281,7 @@ void FullAsyncTest::onRun() { if((i + 1) % iterationsStep == 0) { auto ticks = oatpp::Environment::getMicroTickCount() - lastTick; lastTick = oatpp::Environment::getMicroTickCount(); - OATPP_LOGV("i", "%d, tick=%ld", i + 1, ticks) + OATPP_LOGv("i", "{}, tick={}", i + 1, ticks) } } diff --git a/test/oatpp/web/FullTest.cpp b/test/oatpp/web/FullTest.cpp index b9c1900c..2cab184b 100644 --- a/test/oatpp/web/FullTest.cpp +++ b/test/oatpp/web/FullTest.cpp @@ -545,7 +545,7 @@ void FullTest::onRun() { if((i + 1) % iterationsStep == 0) { auto ticks = oatpp::Environment::getMicroTickCount() - lastTick; lastTick = oatpp::Environment::getMicroTickCount(); - OATPP_LOGV("i", "%d, tick=%ld", i + 1, ticks) + OATPP_LOGv("i", "{}, tick={}", i + 1, ticks) } { // test bundle diff --git a/test/oatpp/web/PipelineTest.cpp b/test/oatpp/web/PipelineTest.cpp index 2557d62e..0b6c675e 100644 --- a/test/oatpp/web/PipelineTest.cpp +++ b/test/oatpp/web/PipelineTest.cpp @@ -145,7 +145,7 @@ void PipelineTest::onRun() { } auto dataToSend = pipelineStream.toString(); - OATPP_LOGD(TAG, "Sending %lu bytes", dataToSend->size()) + OATPP_LOGd(TAG, "Sending {} bytes", dataToSend->size()) oatpp::data::stream::BufferInputStream inputStream(dataToSend); @@ -163,7 +163,7 @@ void PipelineTest::onRun() { v_io_size transferSize = static_cast(sample->size() * static_cast(m_pipelineSize)); - OATPP_LOGD(TAG, "want to Receive %ld bytes", transferSize) + OATPP_LOGd(TAG, "want to Receive {} bytes", transferSize) oatpp::data::stream::transfer(connection.object.get(), &receiveStream, transferSize, ioBuffer.getData(), ioBuffer.getSize()); auto result = receiveStream.toString(); diff --git a/test/oatpp/web/app/Controller.hpp b/test/oatpp/web/app/Controller.hpp index 56df684d..578c3f35 100644 --- a/test/oatpp/web/app/Controller.hpp +++ b/test/oatpp/web/app/Controller.hpp @@ -70,16 +70,16 @@ public: std::atomic available; ENDPOINT("GET", "/", root) { - //OATPP_LOGD(TAG, "GET ROOT") + //OATPP_LOGd(TAG, "GET ROOT") return createResponse(Status::CODE_200, "Hello World!!!"); } ENDPOINT("GET", "/availability", availability) { - //OATPP_LOGV(TAG, "GET '/availability'") + //OATPP_LOGv(TAG, "GET '/availability'") if(available) { return createResponse(Status::CODE_200, "Hello World!!!"); } - OATPP_LOGI(TAG, "GET '/availability'. Service unavailable.") + OATPP_LOGi(TAG, "GET '/availability'. Service unavailable.") OATPP_ASSERT_HTTP(false, Status::CODE_503, "Service unavailable") } @@ -105,7 +105,7 @@ public: ENDPOINT("GET", "params/{param}", getWithParams, PATH(String, param)) { - //OATPP_LOGV(TAG, "GET params/%s", param->c_str()) + //OATPP_LOGv(TAG, "GET params/{}", param) auto dto = TestDto::createShared(); dto->testValue = param; return createDtoResponse(Status::CODE_200, dto); @@ -137,7 +137,7 @@ public: ENDPOINT("GET", "headers", getWithHeaders, HEADER(String, param, "X-TEST-HEADER")) { - //OATPP_LOGV(TAG, "GET headers {X-TEST-HEADER: %s}", param->c_str()) + //OATPP_LOGv(TAG, "GET headers {X-TEST-HEADER: {}}", param) auto dto = TestDto::createShared(); dto->testValue = param; return createDtoResponse(Status::CODE_200, dto); @@ -145,7 +145,7 @@ public: ENDPOINT("POST", "body", postBody, BODY_STRING(String, body)) { - //OATPP_LOGV(TAG, "POST body %s", body->c_str()) + //OATPP_LOGv(TAG, "POST body {}", body) auto dto = TestDto::createShared(); dto->testValue = body; return createDtoResponse(Status::CODE_200, dto); @@ -153,13 +153,13 @@ public: ENDPOINT("POST", "body-dto", postBodyDto, BODY_DTO(Object, body)) { - //OATPP_LOGV(TAG, "POST body %s", body->c_str()) + //OATPP_LOGv(TAG, "POST body {}", body->c_str()) return createDtoResponse(Status::CODE_200, body); } ENDPOINT("POST", "echo", echo, BODY_STRING(String, body)) { - //OATPP_LOGV(TAG, "POST body(echo) size=%d", body->getSize()) + //OATPP_LOGv(TAG, "POST body(echo) size={}", body->getSize()) return createResponse(Status::CODE_200, body); } @@ -283,14 +283,14 @@ public: request->transferBody(&multipartReader); /* Print number of uploaded parts */ - OATPP_LOGD("Multipart", "parts_count=%ld", multipart->count()) + OATPP_LOGd("Multipart", "parts_count={}", multipart->count()) /* Print value of "part1" */ auto part1 = multipart->getNamedPart("part1"); OATPP_ASSERT_HTTP(part1, Status::CODE_400, "part1 is empty") - OATPP_LOGD("Multipart", "part1='%s'", part1->getPayload()->getInMemoryData()->c_str()) + OATPP_LOGd("Multipart", "part1='{}'", part1->getPayload()->getInMemoryData()) /* Get part by name "part2"*/ auto filePart = multipart->getNamedPart("part2"); @@ -344,7 +344,7 @@ public: ++ counter; - OATPP_LOGD("Multipart", "Frame sent!") + OATPP_LOGd("Multipart", "Frame sent!") return part; diff --git a/test/oatpp/web/app/ControllerAsync.hpp b/test/oatpp/web/app/ControllerAsync.hpp index 1187c77c..1f7e3de7 100644 --- a/test/oatpp/web/app/ControllerAsync.hpp +++ b/test/oatpp/web/app/ControllerAsync.hpp @@ -69,7 +69,7 @@ public: ENDPOINT_ASYNC_INIT(Root) Action act() override { - //OATPP_LOGV(TAG, "GET '/'") + //OATPP_LOGv(TAG, "GET '/'") return _return(controller->createResponse(Status::CODE_200, "Hello World Async!!!")); } @@ -81,7 +81,7 @@ public: Action act() override { auto param = request->getPathVariable("param"); - //OATPP_LOGV(TAG, "GET params/%s", param->c_str()) + //OATPP_LOGv(TAG, "GET params/{}", param) auto dto = TestDto::createShared(); dto->testValue = param; return _return(controller->createDtoResponse(Status::CODE_200, dto)); @@ -95,7 +95,7 @@ public: Action act() override { auto param = request->getHeader("X-TEST-HEADER"); - //OATPP_LOGV(TAG, "GET headers {X-TEST-HEADER: %s}", param->c_str()) + //OATPP_LOGv(TAG, "GET headers {X-TEST-HEADER: {}}", param) auto dto = TestDto::createShared(); dto->testValue = param; return _return(controller->createDtoResponse(Status::CODE_200, dto)); @@ -108,12 +108,12 @@ public: ENDPOINT_ASYNC_INIT(PostBody) Action act() override { - //OATPP_LOGV(TAG, "POST body. Reading body...") + //OATPP_LOGv(TAG, "POST body. Reading body...") return request->readBodyToStringAsync().callbackTo(&PostBody::onBodyRead); } Action onBodyRead(const String& body) { - //OATPP_LOGV(TAG, "POST body %s", body->c_str()) + //OATPP_LOGv(TAG, "POST body {}", body) auto dto = TestDto::createShared(); dto->testValue = body; return _return(controller->createDtoResponse(Status::CODE_200, dto)); @@ -126,12 +126,12 @@ public: ENDPOINT_ASYNC_INIT(Echo) Action act() override { - //OATPP_LOGV(TAG, "POST body(echo). Reading body...") + //OATPP_LOGv(TAG, "POST body(echo). Reading body...") return request->readBodyToStringAsync().callbackTo(&Echo::onBodyRead); } Action onBodyRead(const String& body) { - //OATPP_LOGV(TAG, "POST echo size=%d", body->getSize()) + //OATPP_LOGv(TAG, "POST echo size={}", body->getSize()) return _return(controller->createResponse(Status::CODE_200, body)); } @@ -259,7 +259,7 @@ public: Action onUploaded() { /* Print number of uploaded parts */ - OATPP_LOGD("Multipart", "parts_count=%ld", m_multipart->count()) + OATPP_LOGd("Multipart", "parts_count={}", m_multipart->count()) /* Get multipart by name */ auto part1 = m_multipart->getNamedPart("part1"); @@ -268,7 +268,7 @@ public: OATPP_ASSERT_HTTP(part1, Status::CODE_400, "part1 is empty") /* Print value of "part1" */ - OATPP_LOGD("Multipart", "part1='%s'", part1->getPayload()->getInMemoryData()->c_str()) + OATPP_LOGd("Multipart", "part1='{}'", part1->getPayload()->getInMemoryData()) /* Get multipart by name */ auto filePart = m_multipart->getNamedPart("part2"); @@ -333,7 +333,7 @@ public: ++ counter; - OATPP_LOGD("Multipart", "Frame sent!") + OATPP_LOGd("Multipart", "Frame sent!") return part; diff --git a/test/oatpp/web/mime/ContentMappersTest.cpp b/test/oatpp/web/mime/ContentMappersTest.cpp index faeab178..7220c0d9 100644 --- a/test/oatpp/web/mime/ContentMappersTest.cpp +++ b/test/oatpp/web/mime/ContentMappersTest.cpp @@ -56,7 +56,7 @@ public: void ContentMappersTest::onRun() { { - OATPP_LOGD(TAG, "case 1 - default mapper") + OATPP_LOGd(TAG, "case 1 - default mapper") ContentMappers mappers; mappers.putMapper(std::make_shared("application", "json")); auto m = mappers.getMapper("APPLICATION/JSON"); @@ -66,7 +66,7 @@ void ContentMappersTest::onRun() { } { - OATPP_LOGD(TAG, "case 2 - default mapper") + OATPP_LOGd(TAG, "case 2 - default mapper") ContentMappers mappers; mappers.putMapper(std::make_shared("application", "json")); mappers.putMapper(std::make_shared("text", "html")); @@ -79,7 +79,7 @@ void ContentMappersTest::onRun() { } { - OATPP_LOGD(TAG, "case 3 - default mapper") + OATPP_LOGd(TAG, "case 3 - default mapper") ContentMappers mappers; mappers.putMapper(std::make_shared("application", "json")); mappers.putMapper(std::make_shared("text", "html")); @@ -95,7 +95,7 @@ void ContentMappersTest::onRun() { { - OATPP_LOGD(TAG, "case 4 - select mapper") + OATPP_LOGd(TAG, "case 4 - select mapper") ContentMappers mappers; mappers.putMapper(std::make_shared("application", "json")); mappers.putMapper(std::make_shared("text", "html")); @@ -108,7 +108,7 @@ void ContentMappersTest::onRun() { } { - OATPP_LOGD(TAG, "case 5 - select mapper") + OATPP_LOGd(TAG, "case 5 - select mapper") ContentMappers mappers; mappers.putMapper(std::make_shared("application", "json")); mappers.putMapper(std::make_shared("text", "html")); @@ -121,7 +121,7 @@ void ContentMappersTest::onRun() { } { - OATPP_LOGD(TAG, "case 6 - select mapper") + OATPP_LOGd(TAG, "case 6 - select mapper") ContentMappers mappers; mappers.putMapper(std::make_shared("application", "json")); mappers.putMapper(std::make_shared("text", "html")); @@ -134,7 +134,7 @@ void ContentMappersTest::onRun() { } { - OATPP_LOGD(TAG, "case 7 - select mapper - corrupted input") + OATPP_LOGd(TAG, "case 7 - select mapper - corrupted input") ContentMappers mappers; mappers.putMapper(std::make_shared("application", "json")); mappers.putMapper(std::make_shared("text", "html")); @@ -156,7 +156,7 @@ void ContentMappersTest::onRun() { richMappers.putMapper(std::make_shared("text", "html")); { - OATPP_LOGD(TAG, "case 8 - select mapper - empty") + OATPP_LOGd(TAG, "case 8 - select mapper - empty") auto m = richMappers.selectMapper( "" ); @@ -164,7 +164,7 @@ void ContentMappersTest::onRun() { } { - OATPP_LOGD(TAG, "case 9 - select mapper - corrupted input") + OATPP_LOGd(TAG, "case 9 - select mapper - corrupted input") auto m = richMappers.selectMapper( "application/*;q=0.8, text/*;q=0.9, *.*" ); @@ -172,7 +172,7 @@ void ContentMappersTest::onRun() { } { - OATPP_LOGD(TAG, "case 10 - select mapper ") + OATPP_LOGd(TAG, "case 10 - select mapper ") auto m = richMappers.selectMapper( "application/*;q=0.8, text/*;q=0.9, */*" ); @@ -180,7 +180,7 @@ void ContentMappersTest::onRun() { } { - OATPP_LOGD(TAG, "case 11 - select mapper ") + OATPP_LOGd(TAG, "case 11 - select mapper ") auto m = richMappers.selectMapper( "application/*;q=0.9, text/*;q=0.8" ); diff --git a/test/oatpp/web/mime/multipart/StatefulParserTest.cpp b/test/oatpp/web/mime/multipart/StatefulParserTest.cpp index e94d7760..7e552b1e 100644 --- a/test/oatpp/web/mime/multipart/StatefulParserTest.cpp +++ b/test/oatpp/web/mime/multipart/StatefulParserTest.cpp @@ -122,7 +122,7 @@ void StatefulParserTest::onRun() { parseStepByStep(text, "12345", listener, i); if(multipart.count() != 5) { - OATPP_LOGD(TAG, "TEST_DATA_1 itearation %lu", i) + OATPP_LOGd(TAG, "TEST_DATA_1 itearation {}", i) } OATPP_ASSERT(multipart.count() == 5) diff --git a/test/oatpp/web/protocol/http/encoding/ChunkedTest.cpp b/test/oatpp/web/protocol/http/encoding/ChunkedTest.cpp index a7075211..4319edf2 100644 --- a/test/oatpp/web/protocol/http/encoding/ChunkedTest.cpp +++ b/test/oatpp/web/protocol/http/encoding/ChunkedTest.cpp @@ -94,7 +94,7 @@ void ChunkedTest::onRun() { auto count = oatpp::data::stream::transfer(&inStream, &outStream, 0, buffer, bufferSize, &decoder); decoded = outStream.toString(); OATPP_ASSERT(count == static_cast(encoded->size())) - OATPP_LOGD(TAG, "decoded='%s'", decoded->c_str()) + OATPP_LOGd(TAG, "decoded='{}'", decoded) OATPP_ASSERT(decoded == data) } @@ -115,7 +115,7 @@ void ChunkedTest::onRun() { auto count = oatpp::data::stream::transfer(&inStream, &outStream, 0, buffer, bufferSize, &pipeline); auto result = outStream.toString(); OATPP_ASSERT(count == static_cast(data->size())) - OATPP_LOGD(TAG, "result='%s'", result->c_str()) + OATPP_LOGd(TAG, "result='{}'", result) OATPP_ASSERT(result == data) } diff --git a/test/oatpp/web/server/HttpRouterTest.cpp b/test/oatpp/web/server/HttpRouterTest.cpp index dbd5b68b..458fd556 100644 --- a/test/oatpp/web/server/HttpRouterTest.cpp +++ b/test/oatpp/web/server/HttpRouterTest.cpp @@ -49,7 +49,7 @@ void HttpRouterTest::onRun() { router.route("POST", "*", -100); { - OATPP_LOGI(TAG, "Case 1") + OATPP_LOGi(TAG, "Case 1") auto r = router.getRoute("GET", "ints/1"); OATPP_ASSERT(r.isValid()) OATPP_ASSERT(r) @@ -57,7 +57,7 @@ void HttpRouterTest::onRun() { } { - OATPP_LOGI(TAG, "Case 2") + OATPP_LOGi(TAG, "Case 2") auto r = router.getRoute("GET", "/ints/1"); OATPP_ASSERT(r.isValid()) OATPP_ASSERT(r) @@ -65,7 +65,7 @@ void HttpRouterTest::onRun() { } { - OATPP_LOGI(TAG, "Case 3") + OATPP_LOGi(TAG, "Case 3") auto r = router.getRoute("GET", "ints/1//"); OATPP_ASSERT(r.isValid()) OATPP_ASSERT(r) @@ -73,7 +73,7 @@ void HttpRouterTest::onRun() { } { - OATPP_LOGI(TAG, "Case 4") + OATPP_LOGi(TAG, "Case 4") auto r = router.getRoute("GET", "//ints///1//"); OATPP_ASSERT(r.isValid()) OATPP_ASSERT(r) @@ -81,14 +81,14 @@ void HttpRouterTest::onRun() { } { - OATPP_LOGI(TAG, "Case 5") + OATPP_LOGi(TAG, "Case 5") auto r = router.getRoute("GET", "ints/1/*"); OATPP_ASSERT(r.isValid() == false) OATPP_ASSERT(!r) } { - OATPP_LOGI(TAG, "Case 6") + OATPP_LOGi(TAG, "Case 6") auto r = router.getRoute("GET", "ints/2"); OATPP_ASSERT(r.isValid()) OATPP_ASSERT(r) @@ -96,7 +96,7 @@ void HttpRouterTest::onRun() { } { - OATPP_LOGI(TAG, "Case 7") + OATPP_LOGi(TAG, "Case 7") auto r = router.getRoute("GET", "ints/all/10"); OATPP_ASSERT(r.isValid()) OATPP_ASSERT(r) @@ -106,7 +106,7 @@ void HttpRouterTest::onRun() { } { - OATPP_LOGI(TAG, "Case 8") + OATPP_LOGi(TAG, "Case 8") auto r = router.getRoute("GET", "//ints//all//10//"); OATPP_ASSERT(r.isValid()) OATPP_ASSERT(r) @@ -116,14 +116,14 @@ void HttpRouterTest::onRun() { } { - OATPP_LOGI(TAG, "Case 9") + OATPP_LOGi(TAG, "Case 9") auto r = router.getRoute("GET", "//ints//all//10//*"); OATPP_ASSERT(r.isValid() == false) OATPP_ASSERT(!r) } { - OATPP_LOGI(TAG, "Case 10") + OATPP_LOGi(TAG, "Case 10") auto r = router.getRoute("POST", "ints/1"); OATPP_ASSERT(r.isValid()) OATPP_ASSERT(r) @@ -131,7 +131,7 @@ void HttpRouterTest::onRun() { } { - OATPP_LOGI(TAG, "Case 11") + OATPP_LOGi(TAG, "Case 11") auto r = router.getRoute("POST", "ints/2"); OATPP_ASSERT(r.isValid()) OATPP_ASSERT(r) @@ -139,7 +139,7 @@ void HttpRouterTest::onRun() { } { - OATPP_LOGI(TAG, "Case 12") + OATPP_LOGi(TAG, "Case 12") auto r = router.getRoute("POST", "ints/3"); OATPP_ASSERT(r.isValid()) OATPP_ASSERT(r) @@ -149,7 +149,7 @@ void HttpRouterTest::onRun() { } { - OATPP_LOGI(TAG, "Case 13") + OATPP_LOGi(TAG, "Case 13") auto r = router.getRoute("POST", "ints/3/10"); OATPP_ASSERT(r.isValid()) OATPP_ASSERT(r) @@ -158,7 +158,7 @@ void HttpRouterTest::onRun() { } { - OATPP_LOGI(TAG, "Case 14") + OATPP_LOGi(TAG, "Case 14") auto r = router.getRoute("POST", "abc"); OATPP_ASSERT(r.isValid()) OATPP_ASSERT(r) @@ -167,7 +167,7 @@ void HttpRouterTest::onRun() { } { - OATPP_LOGI(TAG, "Case 15") + OATPP_LOGi(TAG, "Case 15") auto r = router.getRoute("GET", "ints/1?q1=1&q2=2"); OATPP_ASSERT(r.isValid()) OATPP_ASSERT(r) @@ -176,7 +176,7 @@ void HttpRouterTest::onRun() { } { - OATPP_LOGI(TAG, "Case 16") + OATPP_LOGi(TAG, "Case 16") auto r = router.getRoute("GET", "ints/all/3?q1=1&q2=2"); OATPP_ASSERT(r.isValid()) OATPP_ASSERT(r) diff --git a/test/oatpp/web/server/ServerStopTest.cpp b/test/oatpp/web/server/ServerStopTest.cpp index 6401cd2a..637186f9 100644 --- a/test/oatpp/web/server/ServerStopTest.cpp +++ b/test/oatpp/web/server/ServerStopTest.cpp @@ -118,9 +118,9 @@ runServer(const std::shared_ptr& conne std::thread t([server, connectionHandler] { server->run(); - OATPP_LOGD("TEST", "server stopped") + OATPP_LOGd("TEST", "server stopped") connectionHandler->stop(); - OATPP_LOGD("TEST", "connectionHandler stopped") + OATPP_LOGd("TEST", "connectionHandler stopped") }); t.detach(); @@ -142,13 +142,13 @@ runAsyncServer(const std::shared_ptr& std::thread t([server, connectionHandler, executor] { server->run(); - OATPP_LOGD("TEST_ASYNC", "server stopped") + OATPP_LOGd("TEST_ASYNC", "server stopped") connectionHandler->stop(); - OATPP_LOGD("TEST_ASYNC", "connectionHandler stopped") + OATPP_LOGd("TEST_ASYNC", "connectionHandler stopped") executor->waitTasksFinished(); executor->stop(); executor->join(); - OATPP_LOGD("TEST_ASYNC", "executor stopped") + OATPP_LOGd("TEST_ASYNC", "executor stopped") }); t.detach(); @@ -166,7 +166,7 @@ void runClient(const std::shared_ptr& auto data = response->readBodyToString(); OATPP_ASSERT(data) - OATPP_LOGD("TEST", "data->size() == %lu", data->size()) + OATPP_LOGd("TEST", "data->size() == {}", data->size()) } @@ -187,9 +187,9 @@ void ServerStopTest::onRun() { } { - OATPP_LOGD(TAG, "Run Simple API test on host=%s, port=%s", - serverConnectionProvider->getProperty("host").toString()->c_str(), - serverConnectionProvider->getProperty("port").toString()->c_str()) + OATPP_LOGd(TAG, "Run Simple API test on host={}, port={}", + serverConnectionProvider->getProperty("host").toString(), + serverConnectionProvider->getProperty("port").toString()) auto server = runServer(serverConnectionProvider); std::list threads; @@ -208,13 +208,13 @@ void ServerStopTest::onRun() { /* wait connection handler to stop */ std::this_thread::sleep_for(std::chrono::seconds(5)); - OATPP_LOGD(TAG, "DONE") + OATPP_LOGd(TAG, "DONE") } { - OATPP_LOGD(TAG, "Run Async API test on host=%s, port=%s", - serverConnectionProvider->getProperty("host").toString()->c_str(), - serverConnectionProvider->getProperty("port").toString()->c_str()) + OATPP_LOGd(TAG, "Run Async API test on host={}, port={}", + serverConnectionProvider->getProperty("host").toString(), + serverConnectionProvider->getProperty("port").toString()) auto server = runAsyncServer(serverConnectionProvider); std::list threads; @@ -233,7 +233,7 @@ void ServerStopTest::onRun() { /* wait connection handler to stop */ std::this_thread::sleep_for(std::chrono::seconds(5)); - OATPP_LOGD(TAG, "DONE") + OATPP_LOGd(TAG, "DONE") } } diff --git a/test/oatpp/web/server/api/ApiControllerTest.cpp b/test/oatpp/web/server/api/ApiControllerTest.cpp index 15c90d48..e6304d60 100644 --- a/test/oatpp/web/server/api/ApiControllerTest.cpp +++ b/test/oatpp/web/server/api/ApiControllerTest.cpp @@ -117,7 +117,7 @@ void ApiControllerTest::onRun() { oatpp::data::stream::BufferOutputStream stream; response->send(&stream, &headersOutBuffer, nullptr); - OATPP_LOGD(TAG, "response:\n---\n%s\n---\n", stream.toString()->c_str()) + OATPP_LOGd(TAG, "response:\n---\n{}\n---\n", stream.toString()) } @@ -144,7 +144,7 @@ void ApiControllerTest::onRun() { oatpp::data::stream::BufferOutputStream stream; response->send(&stream, &headersOutBuffer, nullptr); - OATPP_LOGD(TAG, "response:\n---\n%s\n---\n", stream.toString()->c_str()) + OATPP_LOGd(TAG, "response:\n---\n{}\n---\n", stream.toString()) } @@ -165,7 +165,7 @@ void ApiControllerTest::onRun() { oatpp::data::stream::BufferOutputStream stream; response->send(&stream, &headersOutBuffer, nullptr); - OATPP_LOGD(TAG, "response:\n---\n%s\n---\n", stream.toString()->c_str()) + OATPP_LOGd(TAG, "response:\n---\n{}\n---\n", stream.toString()) } @@ -186,7 +186,7 @@ void ApiControllerTest::onRun() { oatpp::data::stream::BufferOutputStream stream; response->send(&stream, &headersOutBuffer, nullptr); - OATPP_LOGD(TAG, "response:\n---\n%s\n---\n", stream.toString()->c_str()) + OATPP_LOGd(TAG, "response:\n---\n{}\n---\n", stream.toString()) } diff --git a/test/oatpp/web/server/handler/AuthorizationHandlerTest.cpp b/test/oatpp/web/server/handler/AuthorizationHandlerTest.cpp index d6e492d5..08050824 100644 --- a/test/oatpp/web/server/handler/AuthorizationHandlerTest.cpp +++ b/test/oatpp/web/server/handler/AuthorizationHandlerTest.cpp @@ -60,7 +60,7 @@ void AuthorizationHandlerTest::onRun() { { MyBasicAuthorizationHandler basicAuthHandler; auto auth = std::static_pointer_cast(basicAuthHandler.handleAuthorization(header)); - OATPP_LOGV(TAG, "header=\"%s\" -> user=\"%s\" password=\"%s\"", header->c_str(), auth->userId->c_str(), auth->password->c_str()) + OATPP_LOGv(TAG, "header=\"{}\" -> user=\"{}\" password=\"{}\"", header, auth->userId, auth->password) OATPP_ASSERT(auth->userId == "foo") OATPP_ASSERT(auth->password == "bar") } @@ -68,7 +68,7 @@ void AuthorizationHandlerTest::onRun() { { oatpp::web::server::handler::BasicAuthorizationHandler defaultBasicAuthHandler; auto auth = std::static_pointer_cast(defaultBasicAuthHandler.handleAuthorization(header)); - OATPP_LOGV(TAG, "header=\"%s\" -> user=\"%s\" password=\"%s\"", header->c_str(), auth->userId->c_str(), auth->password->c_str()) + OATPP_LOGv(TAG, "header=\"{}\" -> user=\"{}\" password=\"{}\"", header, auth->userId, auth->password) OATPP_ASSERT(auth->userId == "foo") OATPP_ASSERT(auth->password == "bar") } From e0d9266faa80b7ec8f614413598f5b30daa2354d Mon Sep 17 00:00:00 2001 From: Leonid Stryzhevskyi Date: Tue, 14 May 2024 06:44:43 +0300 Subject: [PATCH 03/10] changelog: update 1.4.0 --- changelog/1.4.0.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/changelog/1.4.0.md b/changelog/1.4.0.md index 03cc9ae4..3928a71a 100644 --- a/changelog/1.4.0.md +++ b/changelog/1.4.0.md @@ -12,6 +12,7 @@ Contents: - [oatpp::Tree](#oatpptree) - [Remapper](#remapper) - [oatpp::web::mime::ContentMappers](#oatppwebmimecontentmappers) +- [New OATPP_LOGx format](#new-oatpp_logx-format) - [Restructuring](#restructuring) @@ -149,6 +150,29 @@ on `Content-Type`/`Accept` headers. } ``` +## New OATPP_LOGx format + +Now oatpp logs are type-safe. Also log formatting changed. + +#### Macro + +| old logs | new logs | +|--------------|--------------| +| `OATPP_LOGV` | `OATPP_LOGv` | +| `OATPP_LOGD` | `OATPP_LOGd` | +| `OATPP_LOGI` | `OATPP_LOGi` | +| `OATPP_LOGW` | `OATPP_LOGw` | +| `OATPP_LOGE` | `OATPP_LOGe` | + +#### Formatting + +Instead of old formatting "%s", "%d", "%f" use "{}" for any variable type: + +```cpp +OATPP_LOGd("MyController", "User: name={}, age={}", user->name, user->age) +``` + + ## Restructuring ### Files From 6de7420205bf8996310eae789550c089d3d06a23 Mon Sep 17 00:00:00 2001 From: Leonid Stryzhevskyi Date: Tue, 14 May 2024 23:43:15 +0300 Subject: [PATCH 04/10] Log: better type conversion --- src/oatpp/Environment.cpp | 2 - .../async/worker/IOEventWorker_epoll.cpp | 1 + src/oatpp/base/Log.cpp | 63 +++++++------------ src/oatpp/base/Log.hpp | 22 +++---- test/oatpp/async/LockTest.cpp | 2 +- test/oatpp/base/LogTest.cpp | 49 ++++++++++++--- 6 files changed, 72 insertions(+), 67 deletions(-) diff --git a/src/oatpp/Environment.cpp b/src/oatpp/Environment.cpp index 8a242321..6c7cb609 100644 --- a/src/oatpp/Environment.cpp +++ b/src/oatpp/Environment.cpp @@ -248,8 +248,6 @@ void Environment::checkTypes(){ v_uint32 vUInt32 = ~v_uint32(1); v_uint64 vUInt64 = ~v_uint64(1); - OATPP_LOGe("AAA", "") - OATPP_ASSERT(vInt32 < 0) OATPP_ASSERT(vInt64 < 0) OATPP_ASSERT(vUInt32 > 0) diff --git a/src/oatpp/async/worker/IOEventWorker_epoll.cpp b/src/oatpp/async/worker/IOEventWorker_epoll.cpp index 4078c1f7..f6583199 100644 --- a/src/oatpp/async/worker/IOEventWorker_epoll.cpp +++ b/src/oatpp/async/worker/IOEventWorker_epoll.cpp @@ -30,6 +30,7 @@ // epoll based implementation #include "oatpp/async/Processor.hpp" +#include "oatpp/base/Log.hpp" #include #include diff --git a/src/oatpp/base/Log.cpp b/src/oatpp/base/Log.cpp index edc5859d..706be0b2 100644 --- a/src/oatpp/base/Log.cpp +++ b/src/oatpp/base/Log.cpp @@ -93,86 +93,65 @@ LogMessage& LogMessage::operator << (bool value) { return *this; } -LogMessage& LogMessage::operator << (v_int8 value) { +LogMessage& LogMessage::operator << (int value) { if(writeNextChunk()) { - m_stream.writeAsString(value); + m_stream.writeAsString(static_cast(value)); } return *this; } -LogMessage& LogMessage::operator << (v_uint8 value) { +LogMessage& LogMessage::operator << (unsigned value) { if(writeNextChunk()) { - m_stream.writeAsString(value); + m_stream.writeAsString(static_cast(value)); } return *this; } -LogMessage& LogMessage::operator << (v_int16 value) { +LogMessage& LogMessage::operator << (long value) { if(writeNextChunk()) { - m_stream.writeAsString(value); + m_stream.writeAsString(static_cast(value)); } return *this; } -LogMessage& LogMessage::operator << (v_uint16 value) { +LogMessage& LogMessage::operator << (unsigned long value) { if(writeNextChunk()) { - m_stream.writeAsString(value); + m_stream.writeAsString(static_cast(value)); } return *this; } -LogMessage& LogMessage::operator << (v_int32 value) { - if(writeNextChunk()) { - m_stream.writeAsString(value); - } - return *this; -} - -LogMessage& LogMessage::operator << (v_uint32 value) { - if(writeNextChunk()) { - m_stream.writeAsString(value); - } - return *this; -} - -LogMessage& LogMessage::operator << (v_int64 value) { - if(writeNextChunk()) { - m_stream.writeAsString(value); - } - return *this; -} - -LogMessage& LogMessage::operator << (v_uint64 value) { - if(writeNextChunk()) { - m_stream.writeAsString(value); - } - return *this; -} - -LogMessage& LogMessage::operator << (v_buff_size value) { +LogMessage& LogMessage::operator << (long long value) { if(writeNextChunk()) { m_stream.writeAsString(static_cast(value)); } return *this; } -LogMessage& LogMessage::operator << (v_buff_usize value) { +LogMessage& LogMessage::operator << (unsigned long long value) { if(writeNextChunk()) { m_stream.writeAsString(static_cast(value)); } return *this; } -LogMessage& LogMessage::operator << (v_float32 value) { +LogMessage& LogMessage::operator << (float value) { if(writeNextChunk()) { - m_stream.writeAsString(value); + m_stream.writeAsString(static_cast(value)); } return *this; } -LogMessage& LogMessage::operator << (v_float64 value) { +LogMessage& LogMessage::operator << (double value) { if(writeNextChunk()) { - m_stream.writeAsString(value); + m_stream.writeAsString(static_cast(value)); + } + return *this; +} + +LogMessage& LogMessage::operator << (long double value) { + if(writeNextChunk()) { + m_stream.writeAsString(static_cast(value)); } return *this; } diff --git a/src/oatpp/base/Log.hpp b/src/oatpp/base/Log.hpp index 08892a1f..ef58e92e 100644 --- a/src/oatpp/base/Log.hpp +++ b/src/oatpp/base/Log.hpp @@ -53,18 +53,16 @@ public: LogMessage& operator << (const char* str); LogMessage& operator << (bool value); - LogMessage& operator << (v_int8 value); - LogMessage& operator << (v_uint8 value); - LogMessage& operator << (v_int16 value); - LogMessage& operator << (v_uint16 value); - LogMessage& operator << (v_int32 value); - LogMessage& operator << (v_uint32 value); - LogMessage& operator << (v_int64 value); - LogMessage& operator << (v_uint64 value); - LogMessage& operator << (v_buff_size value); - LogMessage& operator << (v_buff_usize value); - LogMessage& operator << (v_float32 value); - LogMessage& operator << (v_float64 value); + + LogMessage& operator << (int value); + LogMessage& operator << (unsigned value); + LogMessage& operator << (long value); + LogMessage& operator << (unsigned long value); + LogMessage& operator << (long long value); + LogMessage& operator << (unsigned long long value); + LogMessage& operator << (float value); + LogMessage& operator << (double value); + LogMessage& operator << (long double value); LogMessage& operator << (const oatpp::String& str); LogMessage& operator << (const Boolean& value); diff --git a/test/oatpp/async/LockTest.cpp b/test/oatpp/async/LockTest.cpp index 51175c7e..c051cf50 100644 --- a/test/oatpp/async/LockTest.cpp +++ b/test/oatpp/async/LockTest.cpp @@ -141,7 +141,7 @@ bool checkSymbol(char symbol, const char* data, v_buff_size size) { for (v_buff_size j = 0; j < NUM_SYMBOLS; j++) { if (data[i + j] != symbol) { - OATPP_LOGd("aaa", "j pos={}", j) + OATPP_LOGd("aaa", "j pos={}", static_cast(j)) return false; } diff --git a/test/oatpp/base/LogTest.cpp b/test/oatpp/base/LogTest.cpp index 1b51afdf..410cc51d 100644 --- a/test/oatpp/base/LogTest.cpp +++ b/test/oatpp/base/LogTest.cpp @@ -30,16 +30,45 @@ namespace oatpp::base { void LogTest::onRun() { -// oatpp::String val = "hello"; -// oatpp::Float64 fv; -// -// LogMessage msg("{} double={}, float={}"); -// -// //msg << val << fv << ""; -// -// LogMessage::log(0, TAG, msg << 1 << 2 << 3); -// -// //std::cout << msg.toStdString() << std::endl; + { + LogMessage msg("{}"); + msg << "hello"; + OATPP_ASSERT(msg.toStdString() == "hello") + } + + { + LogMessage msg("{}"); + msg << oatpp::String("hello"); + OATPP_ASSERT(msg.toStdString() == "hello") + } + + { + LogMessage msg("{}"); + msg << std::string("hello"); + OATPP_ASSERT(msg.toStdString() == "hello") + } + + { + LogMessage msg("{} {}"); + msg << true << false; + OATPP_ASSERT(msg.toStdString() == "true false") + } + + { + LogMessage msg("{} {}"); + msg << oatpp::Boolean(true) << oatpp::Boolean(false); + OATPP_ASSERT(msg.toStdString() == "true false") + } + + { + LogMessage msg("{} {} {} {} {} {} {} {}"); + msg << v_int8(-8) << v_uint8(8); + msg << v_int16(-16) << v_uint16(16); + msg << v_int32(-32) << v_uint32(32); + msg << v_int64(-64) << v_uint64(64); + OATPP_ASSERT(msg.toStdString() == "-8 8 -16 16 -32 32 -64 64") + } + OATPP_LOGv(TAG, "1={}, 2={}, 3={}", 1, 2, 3) OATPP_LOGv(TAG, "empty params") From bd3410e6c0d5759036a613de6a829c95ce52629a Mon Sep 17 00:00:00 2001 From: Leonid Stryzhevskyi Date: Wed, 15 May 2024 00:15:09 +0300 Subject: [PATCH 05/10] fix warnings on MacOS --- .../async/worker/IOEventWorker_kqueue.cpp | 21 ++++++++++++------- src/oatpp/base/Log.cpp | 4 ++-- src/oatpp/base/Log.hpp | 4 ++-- src/oatpp/data/resource/TemporaryFile.cpp | 2 +- src/oatpp/data/stream/BufferStream.cpp | 6 +++--- src/oatpp/network/Url.cpp | 2 +- src/oatpp/web/mime/multipart/Multipart.cpp | 2 +- test/oatpp/data/buffer/ProcessorTest.cpp | 2 +- test/oatpp/data/mapping/TreeTest.cpp | 8 ++++--- test/oatpp/json/DeserializerTest.cpp | 8 +++---- .../web/mime/multipart/StatefulParserTest.cpp | 4 ++-- 11 files changed, 35 insertions(+), 28 deletions(-) diff --git a/src/oatpp/async/worker/IOEventWorker_kqueue.cpp b/src/oatpp/async/worker/IOEventWorker_kqueue.cpp index 91c6345c..1358ad88 100644 --- a/src/oatpp/async/worker/IOEventWorker_kqueue.cpp +++ b/src/oatpp/async/worker/IOEventWorker_kqueue.cpp @@ -70,7 +70,7 @@ void IOEventWorker::triggerWakeup() { void IOEventWorker::setTriggerEvent(p_char8 eventPtr) { - struct kevent* event = (struct kevent*) eventPtr; + auto* event = reinterpret_cast(eventPtr); std::memset(event, 0, sizeof(struct kevent)); @@ -87,7 +87,7 @@ void IOEventWorker::setCoroutineEvent(CoroutineHandle* coroutine, int operation, switch(action.getType()) { - case Action::TYPE_IO_WAIT: break; + case Action::TYPE_IO_WAIT: case Action::TYPE_IO_REPEAT: break; default: @@ -95,10 +95,10 @@ void IOEventWorker::setCoroutineEvent(CoroutineHandle* coroutine, int operation, } - struct kevent* event = (struct kevent*) eventPtr; + auto* event = reinterpret_cast(eventPtr); std::memset(event, 0, sizeof(struct kevent)); - event->ident = action.getIOHandle(); + event->ident = static_cast(action.getIOHandle()); event->flags = EV_ADD | EV_ONESHOT; event->udata = coroutine; @@ -141,7 +141,7 @@ void IOEventWorker::consumeBacklog() { setTriggerEvent(&m_inEvents[0]); auto curr = m_backlog.first; - v_int32 i = 1; + unsigned long i = 1; while(curr != nullptr) { setCoroutineEvent(curr, 0, &m_inEvents[i * sizeof(struct kevent)]); curr = nextCoroutine(curr); @@ -156,7 +156,12 @@ void IOEventWorker::consumeBacklog() { void IOEventWorker::waitEvents() { - auto eventsCount = kevent(m_eventQueueHandle, (struct kevent*)m_inEvents.get(), m_inEventsCount, (struct kevent*)m_outEvents.get(), MAX_EVENTS,nullptr); + auto eventsCount = kevent(m_eventQueueHandle, + reinterpret_cast(m_inEvents.get()), + m_inEventsCount, + reinterpret_cast(m_outEvents.get()), + MAX_EVENTS, + nullptr); if((eventsCount < 0) && (errno != EINTR)) { OATPP_LOGe("[oatpp::async::worker::IOEventWorker::waitEvents()]", "Error:\n" @@ -174,8 +179,8 @@ void IOEventWorker::waitEvents() { for(v_int32 i = 0; i < eventsCount; i ++) { - struct kevent* event = (struct kevent *)&m_outEvents[i * sizeof(struct kevent)]; - auto coroutine = (CoroutineHandle*) event->udata; + auto* event = reinterpret_cast(&m_outEvents[static_cast(i) * sizeof(struct kevent)]); + auto coroutine = reinterpret_cast(event->udata); if((event->flags & EV_ERROR) > 0) { OATPP_LOGd("Error", "data='{}'", strerror(static_cast(event->data))) diff --git a/src/oatpp/base/Log.cpp b/src/oatpp/base/Log.cpp index 706be0b2..2a1f6326 100644 --- a/src/oatpp/base/Log.cpp +++ b/src/oatpp/base/Log.cpp @@ -27,7 +27,7 @@ #include "oatpp/utils/parser/Caret.hpp" #include "oatpp/macro/basic.hpp" -namespace oatpp::base{ +namespace oatpp { namespace base { LogMessage::LogMessage(const oatpp::String& msg) : m_msg(msg != nullptr ? msg : "") @@ -298,4 +298,4 @@ void LogMessage::log(v_uint32 priority, const LogCategory& category, const LogMe } } -} +}} diff --git a/src/oatpp/base/Log.hpp b/src/oatpp/base/Log.hpp index ef58e92e..ea830c01 100644 --- a/src/oatpp/base/Log.hpp +++ b/src/oatpp/base/Log.hpp @@ -28,7 +28,7 @@ #include "oatpp/data/stream/BufferStream.hpp" #include "oatpp/macro/basic.hpp" -namespace oatpp::base{ +namespace oatpp { namespace base{ class LogMessage { private: @@ -84,7 +84,7 @@ public: }; -} +}} #define OATPP_LOG_PARAMS(IDX, CNT, P) \ << P diff --git a/src/oatpp/data/resource/TemporaryFile.cpp b/src/oatpp/data/resource/TemporaryFile.cpp index 8f889f09..cece6df3 100644 --- a/src/oatpp/data/resource/TemporaryFile.cpp +++ b/src/oatpp/data/resource/TemporaryFile.cpp @@ -41,7 +41,7 @@ TemporaryFile::FileHandle::~FileHandle() { oatpp::String TemporaryFile::constructRandomFilename(const oatpp::String &dir, v_int32 randomWordSizeBytes, const oatpp::String &extension) { - std::unique_ptr buff(new v_char8[randomWordSizeBytes]); + std::unique_ptr buff(new v_char8[static_cast(randomWordSizeBytes)]); utils::random::Random::randomBytes(buff.get(), randomWordSizeBytes); data::stream::BufferOutputStream s(randomWordSizeBytes * 2 + 4); encoding::Hex::encode(&s, buff.get(), randomWordSizeBytes, encoding::Hex::ALPHABET_LOWER); diff --git a/src/oatpp/data/stream/BufferStream.cpp b/src/oatpp/data/stream/BufferStream.cpp index a54c3dd3..5c22e91d 100644 --- a/src/oatpp/data/stream/BufferStream.cpp +++ b/src/oatpp/data/stream/BufferStream.cpp @@ -34,7 +34,7 @@ namespace oatpp { namespace data{ namespace stream { data::stream::DefaultInitializedContext BufferOutputStream::DEFAULT_CONTEXT(data::stream::StreamType::STREAM_INFINITE); BufferOutputStream::BufferOutputStream(v_buff_size initialCapacity, const std::shared_ptr& captureData) - : m_data(new v_char8[initialCapacity]) + : m_data(new v_char8[static_cast(initialCapacity)]) , m_capacity(initialCapacity) , m_position(0) , m_maxCapacity(-1) @@ -88,7 +88,7 @@ void BufferOutputStream::reserveBytesUpfront(v_buff_size count) { throw std::runtime_error("[oatpp::data::stream::BufferOutputStream::reserveBytesUpfront()]: Error. Unable to allocate requested memory."); } - p_char8 newData = new v_char8[newCapacity]; + auto newData = new v_char8[static_cast(newCapacity)]; std::memcpy(newData, m_data, static_cast(m_position)); delete [] m_data; @@ -120,7 +120,7 @@ void BufferOutputStream::setCurrentPosition(v_buff_size position) { void BufferOutputStream::reset(v_buff_size initialCapacity) { delete [] m_data; - m_data = new v_char8[initialCapacity]; + m_data = new v_char8[static_cast(initialCapacity)]; m_capacity = initialCapacity; m_position = 0; } diff --git a/src/oatpp/network/Url.cpp b/src/oatpp/network/Url.cpp index dbfe0880..530f9da5 100644 --- a/src/oatpp/network/Url.cpp +++ b/src/oatpp/network/Url.cpp @@ -33,7 +33,7 @@ oatpp::String Url::Parser::parseScheme(oatpp::utils::parser::Caret& caret) { caret.findChar(':'); v_buff_size size = caret.getPosition() - pos0; if(size > 0) { - std::unique_ptr buff(new v_char8[size]); + std::unique_ptr buff(new v_char8[static_cast(size)]); std::memcpy(buff.get(), &caret.getData()[pos0], static_cast(size)); utils::String::lowerCase_ASCII(buff.get(), size); return oatpp::String(reinterpret_cast(buff.get()), size); diff --git a/src/oatpp/web/mime/multipart/Multipart.cpp b/src/oatpp/web/mime/multipart/Multipart.cpp index cedee75c..44aea45b 100644 --- a/src/oatpp/web/mime/multipart/Multipart.cpp +++ b/src/oatpp/web/mime/multipart/Multipart.cpp @@ -58,7 +58,7 @@ void Multipart::writeNextPartSimple(const std::shared_ptr& part) { } oatpp::String Multipart::generateRandomBoundary(v_int32 boundarySize) { - std::unique_ptr buffer(new v_char8[boundarySize]); + std::unique_ptr buffer(new v_char8[static_cast(boundarySize)]); utils::random::Random::randomBytes(buffer.get(), boundarySize); return encoding::Base64::encode(buffer.get(), boundarySize, encoding::Base64::ALPHABET_BASE64_URL_SAFE); } diff --git a/test/oatpp/data/buffer/ProcessorTest.cpp b/test/oatpp/data/buffer/ProcessorTest.cpp index 86ee0d02..28c968fd 100644 --- a/test/oatpp/data/buffer/ProcessorTest.cpp +++ b/test/oatpp/data/buffer/ProcessorTest.cpp @@ -192,7 +192,7 @@ oatpp::String runTestCase(const oatpp::String& data, v_int32 p1N, v_int32 p2N, v oatpp::base::ObjectHandle(std::make_shared(p3N)), }); - std::unique_ptr buffer(new v_char8[bufferSize]); + std::unique_ptr buffer(new v_char8[static_cast(bufferSize)]); oatpp::data::stream::transfer(&inStream, &outStream, 0, buffer.get(), bufferSize, &processor); return outStream.toString(); diff --git a/test/oatpp/data/mapping/TreeTest.cpp b/test/oatpp/data/mapping/TreeTest.cpp index c334e208..3199de7a 100644 --- a/test/oatpp/data/mapping/TreeTest.cpp +++ b/test/oatpp/data/mapping/TreeTest.cpp @@ -43,15 +43,17 @@ void testTreeValue(T value) { //node.setValue(value); node = value; auto v = node.getValue(); - OATPP_ASSERT(v == value && "value check") + OATPP_ASSERT(std::memcmp(&v, &value, sizeof(T)) == 0 && "value check") node.setValue(std::numeric_limits::min()); auto min = node.getValue(); - OATPP_ASSERT(min == std::numeric_limits::min() && "min check") + auto minLim = std::numeric_limits::min(); + OATPP_ASSERT(std::memcmp(&min, &minLim, sizeof(T)) == 0 && "min check") node.setValue(std::numeric_limits::max()); auto max = node.getValue(); - OATPP_ASSERT(max == std::numeric_limits::max() && "max check") + auto maxLim = std::numeric_limits::max(); + OATPP_ASSERT(std::memcmp(&max, &maxLim, sizeof(T)) == 0 && "max check") } diff --git a/test/oatpp/json/DeserializerTest.cpp b/test/oatpp/json/DeserializerTest.cpp index 64c47a60..e532a07f 100644 --- a/test/oatpp/json/DeserializerTest.cpp +++ b/test/oatpp/json/DeserializerTest.cpp @@ -241,28 +241,28 @@ void DeserializerTest::onRun(){ data::type::DTOWrapper obj5; try { obj5 = mapper.readFromString>(R"({"strF":null})"); - } catch (std::runtime_error& e) { + } catch (std::runtime_error&) { OATPP_LOGd(TAG, "Test5::strF is required!") } OATPP_ASSERT(obj5 == nullptr) try { auto obj6 = mapper.readFromString>(R"({"strF":null})"); - } catch (std::runtime_error& e) { + } catch (std::runtime_error&) { OATPP_ASSERT(false) } data::type::DTOWrapper obj7; try { obj7 = mapper.readFromString>(R"({"strF":"value1", "child":{"name":null}})"); - } catch (std::runtime_error& e) { + } catch (std::runtime_error&) { OATPP_LOGd(TAG, "TestChild1::name is required!") } OATPP_ASSERT(obj7 == nullptr) try { auto obj8 = mapper.readFromString>(R"({"strF":"value1", "child":{"name":null}})"); - } catch (std::runtime_error& e) { + } catch (std::runtime_error&) { OATPP_ASSERT(false) } diff --git a/test/oatpp/web/mime/multipart/StatefulParserTest.cpp b/test/oatpp/web/mime/multipart/StatefulParserTest.cpp index 7e552b1e..7e276a0e 100644 --- a/test/oatpp/web/mime/multipart/StatefulParserTest.cpp +++ b/test/oatpp/web/mime/multipart/StatefulParserTest.cpp @@ -94,8 +94,8 @@ namespace { OATPP_ASSERT(payload->getInMemoryData()) OATPP_ASSERT(payload->getInMemoryData() == value) - v_int64 bufferSize = 16; - std::unique_ptr buffer(new v_char8[bufferSize]); + v_buff_size bufferSize = 16; + std::unique_ptr buffer(new v_char8[static_cast(bufferSize)]); oatpp::data::stream::BufferOutputStream stream; oatpp::data::stream::transfer(payload->openInputStream(), &stream, 0, buffer.get(), bufferSize); From f88d4470e1dea1d1df6dd05f053b29deab5b233a Mon Sep 17 00:00:00 2001 From: Leonid Stryzhevskyi Date: Wed, 15 May 2024 00:35:22 +0300 Subject: [PATCH 06/10] clean Windows warnings --- .gitignore | 1 + test/oatpp/data/mapping/TreeTest.cpp | 2 -- test/oatpp/web/FullAsyncClientTest.cpp | 3 +++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0cdce97a..dc7fce00 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,7 @@ # idea .idea/ cmake-build-debug/ +cmake-build-debug-visual-studio/ # local build build*/ diff --git a/test/oatpp/data/mapping/TreeTest.cpp b/test/oatpp/data/mapping/TreeTest.cpp index 3199de7a..b99364f7 100644 --- a/test/oatpp/data/mapping/TreeTest.cpp +++ b/test/oatpp/data/mapping/TreeTest.cpp @@ -177,8 +177,6 @@ void TreeTest::onRun() { article["references"][0]["author"] = "Alexander"; article["references"][1]["author"] = "Leonid"; - article["references"].getVector().size(); - v_int32 value = article["pages"]; oatpp::String author = article["references"][0]["author"]; diff --git a/test/oatpp/web/FullAsyncClientTest.cpp b/test/oatpp/web/FullAsyncClientTest.cpp index 8d4426ed..c1be7f56 100644 --- a/test/oatpp/web/FullAsyncClientTest.cpp +++ b/test/oatpp/web/FullAsyncClientTest.cpp @@ -160,6 +160,7 @@ public: OATPP_LOGe("[FullAsyncClientTest::ClientCoroutine_getRootAsync::handleError()]", "Error. {}", error->what()) } OATPP_ASSERT(!"Error") + return error; } }; @@ -201,6 +202,7 @@ public: OATPP_LOGe("[FullAsyncClientTest::ClientCoroutine_postBodyAsync::handleError()]", "Error. {}", error->what()) } OATPP_ASSERT(!"Error") + return error; } }; @@ -248,6 +250,7 @@ public: } } OATPP_ASSERT(!"Error") + return error; } }; From fa0b243ab01896e9e552bf78298c25a827b8ba5a Mon Sep 17 00:00:00 2001 From: Leonid Stryzhevskyi Date: Wed, 15 May 2024 02:37:06 +0300 Subject: [PATCH 07/10] base logging use templates instead of macro --- src/oatpp/base/Log.cpp | 4 ++-- src/oatpp/base/Log.hpp | 52 ++++++++++++++++++++++-------------------- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/oatpp/base/Log.cpp b/src/oatpp/base/Log.cpp index 2a1f6326..1e98ccff 100644 --- a/src/oatpp/base/Log.cpp +++ b/src/oatpp/base/Log.cpp @@ -288,11 +288,11 @@ LogMessage& LogMessage::operator << (const Float64& value) { return *this; } -void LogMessage::log(v_uint32 priority, const std::string& tag, const LogMessage& message) { +void Log::log(v_uint32 priority, const std::string& tag, const LogMessage& message) { oatpp::Environment::log(priority, tag, message.toStdString()); } -void LogMessage::log(v_uint32 priority, const LogCategory& category, const LogMessage& message) { +void Log::log(v_uint32 priority, const LogCategory& category, const LogMessage& message) { if (category.categoryEnabled && (category.enabledPriorities & (1U << priority))) { log(priority, category.tag, message); } diff --git a/src/oatpp/base/Log.hpp b/src/oatpp/base/Log.hpp index ea830c01..1a4f3cce 100644 --- a/src/oatpp/base/Log.hpp +++ b/src/oatpp/base/Log.hpp @@ -28,7 +28,7 @@ #include "oatpp/data/stream/BufferStream.hpp" #include "oatpp/macro/basic.hpp" -namespace oatpp { namespace base{ +namespace oatpp { namespace base { class LogMessage { private: @@ -77,7 +77,27 @@ public: LogMessage& operator << (const Float32& value); LogMessage& operator << (const Float64& value); -public: +}; + +struct Log { + + static void ignore(std::initializer_list list) { + (void) list; + } + + template + static void stream(v_uint32 priority, const std::string& tag, const oatpp::String& message, Types... args) { + oatpp::base::LogMessage msg(message); + ignore({std::addressof(msg << args)...}); + log(priority, tag, msg); + } + + template + static void stream(v_uint32 priority, const LogCategory& category, const oatpp::String& message, Types... args) { + oatpp::base::LogMessage msg(message); + ignore({std::addressof(msg << args)...}); + log(priority, category, msg); + } static void log(v_uint32 priority, const std::string& tag, const LogMessage& message); static void log(v_uint32 priority, const LogCategory& category, const LogMessage& message); @@ -86,24 +106,6 @@ public: }} -#define OATPP_LOG_PARAMS(IDX, CNT, P) \ -<< P - -#define OATPP_LOG_MACRO_0(PRIORITY, TAG, MSG) \ -oatpp::base::LogMessage::log(PRIORITY, TAG, oatpp::base::LogMessage(MSG)); - -#define OATPP_LOG_MACRO_1(PRIORITY, TAG, MSG, ...) \ -oatpp::base::LogMessage::log(PRIORITY, TAG, oatpp::base::LogMessage(MSG) OATPP_MACRO_FOREACH_OR_EMPTY(OATPP_LOG_PARAMS, __VA_ARGS__)); - -/** - * General LOG macro - * @param PRIORITY - Http method ("GET", "POST", "PUT", etc.) - * @param TAG - Path to endpoint (without host) - * @param MSG - Name of the generated method - */ -#define OATPP_LOG(PRIORITY, TAG, ...) \ -OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_LOG_MACRO_, (__VA_ARGS__)) (PRIORITY, TAG, __VA_ARGS__)) - //////////////////////////// //////////////////////////// //////////////////////////// @@ -118,7 +120,7 @@ OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_LOG_MACRO_, (__VA_ARG * @param ... - optional format parameter. */ #define OATPP_LOGv(TAG, ...) \ - OATPP_LOG(oatpp::Logger::PRIORITY_V, TAG, __VA_ARGS__) + oatpp::base::Log::stream(oatpp::Logger::PRIORITY_V, TAG, __VA_ARGS__); #else #define OATPP_LOGv(TAG, ...) @@ -134,7 +136,7 @@ OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_LOG_MACRO_, (__VA_ARG * @param ... - optional format parameter. */ #define OATPP_LOGd(TAG, ...) \ - OATPP_LOG(oatpp::Logger::PRIORITY_D, TAG, __VA_ARGS__) + oatpp::base::Log::stream(oatpp::Logger::PRIORITY_D, TAG, __VA_ARGS__); #else #define OATPP_LOGd(TAG, ...) @@ -150,7 +152,7 @@ OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_LOG_MACRO_, (__VA_ARG * @param ... - optional format parameter. */ #define OATPP_LOGi(TAG, ...) \ - OATPP_LOG(oatpp::Logger::PRIORITY_I, TAG, __VA_ARGS__) + oatpp::base::Log::stream(oatpp::Logger::PRIORITY_I, TAG, __VA_ARGS__); #else #define OATPP_LOGi(TAG, ...) @@ -166,7 +168,7 @@ OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_LOG_MACRO_, (__VA_ARG * @param ... - optional format parameter. */ #define OATPP_LOGw(TAG, ...) \ - OATPP_LOG(oatpp::Logger::PRIORITY_W, TAG, __VA_ARGS__) + oatpp::base::Log::stream(oatpp::Logger::PRIORITY_W, TAG, __VA_ARGS__); #else #define OATPP_LOGw(TAG, ...) @@ -182,7 +184,7 @@ OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_LOG_MACRO_, (__VA_ARG * @param ... - optional format parameter. */ #define OATPP_LOGe(TAG, ...) \ - OATPP_LOG(oatpp::Logger::PRIORITY_E, TAG, __VA_ARGS__) + oatpp::base::Log::stream(oatpp::Logger::PRIORITY_E, TAG, __VA_ARGS__); #else #define OATPP_LOGe(TAG, ...) From 9cec285678a25594e361049e68081bb6b58d0191 Mon Sep 17 00:00:00 2001 From: Leonid Stryzhevskyi Date: Wed, 15 May 2024 02:41:15 +0300 Subject: [PATCH 08/10] Clear ubuntu warnings WIP --- .gitignore | 1 + CMakeLists.txt | 2 +- src/oatpp/async/worker/IOEventWorker_epoll.cpp | 4 +++- src/oatpp/base/Log.cpp | 8 ++++---- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index dc7fce00..74087623 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,7 @@ .idea/ cmake-build-debug/ cmake-build-debug-visual-studio/ +cmake-build-debug-wsl/ # local build build*/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 7439e4bd..280f9948 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.25 FATAL_ERROR) +cmake_minimum_required(VERSION 3.20 FATAL_ERROR) file(STRINGS "${CMAKE_CURRENT_LIST_DIR}/src/oatpp/Environment.hpp" OATPP_VERSION_MACRO REGEX "#define OATPP_VERSION \"[0-9]+.[0-9]+.[0-9]+\"$") string(REGEX REPLACE "#define OATPP_VERSION \"([0-9]+.[0-9]+.[0-9]+)\"$" "\\1" oatpp_VERSION "${OATPP_VERSION_MACRO}") diff --git a/src/oatpp/async/worker/IOEventWorker_epoll.cpp b/src/oatpp/async/worker/IOEventWorker_epoll.cpp index f6583199..d70bd07b 100644 --- a/src/oatpp/async/worker/IOEventWorker_epoll.cpp +++ b/src/oatpp/async/worker/IOEventWorker_epoll.cpp @@ -166,7 +166,9 @@ void IOEventWorker::waitEvents() { "foreman={}\n" "this={}\n" "specialization={}", - errno, m_inEventsCount, reinterpret_cast(m_foreman), reinterpret_cast(this), m_specialization) + errno, m_inEventsCount, + reinterpret_cast(m_foreman), reinterpret_cast(this), + m_specialization) throw std::runtime_error("[oatpp::async::worker::IOEventWorker::waitEvents()]: Error. Event loop failed."); } diff --git a/src/oatpp/base/Log.cpp b/src/oatpp/base/Log.cpp index 2a1f6326..3a655d83 100644 --- a/src/oatpp/base/Log.cpp +++ b/src/oatpp/base/Log.cpp @@ -95,14 +95,14 @@ LogMessage& LogMessage::operator << (bool value) { LogMessage& LogMessage::operator << (int value) { if(writeNextChunk()) { - m_stream.writeAsString(static_cast(value)); + m_stream.writeAsString(value); } return *this; } LogMessage& LogMessage::operator << (unsigned value) { if(writeNextChunk()) { - m_stream.writeAsString(static_cast(value)); + m_stream.writeAsString(value); } return *this; } @@ -137,14 +137,14 @@ LogMessage& LogMessage::operator << (unsigned long long value) { LogMessage& LogMessage::operator << (float value) { if(writeNextChunk()) { - m_stream.writeAsString(static_cast(value)); + m_stream.writeAsString(value); } return *this; } LogMessage& LogMessage::operator << (double value) { if(writeNextChunk()) { - m_stream.writeAsString(static_cast(value)); + m_stream.writeAsString(value); } return *this; } From a16b92db98cd1820190584f90bf447e8114597d8 Mon Sep 17 00:00:00 2001 From: Leonid Stryzhevskyi Date: Wed, 15 May 2024 04:03:25 +0300 Subject: [PATCH 09/10] Clean warnings Ubuntu --- src/oatpp-test/web/ClientServerTestRunner.hpp | 2 +- .../async/worker/IOEventWorker_epoll.cpp | 6 ++-- src/oatpp/base/Log.cpp | 28 +++++++++++++++++++ src/oatpp/base/Log.hpp | 4 +++ src/oatpp/data/stream/BufferStream.cpp | 2 +- src/oatpp/data/stream/FIFOStream.cpp | 6 ++-- src/oatpp/data/type/Primitive.cpp | 2 +- src/oatpp/encoding/Base64.cpp | 6 ++-- src/oatpp/json/Utils.cpp | 14 +++++----- .../network/tcp/client/ConnectionProvider.cpp | 4 +-- .../network/tcp/server/ConnectionProvider.cpp | 2 +- .../web/protocol/http/encoding/Chunked.cpp | 4 +-- .../web/protocol/http/outgoing/BufferBody.cpp | 4 +-- .../protocol/http/outgoing/MultipartBody.cpp | 4 +-- src/oatpp/web/url/mapping/Pattern.cpp | 2 +- test/oatpp/async/ConditionVariableTest.cpp | 6 ++-- test/oatpp/async/LockTest.cpp | 2 +- test/oatpp/base/LogTest.cpp | 21 +++++++++++--- test/oatpp/data/share/StringTemplateTest.cpp | 2 -- test/oatpp/encoding/UrlTest.cpp | 4 +-- 20 files changed, 84 insertions(+), 41 deletions(-) diff --git a/src/oatpp-test/web/ClientServerTestRunner.hpp b/src/oatpp-test/web/ClientServerTestRunner.hpp index 0e03e8c0..4e2a2774 100644 --- a/src/oatpp-test/web/ClientServerTestRunner.hpp +++ b/src/oatpp-test/web/ClientServerTestRunner.hpp @@ -104,7 +104,7 @@ public: m_connectionProvider->getProperty("port").toString()->c_str(), timeout.count()) - std::function condition = [&runConditionForLambda](){ + std::function condition = [&runConditionForLambda]() noexcept { return runConditionForLambda; }; diff --git a/src/oatpp/async/worker/IOEventWorker_epoll.cpp b/src/oatpp/async/worker/IOEventWorker_epoll.cpp index d70bd07b..b211e9e5 100644 --- a/src/oatpp/async/worker/IOEventWorker_epoll.cpp +++ b/src/oatpp/async/worker/IOEventWorker_epoll.cpp @@ -168,7 +168,7 @@ void IOEventWorker::waitEvents() { "specialization={}", errno, m_inEventsCount, reinterpret_cast(m_foreman), reinterpret_cast(this), - m_specialization) + static_cast(m_specialization)) throw std::runtime_error("[oatpp::async::worker::IOEventWorker::waitEvents()]: Error. Event loop failed."); } @@ -222,7 +222,7 @@ void IOEventWorker::waitEvents() { OATPP_LOGe( "[oatpp::async::worker::IOEventWorker::waitEvents()]", "Error. Call to epoll_ctl failed. operation={}, errno={}. action_code={}, worker_specialization={}", - EPOLL_CTL_DEL, errno, action.getIOEventCode(), m_specialization + EPOLL_CTL_DEL, errno, action.getIOEventCode(), static_cast(m_specialization) ) throw std::runtime_error("[oatpp::async::worker::IOEventWorker::waitEvents()]: Error. Call to epoll_ctl failed."); } @@ -239,7 +239,7 @@ void IOEventWorker::waitEvents() { OATPP_LOGe( "[oatpp::async::worker::IOEventWorker::waitEvents()]", "Error. Call to epoll_ctl failed. operation={}, errno={}. action_code={}, worker_specialization={}", - EPOLL_CTL_DEL, errno, action.getIOEventCode(), m_specialization + EPOLL_CTL_DEL, errno, action.getIOEventCode(), static_cast(m_specialization) ) throw std::runtime_error("[oatpp::async::worker::IOEventWorker::waitEvents()]: Error. Call to epoll_ctl failed."); } diff --git a/src/oatpp/base/Log.cpp b/src/oatpp/base/Log.cpp index bfba8106..673e222d 100644 --- a/src/oatpp/base/Log.cpp +++ b/src/oatpp/base/Log.cpp @@ -93,6 +93,34 @@ LogMessage& LogMessage::operator << (bool value) { return *this; } +LogMessage& LogMessage::operator << (char value) { + if(writeNextChunk()) { + m_stream.writeAsString(static_cast(value)); + } + return *this; +} + +LogMessage& LogMessage::operator << (unsigned char value) { + if(writeNextChunk()) { + m_stream.writeAsString(static_cast(value)); + } + return *this; +} + +LogMessage& LogMessage::operator << (short value) { + if(writeNextChunk()) { + m_stream.writeAsString(static_cast(value)); + } + return *this; +} + +LogMessage& LogMessage::operator << (unsigned short value) { + if(writeNextChunk()) { + m_stream.writeAsString(static_cast(value)); + } + return *this; +} + LogMessage& LogMessage::operator << (int value) { if(writeNextChunk()) { m_stream.writeAsString(value); diff --git a/src/oatpp/base/Log.hpp b/src/oatpp/base/Log.hpp index 1a4f3cce..75e44469 100644 --- a/src/oatpp/base/Log.hpp +++ b/src/oatpp/base/Log.hpp @@ -54,6 +54,10 @@ public: LogMessage& operator << (const char* str); LogMessage& operator << (bool value); + LogMessage& operator << (char value); + LogMessage& operator << (unsigned char value); + LogMessage& operator << (short value); + LogMessage& operator << (unsigned short value); LogMessage& operator << (int value); LogMessage& operator << (unsigned value); LogMessage& operator << (long value); diff --git a/src/oatpp/data/stream/BufferStream.cpp b/src/oatpp/data/stream/BufferStream.cpp index 5c22e91d..68db5564 100644 --- a/src/oatpp/data/stream/BufferStream.cpp +++ b/src/oatpp/data/stream/BufferStream.cpp @@ -193,7 +193,7 @@ BufferInputStream::BufferInputStream(const std::shared_ptr& memoryH {} BufferInputStream::BufferInputStream(const oatpp::String& data, const std::shared_ptr& captureData) - : BufferInputStream(data.getPtr(), reinterpret_cast(const_cast(data->data())), static_cast(data->size()), captureData) + : BufferInputStream(data.getPtr(), reinterpret_cast(data->data()), static_cast(data->size()), captureData) {} void BufferInputStream::reset(const std::shared_ptr& memoryHandle, diff --git a/src/oatpp/data/stream/FIFOStream.cpp b/src/oatpp/data/stream/FIFOStream.cpp index 16f2199a..bd1454ef 100644 --- a/src/oatpp/data/stream/FIFOStream.cpp +++ b/src/oatpp/data/stream/FIFOStream.cpp @@ -32,7 +32,7 @@ data::stream::DefaultInitializedContext FIFOInputStream::DEFAULT_CONTEXT(data::s FIFOInputStream::FIFOInputStream(v_buff_size initialSize) : m_memoryHandle(std::make_shared(initialSize, static_cast(0))) - , m_fifo(std::make_shared(reinterpret_cast(const_cast(m_memoryHandle->data())), m_memoryHandle->size(), 0, 0, false)) + , m_fifo(std::make_shared(reinterpret_cast(m_memoryHandle->data()), m_memoryHandle->size(), 0, 0, false)) , m_maxCapacity(-1) { } @@ -87,8 +87,8 @@ void FIFOInputStream::reserveBytesUpfront(v_buff_size count) { // ToDo: In-Memory-Resize auto newHandle = std::make_shared(newCapacity, static_cast(0)); v_io_size oldSize = m_fifo->availableToRead(); - m_fifo->read(reinterpret_cast(const_cast(newHandle->data())), oldSize); - auto newFifo = std::make_shared(reinterpret_cast(const_cast(newHandle->data())), newHandle->size(), 0, oldSize, oldSize > 0); + m_fifo->read(reinterpret_cast(newHandle->data()), oldSize); + auto newFifo = std::make_shared(reinterpret_cast(newHandle->data()), newHandle->size(), 0, oldSize, oldSize > 0); m_memoryHandle = newHandle; m_fifo = newFifo; } diff --git a/src/oatpp/data/type/Primitive.cpp b/src/oatpp/data/type/Primitive.cpp index 6ad660e7..e652f2b6 100644 --- a/src/oatpp/data/type/Primitive.cpp +++ b/src/oatpp/data/type/Primitive.cpp @@ -45,7 +45,7 @@ String String::loadFromFile(const char* filename) { if (file.is_open()) { auto result = data::type::String(file.tellg()); file.seekg(0, std::ios::beg); - file.read(const_cast(result->data()), static_cast(result->size())); + file.read(result->data(), static_cast(result->size())); file.close(); return result; } diff --git a/src/oatpp/encoding/Base64.cpp b/src/oatpp/encoding/Base64.cpp index e07f1cf1..f4bc8466 100644 --- a/src/oatpp/encoding/Base64.cpp +++ b/src/oatpp/encoding/Base64.cpp @@ -109,8 +109,8 @@ oatpp::String Base64::encode(const void* data, v_buff_size size, const char* alp auto result = oatpp::String(resultSize); - p_char8 bdata = reinterpret_cast(const_cast(data)); - p_char8 resultData = reinterpret_cast(const_cast(result->data())); + auto bdata = reinterpret_cast(data); + auto resultData = reinterpret_cast(result->data()); v_buff_size pos = 0; while (pos + 2 < size) { @@ -159,7 +159,7 @@ oatpp::String Base64::decode(const char* data, v_buff_size size, const char* aux } auto result = oatpp::String(resultSize); - p_char8 resultData = reinterpret_cast(const_cast(result->data())); + auto resultData = reinterpret_cast(result->data()); v_buff_size pos = 0; while (pos + 3 < base64StrLength) { v_char8 b0 = getAlphabetCharIndex(static_cast(data[pos]), auxiliaryChars); diff --git a/src/oatpp/json/Utils.cpp b/src/oatpp/json/Utils.cpp index 22903d47..ff520d1c 100644 --- a/src/oatpp/json/Utils.cpp +++ b/src/oatpp/json/Utils.cpp @@ -225,8 +225,8 @@ oatpp::String Utils::escapeString(const char* data, v_buff_size size, v_uint32 f if(escapedSize == size) { return String(data, size); } - auto result = String(escapedSize); - p_char8 resultData = reinterpret_cast(const_cast(result->data())); + String result(escapedSize); + auto resultData = reinterpret_cast(result->data()); v_buff_size pos = 0; { @@ -375,11 +375,11 @@ oatpp::String Utils::unescapeString(const char* data, v_buff_size size, v_int64& if(errorCode != 0){ return nullptr; } - auto result = String(unescapedSize); + String result(unescapedSize); if(unescapedSize == size) { - std::memcpy(reinterpret_cast(const_cast(result->data())), data, static_cast(size)); + std::memcpy(reinterpret_cast(result->data()), data, static_cast(size)); } else { - unescapeStringToBuffer(data, size, reinterpret_cast(const_cast(result->data()))); + unescapeStringToBuffer(data, size, reinterpret_cast(result->data())); } return result; @@ -394,9 +394,9 @@ std::string Utils::unescapeStringToStdString(const char* data, v_buff_size size, std::string result; result.resize(static_cast(unescapedSize)); if(unescapedSize == size) { - std::memcpy(reinterpret_cast(const_cast(result.data())), data, static_cast(size)); + std::memcpy(reinterpret_cast(result.data()), data, static_cast(size)); } else { - unescapeStringToBuffer(data, size, reinterpret_cast(const_cast(result.data()))); + unescapeStringToBuffer(data, size, reinterpret_cast(result.data())); } return result; diff --git a/src/oatpp/network/tcp/client/ConnectionProvider.cpp b/src/oatpp/network/tcp/client/ConnectionProvider.cpp index 24af2463..2e4229d9 100644 --- a/src/oatpp/network/tcp/client/ConnectionProvider.cpp +++ b/src/oatpp/network/tcp/client/ConnectionProvider.cpp @@ -124,7 +124,7 @@ provider::ResourceHandle ConnectionProvider::get() { if(clientHandle >= 0) { - if(connect(clientHandle, currResult->ai_addr, static_cast(currResult->ai_addrlen)) == 0) { + if(connect(clientHandle, currResult->ai_addr, currResult->ai_addrlen) == 0) { break; } else { err = errno; @@ -283,7 +283,7 @@ oatpp::async::CoroutineStarterForResultai_addr, static_cast(m_currentResult->ai_addrlen)); + auto res = connect(m_clientHandle, m_currentResult->ai_addr, m_currentResult->ai_addrlen); #if defined(WIN32) || defined(_WIN32) diff --git a/src/oatpp/network/tcp/server/ConnectionProvider.cpp b/src/oatpp/network/tcp/server/ConnectionProvider.cpp index 4f14ed98..c1f2884d 100644 --- a/src/oatpp/network/tcp/server/ConnectionProvider.cpp +++ b/src/oatpp/network/tcp/server/ConnectionProvider.cpp @@ -285,7 +285,7 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){ "Warning. Failed to set {} for accepting socket: {}", "SO_REUSEADDR", strerror(errno)) } - if (bind(serverHandle, currResult->ai_addr, static_cast(currResult->ai_addrlen)) == 0 && + if (bind(serverHandle, currResult->ai_addr, currResult->ai_addrlen) == 0 && listen(serverHandle, 10000) == 0) { break; diff --git a/src/oatpp/web/protocol/http/encoding/Chunked.cpp b/src/oatpp/web/protocol/http/encoding/Chunked.cpp index d30ef524..a22ad14a 100644 --- a/src/oatpp/web/protocol/http/encoding/Chunked.cpp +++ b/src/oatpp/web/protocol/http/encoding/Chunked.cpp @@ -69,7 +69,7 @@ v_int32 EncoderChunked::iterate(data::buffer::InlineReadData& dataIn, data::buff stream.write("\r\n", 2, action); m_chunkHeader = stream.toString(); - dataOut.set(reinterpret_cast(const_cast(m_chunkHeader->data())), static_cast(m_chunkHeader->size())); + dataOut.set(reinterpret_cast(m_chunkHeader->data()), static_cast(m_chunkHeader->size())); m_firstChunk = false; m_writeChunkHeader = false; @@ -96,7 +96,7 @@ v_int32 EncoderChunked::iterate(data::buffer::InlineReadData& dataIn, data::buff stream.write("0\r\n\r\n", 5, action); m_chunkHeader = stream.toString(); - dataOut.set(reinterpret_cast(const_cast(m_chunkHeader->data())), static_cast(m_chunkHeader->size())); + dataOut.set(reinterpret_cast(m_chunkHeader->data()), static_cast(m_chunkHeader->size())); m_firstChunk = false; m_writeChunkHeader = false; diff --git a/src/oatpp/web/protocol/http/outgoing/BufferBody.cpp b/src/oatpp/web/protocol/http/outgoing/BufferBody.cpp index eb852e96..29fd3e90 100644 --- a/src/oatpp/web/protocol/http/outgoing/BufferBody.cpp +++ b/src/oatpp/web/protocol/http/outgoing/BufferBody.cpp @@ -29,7 +29,7 @@ namespace oatpp { namespace web { namespace protocol { namespace http { namespac BufferBody::BufferBody(const oatpp::String &buffer, const data::share::StringKeyLabel &contentType) : m_buffer(buffer ? buffer : "") , m_contentType(contentType) - , m_inlineData(reinterpret_cast(const_cast(m_buffer->data())), static_cast(m_buffer->size())) + , m_inlineData(reinterpret_cast(m_buffer->data()), static_cast(m_buffer->size())) {} std::shared_ptr BufferBody::createShared(const oatpp::String &buffer, @@ -67,7 +67,7 @@ void BufferBody::declareHeaders(Headers &headers) { } p_char8 BufferBody::getKnownData() { - return reinterpret_cast(const_cast(m_buffer->data())); + return reinterpret_cast(m_buffer->data()); } v_int64 BufferBody::getKnownSize() { diff --git a/src/oatpp/web/protocol/http/outgoing/MultipartBody.cpp b/src/oatpp/web/protocol/http/outgoing/MultipartBody.cpp index 5ee867ae..eb3d5c85 100644 --- a/src/oatpp/web/protocol/http/outgoing/MultipartBody.cpp +++ b/src/oatpp/web/protocol/http/outgoing/MultipartBody.cpp @@ -135,7 +135,7 @@ v_io_size MultipartBody::readBoundary(const std::shared_ptr& multipar boundary = "\r\n--" + multipart->getBoundary() + "\r\n"; } - readStream.reset(boundary.getPtr(), reinterpret_cast(const_cast(boundary->data())), static_cast(boundary->size())); + readStream.reset(boundary.getPtr(), reinterpret_cast(boundary->data()), static_cast(boundary->size())); } @@ -162,7 +162,7 @@ v_io_size MultipartBody::readHeaders(const std::shared_ptr& multipart http::Utils::writeHeaders(part->getHeaders(), &stream); stream.writeSimple("\r\n", 2); auto str = stream.toString(); - readStream.reset(str.getPtr(), reinterpret_cast(const_cast(str->data())), static_cast(str->size())); + readStream.reset(str.getPtr(), reinterpret_cast(str->data()), static_cast(str->size())); } diff --git a/src/oatpp/web/url/mapping/Pattern.cpp b/src/oatpp/web/url/mapping/Pattern.cpp index 0cff94fb..31035413 100644 --- a/src/oatpp/web/url/mapping/Pattern.cpp +++ b/src/oatpp/web/url/mapping/Pattern.cpp @@ -103,7 +103,7 @@ std::shared_ptr Pattern::parse(const char* data){ } std::shared_ptr Pattern::parse(const oatpp::String& data){ - return parse(reinterpret_cast(const_cast(data->data())), static_cast(data->size())); + return parse(reinterpret_cast(data->data()), static_cast(data->size())); } v_char8 Pattern::findSysChar(oatpp::utils::parser::Caret& caret) { diff --git a/test/oatpp/async/ConditionVariableTest.cpp b/test/oatpp/async/ConditionVariableTest.cpp index 77290ea8..178cc298 100644 --- a/test/oatpp/async/ConditionVariableTest.cpp +++ b/test/oatpp/async/ConditionVariableTest.cpp @@ -51,7 +51,7 @@ public: {} Action act() override { - return m_cv->wait(m_lockGuard, [this]{return m_resource->counter == 100;}) + return m_cv->wait(m_lockGuard, [this]() noexcept {return m_resource->counter == 100;}) .next(yieldTo(&TestCoroutineWait::onReady)); } @@ -78,7 +78,7 @@ public: {} Action act() override { - return m_cv->waitFor(m_lockGuard, [this]{return m_resource->counter == 100;}, std::chrono::seconds(5)) + return m_cv->waitFor(m_lockGuard, [this]() noexcept{return m_resource->counter == 100;}, std::chrono::seconds(5)) .next(yieldTo(&TestCoroutineWaitWithTimeout::onReady)); } @@ -105,7 +105,7 @@ public: {} Action act() override { - return m_cv->waitFor(m_lockGuard, []{return false;}, std::chrono::seconds(1)) + return m_cv->waitFor(m_lockGuard, []() noexcept{return false;}, std::chrono::seconds(1)) .next(yieldTo(&TestCoroutineTimeout::onReady)); } diff --git a/test/oatpp/async/LockTest.cpp b/test/oatpp/async/LockTest.cpp index c051cf50..51175c7e 100644 --- a/test/oatpp/async/LockTest.cpp +++ b/test/oatpp/async/LockTest.cpp @@ -141,7 +141,7 @@ bool checkSymbol(char symbol, const char* data, v_buff_size size) { for (v_buff_size j = 0; j < NUM_SYMBOLS; j++) { if (data[i + j] != symbol) { - OATPP_LOGd("aaa", "j pos={}", static_cast(j)) + OATPP_LOGd("aaa", "j pos={}", j) return false; } diff --git a/test/oatpp/base/LogTest.cpp b/test/oatpp/base/LogTest.cpp index 410cc51d..6842a7d5 100644 --- a/test/oatpp/base/LogTest.cpp +++ b/test/oatpp/base/LogTest.cpp @@ -61,11 +61,24 @@ void LogTest::onRun() { } { + + v_int8 i8 = -8; + v_uint8 u8 = 8; + + v_int16 i16 = -16; + v_uint16 u16 = 16; + + v_int32 i32 = -32; + v_uint32 u32 = 32; + + v_int64 i64 = -64; + v_uint64 u64 = 64; + LogMessage msg("{} {} {} {} {} {} {} {}"); - msg << v_int8(-8) << v_uint8(8); - msg << v_int16(-16) << v_uint16(16); - msg << v_int32(-32) << v_uint32(32); - msg << v_int64(-64) << v_uint64(64); + msg << i8 << u8; + msg << i16 << u16; + msg << i32 << u32; + msg << i64 << u64; OATPP_ASSERT(msg.toStdString() == "-8 8 -16 16 -32 32 -64 64") } diff --git a/test/oatpp/data/share/StringTemplateTest.cpp b/test/oatpp/data/share/StringTemplateTest.cpp index f7e6431d..c9901ab3 100644 --- a/test/oatpp/data/share/StringTemplateTest.cpp +++ b/test/oatpp/data/share/StringTemplateTest.cpp @@ -30,8 +30,6 @@ namespace oatpp { namespace data { namespace share { void StringTemplateTest::onRun() { - typedef oatpp::data::share::StringTemplate StringTemplate; - { OATPP_LOGi(TAG, "Case1 ...") StringTemplate t("{} World!", {{0, 1, "p1", nullptr}}); diff --git a/test/oatpp/encoding/UrlTest.cpp b/test/oatpp/encoding/UrlTest.cpp index 844883cd..1088f0d1 100644 --- a/test/oatpp/encoding/UrlTest.cpp +++ b/test/oatpp/encoding/UrlTest.cpp @@ -38,7 +38,7 @@ void UrlTest::onRun(){ for(v_int32 i = 0; i < 100; i++) { oatpp::String buff(100); - utils::random::Random::randomBytes(reinterpret_cast(const_cast(buff->data())), static_cast(buff->size())); + utils::random::Random::randomBytes(reinterpret_cast(buff->data()), static_cast(buff->size())); auto encoded = oatpp::encoding::Url::encode(buff, config); auto decoded = oatpp::encoding::Url::decode(encoded); OATPP_ASSERT(decoded == buff) @@ -51,7 +51,7 @@ void UrlTest::onRun(){ for(v_int32 i = 0; i < 100; i++) { oatpp::String buff(100); - utils::random::Random::randomBytes(reinterpret_cast(const_cast(buff->data())), static_cast(buff->size())); + utils::random::Random::randomBytes(reinterpret_cast(buff->data()), static_cast(buff->size())); auto encoded = oatpp::encoding::Url::encode(buff, config); auto decoded = oatpp::encoding::Url::decode(encoded); OATPP_ASSERT(decoded == buff) From b27b354c35d8f3f2d45a44fa9e8fc3c53cd39bbc Mon Sep 17 00:00:00 2001 From: Leonid Stryzhevskyi Date: Wed, 15 May 2024 04:27:43 +0300 Subject: [PATCH 10/10] Clear macOS warnings --- src/oatpp/web/mime/ContentMappers.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/oatpp/web/mime/ContentMappers.cpp b/src/oatpp/web/mime/ContentMappers.cpp index 071ee586..f5c334d1 100644 --- a/src/oatpp/web/mime/ContentMappers.cpp +++ b/src/oatpp/web/mime/ContentMappers.cpp @@ -53,7 +53,7 @@ std::pair ContentMappers::typeAndSubtype(const dat } void ContentMappers::putMapper(const std::shared_ptr& mapper) { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); if(m_defaultMapper == nullptr) { m_defaultMapper = mapper; } @@ -62,12 +62,12 @@ void ContentMappers::putMapper(const std::shared_ptr lock(m_mutex); m_defaultMapper = m_mappers.at(contentType); } void ContentMappers::setDefaultMapper(const std::shared_ptr& mapper) { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); m_defaultMapper = mapper; if(m_defaultMapper) { m_index[m_defaultMapper->getInfo().mimeType][m_defaultMapper->getInfo().mimeSubtype] = m_defaultMapper; @@ -76,7 +76,7 @@ void ContentMappers::setDefaultMapper(const std::shared_ptr ContentMappers::getMapper(const oatpp::String& contentType) const { - std::shared_lock lock(m_mutex); + std::shared_lock lock(m_mutex); auto it = m_mappers.find(contentType); if(it == m_mappers.end()) { return nullptr; @@ -85,7 +85,7 @@ std::shared_ptr ContentMappers::getMapper(const oat } std::shared_ptr ContentMappers::getDefaultMapper() const { - std::shared_lock lock(m_mutex); + std::shared_lock lock(m_mutex); return m_defaultMapper; } @@ -162,7 +162,7 @@ std::shared_ptr ContentMappers::selectMapper(const std::shared_ptr ContentMappers::selectMapper(const oatpp::String& acceptHeader) const { - std::shared_lock lock(m_mutex); + std::shared_lock lock(m_mutex); if(!acceptHeader || acceptHeader->empty()) { return m_defaultMapper; @@ -177,7 +177,7 @@ std::shared_ptr ContentMappers::selectMapper(const std::shared_ptr ContentMappers::selectMapper(const std::vector& acceptableContentTypes) const { - std::shared_lock lock(m_mutex); + std::shared_lock lock(m_mutex); if(acceptableContentTypes.empty()) { return m_defaultMapper; @@ -194,7 +194,7 @@ std::shared_ptr ContentMappers::selectMapper(const } void ContentMappers::clear() { - std::unique_lock lock(m_mutex); + std::unique_lock lock(m_mutex); m_defaultMapper = nullptr; m_mappers.clear(); }