Skip to content

Conversation

SpriteOvO
Copy link
Contributor

@SpriteOvO SpriteOvO commented May 14, 2025

Implementation of #3384.

The PR is currently in a very early stage, so it is incomplete and will continue to be changed. Opening it as a draft to take notes, track progress, and early review.

API

For users, I currently expect the API to be

using namespace spdlog_literals;

// The type of the argument is `spdlog::static_pattern_formatter`.
spdlog::set_formatter("[%n] [%^%l%$] %v"_pat);

Internal

Maintainability

The code for the flag formatters remains almost unchanged. If a new flag needs to be added in the future, perhaps just add an if constexpr.

Notable Changes

  • All flag formatters are moved from file pattern_formatter-inl.h to pattern_formatter.h.

    • Reason: consteval implies inline, a consteval function can't be split into a definition and a declaration, therefore all flag formatters must be visible to these consteval functions. However, they are still inside details namespace.
    • It has been done in a separate commit ea81283 to avoid diff messes.
  • SPDLOG_CONSTEXPR_FUNC has been added to the explicit constructors of all flag formatters.

  • For some unsure concerns, TODO comments were left.

  • ... TBD

Steps

  • Parse and compile flags at compile-time.
  • Wrap flags tuple into static_pattern_formatter.
  • Test the output. Make sure that {,static_}pattern_formatter outputs are consistent.
  • Padding support.
  • Name decisions. Is the current names acceptable or are there better options?
  • ... TBD

@SpriteOvO SpriteOvO force-pushed the compile-time-pattern branch from 3936f33 to 7cab222 Compare May 14, 2025 17:27
@SpriteOvO SpriteOvO marked this pull request as draft May 14, 2025 17:39
@SpriteOvO SpriteOvO force-pushed the compile-time-pattern branch from 7cab222 to b5d38b4 Compare May 15, 2025 04:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant