diff --git a/example/example.cpp b/example/example.cpp index 87b00518..71119758 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -191,14 +191,20 @@ void binary_example() } // Log a vector of numbers - -#include "spdlog/fmt/bundled/ranges.h" +#ifndef SPDLOG_USE_STD_FORMAT +# include "spdlog/fmt/bundled/ranges.h" void vector_example() { std::vector vec = {1, 2, 3}; spdlog::info("Vector example: {}", vec); } +#else +void vector_example() {} +#endif + +// ! DSPDLOG_USE_STD_FORMAT + // Compile time log levels. // define SPDLOG_ACTIVE_LEVEL to required level (e.g. SPDLOG_LEVEL_TRACE) void trace_example() @@ -252,10 +258,14 @@ void multi_sink_example() struct my_type { int i; - template - friend OStream &operator<<(OStream &os, const my_type &c) +}; + +template<> +struct std::formatter : std::formatter +{ + auto format(my_type my, format_context &ctx) { - return os << "[my_type i=" << c.i << "]"; + return formatter::format(std::format("[my_type i={}]", my.i), ctx); } }; @@ -354,4 +364,3 @@ void replace_default_logger_example() spdlog::set_default_logger(old_logger); } -