From f0cccbe3285c039553e1fd8b5a5c7830d6087974 Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Thu, 6 Mar 2025 22:56:56 +0100 Subject: Replace ASL_MOVE, ASL_FWD, and ASL_FWD_LIKE by their std:: equivalent This is because some compiler stuff and diagnostics tools rely on those symboles being what they are. --- asl/logging/logging.cpp | 10 +++++++++- asl/logging/logging.hpp | 6 +++++- asl/logging/logging_tests.cpp | 7 ++++--- 3 files changed, 18 insertions(+), 5 deletions(-) (limited to 'asl/logging') diff --git a/asl/logging/logging.cpp b/asl/logging/logging.cpp index edf065d..2cb9a3f 100644 --- a/asl/logging/logging.cpp +++ b/asl/logging/logging.cpp @@ -3,14 +3,22 @@ // SPDX-License-Identifier: BSD-3-Clause #include "asl/logging/logging.hpp" + +#include "asl/containers/intrusive_list.hpp" +#include "asl/formatting/format.hpp" #include "asl/io/print.hpp" +#include "asl/io/writer.hpp" #include "asl/strings/string_builder.hpp" +#include "asl/strings/string_view.hpp" +#include "asl/types/span.hpp" // @Todo Don't use internal get_stdout_writer, make console module +// NOLINTNEXTLINE(*-avoid-non-const-global-variables) static asl::log::DefaultLogger g_default_logger{asl::print_internals::get_stdout_writer()}; // @Todo Protect the loggers list being a mutex +// NOLINTNEXTLINE(*-avoid-non-const-global-variables) static asl::IntrusiveList g_loggers(&g_default_logger); void asl::log::register_logger(Logger* logger) @@ -56,7 +64,7 @@ void asl::log::log_inner( StringWriter msg_writer{}; asl::format_internals::format(&msg_writer, fmt, args); - message m{ + const message m{ .level = l, .message = msg_writer.as_string_view(), .location = sl, diff --git a/asl/logging/logging.hpp b/asl/logging/logging.hpp index 9ff0d08..9c74b31 100644 --- a/asl/logging/logging.hpp +++ b/asl/logging/logging.hpp @@ -48,7 +48,11 @@ class DefaultLogger : public DefaultLoggerBase W m_writer; public: - explicit constexpr DefaultLogger(W&& writer) : m_writer{ASL_FWD(writer)} {} + template + explicit constexpr DefaultLogger(U&& writer) + requires constructible_from + : m_writer{std::forward(writer)} + {} constexpr void log(const message& m) override { diff --git a/asl/logging/logging_tests.cpp b/asl/logging/logging_tests.cpp index ec47a8a..ea5bd2a 100644 --- a/asl/logging/logging_tests.cpp +++ b/asl/logging/logging_tests.cpp @@ -2,10 +2,11 @@ // // SPDX-License-Identifier: BSD-3-Clause +#include "asl/base/defer.hpp" #include "asl/logging/logging.hpp" -#include "asl/testing/testing.hpp" #include "asl/strings/string_builder.hpp" -#include "asl/base/defer.hpp" +#include "asl/strings/string_view.hpp" +#include "asl/testing/testing.hpp" ASL_TEST(log) { @@ -27,6 +28,6 @@ ASL_TEST(custom_writer) ASL_LOG_INFO("Hello"); auto sv = string_writer.as_string_view(); - ASL_TEST_EXPECT(sv == "[ INFO ] asl/logging/logging_tests.cpp:27: Hello\n"); + ASL_TEST_EXPECT(sv == "[ INFO ] asl/logging/logging_tests.cpp:28: Hello\n"); } -- cgit