diff options
author | gabime <gmelman1@gmail.com> | 2021-12-04 15:53:16 +0300 |
---|---|---|
committer | gabime <gmelman1@gmail.com> | 2021-12-04 15:53:16 +0300 |
commit | 2b5e628c8d8c0fda912a62d4b059b65a88351fa7 (patch) | |
tree | 29e383ceeff99bc71f7081caab5b2d9952dd9d91 | |
parent | bd511c5c9913d739b3ca1c605c8b5fc7c52cb85d (diff) |
Fixed example for custom_type
-rw-r--r-- | example/example.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/example/example.cpp b/example/example.cpp index 6711f566..5d269f82 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -244,7 +244,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; @@ -252,11 +252,12 @@ struct my_type namespace fmt_lib = spdlog::fmt_lib; template<> -struct fmt_lib::formatter<my_type> : fmt_lib::formatter<std::string> +struct fmt_lib::formatter<my_type> : fmt_lib::formatter<char> { auto format(my_type my, format_context &ctx) - { - return formatter<std::string>::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); } }; |