Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/deeplog/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ dplx_target_sources(deeplog

dlog/detail/any_loggable_ref
dlog/detail/any_reified
dlog/detail/system_error2_fmt
dlog/detail/workaround
)

Expand All @@ -126,7 +127,6 @@ dplx_target_sources(deeplog
dlog/macros.hpp

dlog/detail/hex.hpp
dlog/detail/system_error2_fmt.hpp
dlog/detail/utils.hpp
dlog/detail/x_poly_types.inl

Expand Down
1 change: 0 additions & 1 deletion libs/deeplog/src/dlog_tests/test_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <string>

#include <catch2/catch_tostring.hpp>
#include <fmt/core.h>
#include <fmt/format.h>

#include <dplx/predef/compiler.h>
Expand Down
1 change: 0 additions & 1 deletion libs/deeplog/src/dplx/dlog/argument_transmorpher_fmt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <boost/unordered/unordered_flat_map.hpp>

#include <fmt/args.h>
#include <fmt/core.h>
#include <fmt/format.h>

#include <dplx/dp.hpp>
Expand Down
2 changes: 1 addition & 1 deletion libs/deeplog/src/dplx/dlog/core/strong_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <span>
#include <type_traits>

#include <fmt/core.h>
#include <fmt/base.h>

#include <dplx/cncr/utils.hpp>
#include <dplx/dp/fwd.hpp>
Expand Down
2 changes: 1 addition & 1 deletion libs/deeplog/src/dplx/dlog/detail/any_loggable_ref.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <string_view>

#include <fmt/core.h>
#include <fmt/base.h>

#include <dplx/cncr/utils.hpp>
#include <dplx/dp/api.hpp>
Expand Down
16 changes: 6 additions & 10 deletions libs/deeplog/src/dplx/dlog/detail/system_error2_fmt.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// Copyright Henrik Steffen Gaßmann 2023
// Copyright Henrik Steffen Gaßmann 2023, 2025.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE or copy at
Expand Down Expand Up @@ -28,8 +28,8 @@ struct string_ref_formatter : private Formatter<StringView>
}

template <typename FormatContext>
auto format(status_code_domain::string_ref const &str, FormatContext &ctx)
-> typename FormatContext::iterator
auto format(status_code_domain::string_ref const &str,
FormatContext &ctx) const -> typename FormatContext::iterator
{
return base::format(StringView(str.data(), str.size()), ctx);
}
Expand Down Expand Up @@ -59,7 +59,7 @@ struct std::formatter<SYSTEM_ERROR2_NAMESPACE::status_code_domain::string_ref,
};
#endif

#include <fmt/core.h>
#include <fmt/format.h>

SYSTEM_ERROR2_NAMESPACE_BEGIN
namespace detail
Expand Down Expand Up @@ -92,7 +92,7 @@ struct trivial_status_code_view
{
system_error2::status_code<void> const *code;

trivial_status_code_view() noexcept = default;
constexpr trivial_status_code_view() noexcept = default;

DPLX_ATTR_FORCE_INLINE
trivial_status_code_view(system_error2::status_code<void> const &sc)
Expand All @@ -105,15 +105,13 @@ struct reified_status_code
std::uint64_t mDomainId{};
std::pmr::string mDomainName;
std::pmr::string mMessage;

reified_status_code() noexcept = default;
};

struct trivial_system_code_view
{
system_error2::system_code const *code;

trivial_system_code_view() noexcept = default;
constexpr trivial_system_code_view() noexcept = default;

DPLX_ATTR_FORCE_INLINE
trivial_system_code_view(system_error2::system_code const &sc)
Expand All @@ -127,8 +125,6 @@ struct reified_system_code
std::uint64_t mRawValue{};
std::pmr::string mDomainName;
std::pmr::string mMessage;

reified_system_code() noexcept = default;
};

} // namespace dplx::dlog::detail
Expand Down
61 changes: 61 additions & 0 deletions libs/deeplog/src/dplx/dlog/detail/system_error2_fmt.test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

// Copyright Henrik S. Gaßmann 2025.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE or copy at
// https://www.boost.org/LICENSE_1_0.txt)

#include "dplx/dlog/detail/system_error2_fmt.hpp"

#include <catch2/catch_test_macros.hpp>

#include "test_dir.hpp"
#include "test_utils.hpp"

namespace dlog_tests
{

TEST_CASE("formats a static_code_domain::string_ref using fmt")
{
using namespace dplx::dlog::detail;
constexpr char const helloWorld[] = "Hello, World!";

SYSTEM_ERROR2_NAMESPACE::status_code_domain::string_ref strRef{
static_cast<char const *>(helloWorld), sizeof(helloWorld) - 1};

auto const formatted = fmt::format("{}", strRef);
REQUIRE(formatted
== std::string_view{static_cast<char const *>(helloWorld),
sizeof(helloWorld) - 1});
}

TEST_CASE("formats a reified_status_code using fmt")
{
using namespace dplx::dlog::detail;

reified_status_code code{
.mDomainId = system_error2::generic_code::domain_type::get().id(),
.mDomainName = "example_domain",
.mMessage = "an example message",
};

auto const formatted = fmt::format("{}", code);
REQUIRE(formatted == "{example_domain: an example message}");
}

TEST_CASE("formats a reified_system_code using fmt")
{
using namespace dplx::dlog::detail;

reified_system_code code{
.mDomainId = system_error2::generic_code::domain_type::get().id(),
.mRawValue = 0,
.mDomainName = "example_system_domain",
.mMessage = "a system error message",
};

auto const formatted = fmt::format("{}", code);
REQUIRE(formatted == "{example_system_domain: a system error message}");
}

} // namespace dlog_tests
1 change: 0 additions & 1 deletion libs/deeplog/src/dplx/dlog/record_container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <memory_resource>
#include <string_view>

#include <fmt/core.h>
#include <fmt/format.h>

#include <dplx/dp.hpp>
Expand Down
2 changes: 1 addition & 1 deletion libs/deeplog/src/dplx/dlog/source/log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <source_location>
#endif

#include <fmt/core.h>
#include <fmt/base.h>

#include <dplx/dlog/config.hpp>
#include <dplx/dlog/core/strong_types.hpp>
Expand Down
1 change: 0 additions & 1 deletion libs/deeplog_tui/src/dlog_tui_tests/test_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <string>

#include <catch2/catch_tostring.hpp>
#include <fmt/core.h>
#include <fmt/format.h>

#include <dplx/predef/compiler.h>
Expand Down