Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove fmt in favor of std::format, upgrade spdlog to current version #67

Merged
merged 14 commits into from
Jun 22, 2024

Conversation

Holt59
Copy link
Member

@Holt59 Holt59 commented Jun 15, 2024

Some details:

  • The include path from spdlog does NOT include spdlog anymore which is why #include are now spdlog/spdlog.h rather than simply spdlog.h.
  • std::ostream& operator<< operators have been converted specializations of std::formatter - almost everything can be found in the formatters.h header:
    • Specializations for wide chars on non-wide char format (same as before).
    • Specialization for PCUNICODE_STRING.
    • Specialization for pointers - This was need as std::format does not natively support pointers other than void* and const void*.
    • Specialization for Wrap<NTSTATUS> and Wrap<DWORD>.
    • Removed every notion of Wrap<STR> (STR being any kind of string) as this was not doing anything different than the standard formatters. The only use cases for Wrap are now NTSTATUS and DWORD.
    • Specialization for usvfs::UnicodeString.
  • Some refactoring for fmt::MemoryWriter using std::format_to.
  • toHex and SeverityShort functions were simply removed since these are not used anywhere and annoying to convert.
  • Update for spdlog sinks:
    • Extra headers are included when needed.
    • Switch from the custom null sink to the spdlog one.
    • Updated the shmsink.
  • Change many usage of path::u8string() to simply path::string() because in C++20 both are different, and it is very complicated to mix both (and support for u8string is very poor).

@Holt59 Holt59 changed the title WIP: Remove fmt in favor of std::format, upgrade spdlog to current version Remove fmt in favor of std::format, upgrade spdlog to current version Jun 15, 2024
Copy link
Member

@Al12rs Al12rs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the work here. Good to be on c++20. A lot of nice cleanup here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file contains most formatters for std::format - These are basically the ones from loghelpers before. I tried to reduce the amount of copy/paste so most formatters forward to other formatters for the sake of readibility.

There is not formatters for wrapped strings because those were not doing anything more than the standard formatters.

The formatter for USVFS own UnicodeString is in a separate file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most stuff in this file has moved to the formatters.h file above. The new functions are to avoid bringing ush into formatters.h - There are only two overloads because most string-based converters forward to the LPCWSTR overload.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes here are mostly to change the message formatting when logging parameters.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pure formatting and replacing typedef with using.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This updates the shm_sink for spdlog - I moved the sink to the usvfs namespace because it took me some times to see that it was not a spdlog built-in sink.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unused function. Use spdlog built-in null sink. Updates for new spdlog.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u8string -> string
test namespace

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u8string -> string
test namespace

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NtWriteFile takes a char*, not a const char*, so C++20 is not happy here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u8string -> string

@Holt59 Holt59 merged commit 9f7fd96 into master Jun 22, 2024
11 checks passed
@Holt59 Holt59 deleted the dev/fmt-spdlog-upgrade branch June 22, 2024 06:34
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.

2 participants