From f81970191aad8f7dc9c810ce544a92301a612a88 Mon Sep 17 00:00:00 2001 From: gabime Date: Sat, 4 Dec 2021 14:53:16 +0200 Subject: [PATCH] Fixed example for custom_type --- example/example.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/example/example.cpp b/example/example.cpp index 5e5f85d3..0d0db6b8 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -254,7 +254,7 @@ void multi_sink_example() logger.info("this message should not appear in the console, only in the file"); } -// User defined types logging by implementing operator<< +// User defined types logging struct my_type { int i = 0; @@ -262,11 +262,12 @@ struct my_type namespace fmt_lib = spdlog::fmt_lib; template<> -struct fmt_lib::formatter : fmt_lib::formatter +struct fmt_lib::formatter : fmt_lib::formatter { auto format(my_type my, format_context &ctx) - { - return formatter::format(fmt_lib::format("[my_type i={}]", my.i), ctx); + { + auto &&out = ctx.out(); + return fmt_lib::format_to(out, "[my_type i={}]", my.i); } };