From d5a2c26265985f501e446e6584c98df21d1c1216 Mon Sep 17 00:00:00 2001 From: Karim Shamazov Date: Tue, 10 Mar 2026 13:49:24 +0300 Subject: [PATCH 1/6] logs refactoring --- runtime-light/state/instance-state.h | 2 +- .../stdlib/diagnostics/contextual-logger.cpp | 32 +----------- .../stdlib/diagnostics/contextual-logger.h | 49 +++++------------- runtime-light/stdlib/diagnostics/logs.h | 51 ++++++++++++++----- runtime-light/stdlib/diagnostics/raw-logger.h | 50 ------------------ .../stdlib/system/system-functions.h | 18 +++---- 6 files changed, 64 insertions(+), 138 deletions(-) delete mode 100644 runtime-light/stdlib/diagnostics/raw-logger.h diff --git a/runtime-light/state/instance-state.h b/runtime-light/state/instance-state.h index cd855b1a5b..f55d423e40 100644 --- a/runtime-light/state/instance-state.h +++ b/runtime-light/state/instance-state.h @@ -89,7 +89,7 @@ struct InstanceState final : vk::not_copyable { } AllocatorState instance_allocator_state{INIT_INSTANCE_ALLOCATOR_SIZE, 0}; - kphp::log::contextual_logger instance_logger; + kphp::log::contextual_tags instance_tags; kphp::coro::io_scheduler io_scheduler; CoroutineInstanceState coroutine_instance_state; diff --git a/runtime-light/stdlib/diagnostics/contextual-logger.cpp b/runtime-light/stdlib/diagnostics/contextual-logger.cpp index c8b4c9711d..5a5786017a 100644 --- a/runtime-light/stdlib/diagnostics/contextual-logger.cpp +++ b/runtime-light/stdlib/diagnostics/contextual-logger.cpp @@ -7,45 +7,17 @@ #include #include #include -#include -#include -#include -#include "runtime-common/core/allocator/script-allocator.h" -#include "runtime-common/core/std/containers.h" #include "runtime-light/k2-platform/k2-api.h" #include "runtime-light/state/instance-state.h" -#include "runtime-light/stdlib/diagnostics/detail/logs.h" namespace kphp::log { -std::optional> contextual_logger::try_get() noexcept { +std::optional> contextual_tags::try_get() noexcept { if (auto* instance_state_ptr{k2::instance_state()}; instance_state_ptr != nullptr) [[likely]] { - return instance_state_ptr->instance_logger; + return instance_state_ptr->instance_tags; } return std::nullopt; } -void contextual_logger::log_with_tags(kphp::log::level level, std::optional> trace, std::string_view message) const noexcept { - kphp::stl::vector tagged_entries{}; - const bool is_extra_tags_enabled{level == level::warn || level == level::error}; - const size_t tagged_entries_size{static_cast((trace.has_value() ? 1 : 0) + (is_extra_tags_enabled ? extra_tags.size() : 0))}; - tagged_entries.reserve(tagged_entries_size); - if (is_extra_tags_enabled) { - for (const auto& [key, value] : extra_tags) { - tagged_entries.push_back(k2::LogTaggedEntry{.key = key.data(), .value = value.data(), .key_len = key.size(), .value_len = value.size()}); - } - } - if (trace.has_value()) { - static constexpr size_t BACKTRACE_BUFFER_SIZE = 1024UZ * 4UZ; - std::array backtrace_buffer; // NOLINT - size_t backtrace_size{impl::resolve_log_trace(backtrace_buffer, *trace)}; - tagged_entries.push_back( - k2::LogTaggedEntry{.key = BACKTRACE_KEY.data(), .value = backtrace_buffer.data(), .key_len = BACKTRACE_KEY.size(), .value_len = backtrace_size}); - k2::log(std::to_underlying(level), message, tagged_entries); - return; - } - k2::log(std::to_underlying(level), message, tagged_entries); -} - } // namespace kphp::log diff --git a/runtime-light/stdlib/diagnostics/contextual-logger.h b/runtime-light/stdlib/diagnostics/contextual-logger.h index b9414bca55..106ff02322 100644 --- a/runtime-light/stdlib/diagnostics/contextual-logger.h +++ b/runtime-light/stdlib/diagnostics/contextual-logger.h @@ -8,18 +8,15 @@ #include #include #include -#include #include -#include #include "common/mixin/not_copyable.h" #include "runtime-common/core/allocator/script-allocator.h" #include "runtime-common/core/std/containers.h" -#include "runtime-light/stdlib/diagnostics/detail/logs.h" namespace kphp::log { -class contextual_logger final : vk::not_copyable { +class contextual_tags final : vk::not_copyable { using tag_key_t = kphp::stl::string; using tag_value_t = kphp::stl::string; @@ -59,45 +56,27 @@ class contextual_logger final : vk::not_copyable { kphp::stl::unordered_map extra_tags; - void log_with_tags(kphp::log::level level, std::optional> trace, std::string_view message) const noexcept; - public: - template - void log(kphp::log::level level, std::optional> trace, std::format_string...> fmt, - Args&&... args) const noexcept; + size_t size() const noexcept { + return extra_tags.size(); + } + + auto begin() const noexcept { + return extra_tags.begin(); + } + + auto end() const noexcept { + return extra_tags.end(); + } void add_extra_tag(std::string_view key, std::string_view value) noexcept; void remove_extra_tag(std::string_view key) noexcept; void clear_extra_tags() noexcept; - static std::optional> try_get() noexcept; + static std::optional> try_get() noexcept; }; -template -void contextual_logger::log(kphp::log::level level, std::optional> trace, std::format_string...> fmt, - Args&&... args) const noexcept { - static constexpr size_t LOG_BUFFER_SIZE = 2048UZ; - std::array log_buffer; // NOLINT - size_t message_size{impl::format_log_message(log_buffer, fmt, std::forward(args)...)}; - auto message{std::string_view{log_buffer.data(), static_cast(message_size)}}; - log_with_tags(level, trace, message); -} - -inline void contextual_logger::add_extra_tag(std::string_view key, std::string_view value) noexcept { - if (auto it{extra_tags.find(key)}; it == extra_tags.end()) { - extra_tags.emplace(key, value); - } else { - it->second = value; - } -} - -inline void contextual_logger::remove_extra_tag(std::string_view key) noexcept { - if (auto it{extra_tags.find(key)}; it != extra_tags.end()) { - extra_tags.erase(it); - } -} - -inline void contextual_logger::clear_extra_tags() noexcept { +inline void contextual_tags::clear_extra_tags() noexcept { extra_tags.clear(); } diff --git a/runtime-light/stdlib/diagnostics/logs.h b/runtime-light/stdlib/diagnostics/logs.h index c3c5a9725a..ea30551011 100644 --- a/runtime-light/stdlib/diagnostics/logs.h +++ b/runtime-light/stdlib/diagnostics/logs.h @@ -15,20 +15,45 @@ #include "runtime-light/stdlib/diagnostics/backtrace.h" #include "runtime-light/stdlib/diagnostics/contextual-logger.h" #include "runtime-light/stdlib/diagnostics/error-handling-state.h" -#include "runtime-light/stdlib/diagnostics/raw-logger.h" namespace kphp::log { namespace impl { template -void select_logger_and_log(level level, std::optional> trace, std::format_string...> fmt, - Args&&... args) noexcept { - if (auto logger{contextual_logger::try_get()}; logger.has_value()) [[likely]] { - (*logger).get().log(level, trace, fmt, std::forward(args)...); - } else { - raw_logger::log(level, trace, fmt, std::forward(args)...); +void log(level level, std::optional> trace, std::format_string...> fmt, Args&&... args) noexcept { + static constexpr size_t LOG_BUFFER_SIZE = 2048UZ; + std::array log_buffer; // NOLINT + size_t message_size{impl::format_log_message(log_buffer, fmt, std::forward(args)...)}; + auto message{std::string_view{log_buffer.data(), static_cast(message_size)}}; + + auto opt_tags{contextual_tags::try_get().and_then([level](contextual_tags& tags) noexcept { + if (level == level::warn || level == level::error) { + return std::make_optional(std::ref(tags)); + } + return std::nullopt; + })}; + + const size_t tagged_entries_size{ + static_cast((trace.has_value() ? 1 : 0) + opt_tags.transform([](contextual_tags& tags) noexcept { return tags.size(); }).value_or(0))}; + kphp::stl::vector tagged_entries{}; + tagged_entries.reserve(tagged_entries_size); + + opt_tags.transform([&tagged_entries](contextual_tags& tags) noexcept { + for (const auto& [key, value] : tags) { + tagged_entries.push_back(k2::LogTaggedEntry{.key = key.data(), .value = value.data(), .key_len = key.size(), .value_len = value.size()}); + } + }); + if (trace.has_value()) { + static constexpr size_t BACKTRACE_BUFFER_SIZE = 1024UZ * 4UZ; + static constexpr std::string_view BACKTRACE_KEY = "trace"; + std::array backtrace_buffer; // NOLINT + size_t backtrace_size{impl::resolve_log_trace(backtrace_buffer, *trace)}; + tagged_entries.push_back( + k2::LogTaggedEntry{.key = BACKTRACE_KEY.data(), .value = backtrace_buffer.data(), .key_len = BACKTRACE_KEY.size(), .value_len = backtrace_size}); } + + k2::log(std::to_underlying(level), message, tagged_entries); } } // namespace impl @@ -37,7 +62,7 @@ void select_logger_and_log(level level, std::optional> tr // If assertion is modified, the backtrace algorithm should be updated accordingly inline void assertion(bool condition, const std::source_location& location = std::source_location::current()) noexcept { if (!condition) [[unlikely]] { - impl::select_logger_and_log(level::error, std::nullopt, "assertion failed at {}:{}", location.file_name(), location.line()); + impl::log(level::error, std::nullopt, "assertion failed at {}:{}", location.file_name(), location.line()); k2::exit(1); } } @@ -50,7 +75,7 @@ template std::array backtrace{}; const size_t num_frames{kphp::diagnostic::backtrace(backtrace)}; const std::span backtrace_view{backtrace.data(), num_frames}; - impl::select_logger_and_log(level::error, backtrace_view, fmt, std::forward(args)...); + impl::log(level::error, backtrace_view, fmt, std::forward(args)...); } k2::exit(1); } @@ -65,7 +90,7 @@ void warning(std::format_string...> fmt, Args&&... arg std::array backtrace{}; const size_t num_frames{kphp::diagnostic::backtrace(backtrace)}; const std::span backtrace_view{backtrace.data(), num_frames}; - impl::select_logger_and_log(level::warn, backtrace_view, fmt, std::forward(args)...); + impl::log(level::warn, backtrace_view, fmt, std::forward(args)...); } } @@ -76,21 +101,21 @@ void info(std::format_string...> fmt, Args&&... args) return; } if (std::to_underlying(level::info) <= k2::log_level_enabled()) { - impl::select_logger_and_log(level::info, std::nullopt, fmt, std::forward(args)...); + impl::log(level::info, std::nullopt, fmt, std::forward(args)...); } } template void debug(std::format_string...> fmt, Args&&... args) noexcept { if (std::to_underlying(level::debug) <= k2::log_level_enabled()) { - impl::select_logger_and_log(level::debug, std::nullopt, fmt, std::forward(args)...); + impl::log(level::debug, std::nullopt, fmt, std::forward(args)...); } } template void trace(std::format_string...> fmt, Args&&... args) noexcept { if (std::to_underlying(level::trace) <= k2::log_level_enabled()) { - impl::select_logger_and_log(level::trace, std::nullopt, fmt, std::forward(args)...); + impl::log(level::trace, std::nullopt, fmt, std::forward(args)...); } } diff --git a/runtime-light/stdlib/diagnostics/raw-logger.h b/runtime-light/stdlib/diagnostics/raw-logger.h deleted file mode 100644 index 959d27909b..0000000000 --- a/runtime-light/stdlib/diagnostics/raw-logger.h +++ /dev/null @@ -1,50 +0,0 @@ -// Compiler for PHP (aka KPHP) -// Copyright (c) 2025 LLC «V Kontakte» -// Distributed under the GPL v3 License, see LICENSE.notice.txt - -#pragma once - -#include -#include -#include -#include -#include -#include -#include - -#include "runtime-light/k2-platform/k2-api.h" -#include "runtime-light/stdlib/diagnostics/detail/logs.h" - -namespace kphp::log { - -struct raw_logger final { - raw_logger() noexcept = delete; - - template - static void log(kphp::log::level level, std::optional> trace, std::format_string...> fmt, - Args&&... args) noexcept { - static constexpr size_t LOG_BUFFER_SIZE = 2048UZ; - std::array log_buffer; // NOLINT - size_t message_size{impl::format_log_message(log_buffer, fmt, std::forward(args)...)}; - auto message{std::string_view{log_buffer.data(), static_cast(message_size)}}; - - if (trace.has_value()) { - std::array tagged_entries; // NOLINT - - static constexpr size_t BACKTRACE_BUFFER_SIZE = 1024UZ * 4UZ; - std::array backtrace_buffer; // NOLINT - size_t backtrace_size{impl::resolve_log_trace(backtrace_buffer, *trace)}; - - tagged_entries[0] = - k2::LogTaggedEntry{.key = BACKTRACE_KEY.data(), .value = backtrace_buffer.data(), .key_len = BACKTRACE_KEY.size(), .value_len = backtrace_size}; - k2::log(std::to_underlying(level), message, tagged_entries); - return; - } - k2::log(std::to_underlying(level), message, std::nullopt); - } - -private: - static constexpr std::string_view BACKTRACE_KEY = "trace"; -}; - -} // namespace kphp::log diff --git a/runtime-light/stdlib/system/system-functions.h b/runtime-light/stdlib/system/system-functions.h index 65927e1c15..38b5e63f7d 100644 --- a/runtime-light/stdlib/system/system-functions.h +++ b/runtime-light/stdlib/system/system-functions.h @@ -101,32 +101,32 @@ inline int64_t f$numa_get_bound_node() noexcept { } inline void f$kphp_set_context_on_error(const array& tags, const Optional>& extra_info = {}, const Optional& env = {}) noexcept { - auto logger_opt{kphp::log::contextual_logger::try_get()}; - if (!logger_opt.has_value()) [[unlikely]] { + auto tags_opt{kphp::log::contextual_tags::try_get()}; + if (!tags_opt.has_value()) [[unlikely]] { return; } - auto& logger{(*logger_opt).get()}; + auto& contextual_tags{(*tags_opt).get()}; static constexpr std::string_view EXTRA_TAGS_KEY = "tags"; static constexpr std::string_view EXTRA_INFO_KEY = "extra_info"; static constexpr std::string_view ENVIRONMENT_KEY = "env"; auto& static_SB{RuntimeContext::get().static_SB.clean()}; - logger.remove_extra_tag(EXTRA_TAGS_KEY); + contextual_tags.remove_extra_tag(EXTRA_TAGS_KEY); if (impl_::JsonEncoder(JSON_FORCE_OBJECT, false).encode(tags, static_SB)) [[likely]] { - logger.add_extra_tag(EXTRA_TAGS_KEY, {static_SB.buffer(), static_SB.size()}); + contextual_tags.add_extra_tag(EXTRA_TAGS_KEY, {static_SB.buffer(), static_SB.size()}); } static_SB.clean(); - logger.remove_extra_tag(EXTRA_INFO_KEY); + contextual_tags.remove_extra_tag(EXTRA_INFO_KEY); if (extra_info.has_value() && impl_::JsonEncoder(JSON_FORCE_OBJECT, false).encode(extra_info.val(), static_SB)) [[likely]] { - logger.add_extra_tag(EXTRA_INFO_KEY, {static_SB.buffer(), static_SB.size()}); + contextual_tags.add_extra_tag(EXTRA_INFO_KEY, {static_SB.buffer(), static_SB.size()}); } static_SB.clean(); - logger.remove_extra_tag(ENVIRONMENT_KEY); + contextual_tags.remove_extra_tag(ENVIRONMENT_KEY); if (env.has_value()) { - logger.add_extra_tag(ENVIRONMENT_KEY, {env.val().c_str(), env.val().size()}); + contextual_tags.add_extra_tag(ENVIRONMENT_KEY, {env.val().c_str(), env.val().size()}); } } From cb184d83a2cdbf1e5c99e4ec274d039bd98a2012 Mon Sep 17 00:00:00 2001 From: Karim Shamazov Date: Tue, 10 Mar 2026 13:50:24 +0300 Subject: [PATCH 2/6] rename --- .../diagnostics/{contextual-logger.cpp => contextual-tags.cpp} | 0 .../stdlib/diagnostics/{contextual-logger.h => contextual-tags.h} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename runtime-light/stdlib/diagnostics/{contextual-logger.cpp => contextual-tags.cpp} (100%) rename runtime-light/stdlib/diagnostics/{contextual-logger.h => contextual-tags.h} (100%) diff --git a/runtime-light/stdlib/diagnostics/contextual-logger.cpp b/runtime-light/stdlib/diagnostics/contextual-tags.cpp similarity index 100% rename from runtime-light/stdlib/diagnostics/contextual-logger.cpp rename to runtime-light/stdlib/diagnostics/contextual-tags.cpp diff --git a/runtime-light/stdlib/diagnostics/contextual-logger.h b/runtime-light/stdlib/diagnostics/contextual-tags.h similarity index 100% rename from runtime-light/stdlib/diagnostics/contextual-logger.h rename to runtime-light/stdlib/diagnostics/contextual-tags.h From ced63e5644099a3b02f9d6234bc0d5e7eea081a9 Mon Sep 17 00:00:00 2001 From: Karim Shamazov Date: Tue, 10 Mar 2026 13:51:49 +0300 Subject: [PATCH 3/6] fixes after rename --- runtime-light/state/instance-state.h | 2 +- runtime-light/stdlib/diagnostics/contextual-tags.cpp | 2 +- runtime-light/stdlib/diagnostics/logs.h | 2 +- runtime-light/stdlib/stdlib.cmake | 2 +- runtime-light/stdlib/system/system-functions.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/runtime-light/state/instance-state.h b/runtime-light/state/instance-state.h index f55d423e40..1c91367c30 100644 --- a/runtime-light/state/instance-state.h +++ b/runtime-light/state/instance-state.h @@ -23,7 +23,7 @@ #include "runtime-light/state/component-state.h" #include "runtime-light/stdlib/confdata/confdata-state.h" #include "runtime-light/stdlib/curl/curl-state.h" -#include "runtime-light/stdlib/diagnostics/contextual-logger.h" +#include "runtime-light/stdlib/diagnostics/contextual-tags.h" #include "runtime-light/stdlib/diagnostics/error-handling-state.h" #include "runtime-light/stdlib/fork/fork-state.h" #include "runtime-light/stdlib/fork/wait-queue-state.h" diff --git a/runtime-light/stdlib/diagnostics/contextual-tags.cpp b/runtime-light/stdlib/diagnostics/contextual-tags.cpp index 5a5786017a..a662e7b2bd 100644 --- a/runtime-light/stdlib/diagnostics/contextual-tags.cpp +++ b/runtime-light/stdlib/diagnostics/contextual-tags.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2025 LLC «V Kontakte» // Distributed under the GPL v3 License, see LICENSE.notice.txt -#include "runtime-light/stdlib/diagnostics/contextual-logger.h" +#include "runtime-light/stdlib/diagnostics/contextual-tags.h" #include #include diff --git a/runtime-light/stdlib/diagnostics/logs.h b/runtime-light/stdlib/diagnostics/logs.h index ea30551011..c8e336560d 100644 --- a/runtime-light/stdlib/diagnostics/logs.h +++ b/runtime-light/stdlib/diagnostics/logs.h @@ -13,7 +13,7 @@ #include "runtime-light/k2-platform/k2-api.h" #include "runtime-light/stdlib/diagnostics/backtrace.h" -#include "runtime-light/stdlib/diagnostics/contextual-logger.h" +#include "runtime-light/stdlib/diagnostics/contextual-tags.h" #include "runtime-light/stdlib/diagnostics/error-handling-state.h" namespace kphp::log { diff --git a/runtime-light/stdlib/stdlib.cmake b/runtime-light/stdlib/stdlib.cmake index 3831da6b07..92f67cd6b4 100644 --- a/runtime-light/stdlib/stdlib.cmake +++ b/runtime-light/stdlib/stdlib.cmake @@ -7,7 +7,7 @@ prepend( curl/curl-state.cpp web-transfer-lib/web-state.cpp diagnostics/backtrace.cpp - diagnostics/contextual-logger.cpp + diagnostics/contextual-tags.cpp diagnostics/error-handling-state.cpp diagnostics/php-assert.cpp file/file-system-state.cpp diff --git a/runtime-light/stdlib/system/system-functions.h b/runtime-light/stdlib/system/system-functions.h index 38b5e63f7d..e55d67a867 100644 --- a/runtime-light/stdlib/system/system-functions.h +++ b/runtime-light/stdlib/system/system-functions.h @@ -31,7 +31,7 @@ #include "runtime-light/coroutine/task.h" #include "runtime-light/k2-platform/k2-api.h" #include "runtime-light/state/image-state.h" -#include "runtime-light/stdlib/diagnostics/contextual-logger.h" +#include "runtime-light/stdlib/diagnostics/contextual-tags.h" #include "runtime-light/stdlib/diagnostics/logs.h" #include "runtime-light/stdlib/fork/fork-functions.h" #include "runtime-light/stdlib/system/system-state.h" From 8e9f277094941d34e63f1e2cef0c43a4d4610a2a Mon Sep 17 00:00:00 2001 From: Karim Shamazov Date: Tue, 10 Mar 2026 13:56:55 +0300 Subject: [PATCH 4/6] fixes --- runtime-light/stdlib/diagnostics/logs.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime-light/stdlib/diagnostics/logs.h b/runtime-light/stdlib/diagnostics/logs.h index c8e336560d..170288f839 100644 --- a/runtime-light/stdlib/diagnostics/logs.h +++ b/runtime-light/stdlib/diagnostics/logs.h @@ -14,6 +14,7 @@ #include "runtime-light/k2-platform/k2-api.h" #include "runtime-light/stdlib/diagnostics/backtrace.h" #include "runtime-light/stdlib/diagnostics/contextual-tags.h" +#include "runtime-light/stdlib/diagnostics/detail/logs.h" #include "runtime-light/stdlib/diagnostics/error-handling-state.h" namespace kphp::log { @@ -27,7 +28,7 @@ void log(level level, std::optional> trace, std::format_s size_t message_size{impl::format_log_message(log_buffer, fmt, std::forward(args)...)}; auto message{std::string_view{log_buffer.data(), static_cast(message_size)}}; - auto opt_tags{contextual_tags::try_get().and_then([level](contextual_tags& tags) noexcept { + auto opt_tags{contextual_tags::try_get().and_then([level](contextual_tags& tags) noexcept -> std::optional> { if (level == level::warn || level == level::error) { return std::make_optional(std::ref(tags)); } @@ -43,6 +44,7 @@ void log(level level, std::optional> trace, std::format_s for (const auto& [key, value] : tags) { tagged_entries.push_back(k2::LogTaggedEntry{.key = key.data(), .value = value.data(), .key_len = key.size(), .value_len = value.size()}); } + return 0; }); if (trace.has_value()) { static constexpr size_t BACKTRACE_BUFFER_SIZE = 1024UZ * 4UZ; From 87538aeef0bd9af85e9d21ba097889e42a3d8184 Mon Sep 17 00:00:00 2001 From: Karim Shamazov Date: Tue, 10 Mar 2026 14:26:59 +0300 Subject: [PATCH 5/6] refactor k2::log --- runtime-light/k2-platform/k2-api.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime-light/k2-platform/k2-api.h b/runtime-light/k2-platform/k2-api.h index c519e32a0b..9b0c5f4874 100644 --- a/runtime-light/k2-platform/k2-api.h +++ b/runtime-light/k2-platform/k2-api.h @@ -261,9 +261,9 @@ inline k2::UpdateStatus take_update(k2::descriptor* descriptor) noexcept { using LogTaggedEntry = ::LogKeyValuePair; -inline void log(size_t level, std::string_view msg, std::optional> tags) noexcept { - const auto tags_count{tags.value_or(std::span{}).size()}; - const auto* tags_data{tags.value_or(std::span{}).data()}; +inline void log(size_t level, std::string_view msg, std::span tags) noexcept { + const auto tags_count{tags.size()}; + const auto* tags_data{tags.data()}; k2_log(level, msg.size(), msg.data(), tags_count, tags_data); } From d398774f96b36aa7a2031f3f51772812b17846f5 Mon Sep 17 00:00:00 2001 From: Karim Shamazov Date: Tue, 10 Mar 2026 14:39:40 +0300 Subject: [PATCH 6/6] format --- runtime-light/stdlib/diagnostics/logs.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/runtime-light/stdlib/diagnostics/logs.h b/runtime-light/stdlib/diagnostics/logs.h index 170288f839..3f7843ed20 100644 --- a/runtime-light/stdlib/diagnostics/logs.h +++ b/runtime-light/stdlib/diagnostics/logs.h @@ -28,12 +28,13 @@ void log(level level, std::optional> trace, std::format_s size_t message_size{impl::format_log_message(log_buffer, fmt, std::forward(args)...)}; auto message{std::string_view{log_buffer.data(), static_cast(message_size)}}; - auto opt_tags{contextual_tags::try_get().and_then([level](contextual_tags& tags) noexcept -> std::optional> { - if (level == level::warn || level == level::error) { - return std::make_optional(std::ref(tags)); - } - return std::nullopt; - })}; + auto opt_tags{ + contextual_tags::try_get().and_then([level](contextual_tags& tags) noexcept -> std::optional> { + if (level == level::warn || level == level::error) { + return std::make_optional(std::ref(tags)); + } + return std::nullopt; + })}; const size_t tagged_entries_size{ static_cast((trace.has_value() ? 1 : 0) + opt_tags.transform([](contextual_tags& tags) noexcept { return tags.size(); }).value_or(0))};