spdlog error: “don't know how to format the type, include fmt/ostream.h if it provides an operator<<...
up vote
0
down vote
favorite
I've just picked up spdlog in an effort to improve our logging. Our logging is very basic, so I'm just copying the "multi sink" example almost verbatim to log to file and console.
However, even when following the example exactly, I get:
Error C2338 don't know how to format the type, include fmt/ostream.h if it provides an operator<< that should be used Logger d:tfsdevelopmentbladedmainexternalspdlogspdlog-1.xincludespdlogfmtbundledcore.h 351
Coming from core.h:
// A formatter for objects of type T.
template <typename T, typename Char = char, typename Enable = void>
struct formatter {
static_assert(no_formatter_error<T>::value,
"don't know how to format the type, include fmt/ostream.h if it provides "
"an operator<< that should be used");
I'm presuming this is really easy to fix, but I can't see it...
[basic Win32 usage]
c++ spdlog
|
show 9 more comments
up vote
0
down vote
favorite
I've just picked up spdlog in an effort to improve our logging. Our logging is very basic, so I'm just copying the "multi sink" example almost verbatim to log to file and console.
However, even when following the example exactly, I get:
Error C2338 don't know how to format the type, include fmt/ostream.h if it provides an operator<< that should be used Logger d:tfsdevelopmentbladedmainexternalspdlogspdlog-1.xincludespdlogfmtbundledcore.h 351
Coming from core.h:
// A formatter for objects of type T.
template <typename T, typename Char = char, typename Enable = void>
struct formatter {
static_assert(no_formatter_error<T>::value,
"don't know how to format the type, include fmt/ostream.h if it provides "
"an operator<< that should be used");
I'm presuming this is really easy to fix, but I can't see it...
[basic Win32 usage]
c++ spdlog
1
You might want to add a Minimal, Complete, and Verifiable example
– anatolyg
Nov 22 at 14:17
Also, you might want to specify your environment, like the version of your compiler, OS, etc.
– anatolyg
Nov 22 at 14:21
Did you tryinclude fmt/ostream.h
like the error suggests?
– xtofl
Nov 22 at 14:21
1
@MikeSadler What type are you trying to format? Wild guess -- are you usingstd::string
or similar, and forgot to#include <string>
in your source?
– PaulMcKenzie
Nov 22 at 14:32
1
ok. I think you should write up the solution, since I only gave hints and you know the library better than I do.
– PaulMcKenzie
Nov 22 at 14:49
|
show 9 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I've just picked up spdlog in an effort to improve our logging. Our logging is very basic, so I'm just copying the "multi sink" example almost verbatim to log to file and console.
However, even when following the example exactly, I get:
Error C2338 don't know how to format the type, include fmt/ostream.h if it provides an operator<< that should be used Logger d:tfsdevelopmentbladedmainexternalspdlogspdlog-1.xincludespdlogfmtbundledcore.h 351
Coming from core.h:
// A formatter for objects of type T.
template <typename T, typename Char = char, typename Enable = void>
struct formatter {
static_assert(no_formatter_error<T>::value,
"don't know how to format the type, include fmt/ostream.h if it provides "
"an operator<< that should be used");
I'm presuming this is really easy to fix, but I can't see it...
[basic Win32 usage]
c++ spdlog
I've just picked up spdlog in an effort to improve our logging. Our logging is very basic, so I'm just copying the "multi sink" example almost verbatim to log to file and console.
However, even when following the example exactly, I get:
Error C2338 don't know how to format the type, include fmt/ostream.h if it provides an operator<< that should be used Logger d:tfsdevelopmentbladedmainexternalspdlogspdlog-1.xincludespdlogfmtbundledcore.h 351
Coming from core.h:
// A formatter for objects of type T.
template <typename T, typename Char = char, typename Enable = void>
struct formatter {
static_assert(no_formatter_error<T>::value,
"don't know how to format the type, include fmt/ostream.h if it provides "
"an operator<< that should be used");
I'm presuming this is really easy to fix, but I can't see it...
[basic Win32 usage]
c++ spdlog
c++ spdlog
edited Nov 22 at 14:27
asked Nov 22 at 14:15
Mike Sadler
61111024
61111024
1
You might want to add a Minimal, Complete, and Verifiable example
– anatolyg
Nov 22 at 14:17
Also, you might want to specify your environment, like the version of your compiler, OS, etc.
– anatolyg
Nov 22 at 14:21
Did you tryinclude fmt/ostream.h
like the error suggests?
– xtofl
Nov 22 at 14:21
1
@MikeSadler What type are you trying to format? Wild guess -- are you usingstd::string
or similar, and forgot to#include <string>
in your source?
– PaulMcKenzie
Nov 22 at 14:32
1
ok. I think you should write up the solution, since I only gave hints and you know the library better than I do.
– PaulMcKenzie
Nov 22 at 14:49
|
show 9 more comments
1
You might want to add a Minimal, Complete, and Verifiable example
– anatolyg
Nov 22 at 14:17
Also, you might want to specify your environment, like the version of your compiler, OS, etc.
– anatolyg
Nov 22 at 14:21
Did you tryinclude fmt/ostream.h
like the error suggests?
– xtofl
Nov 22 at 14:21
1
@MikeSadler What type are you trying to format? Wild guess -- are you usingstd::string
or similar, and forgot to#include <string>
in your source?
– PaulMcKenzie
Nov 22 at 14:32
1
ok. I think you should write up the solution, since I only gave hints and you know the library better than I do.
– PaulMcKenzie
Nov 22 at 14:49
1
1
You might want to add a Minimal, Complete, and Verifiable example
– anatolyg
Nov 22 at 14:17
You might want to add a Minimal, Complete, and Verifiable example
– anatolyg
Nov 22 at 14:17
Also, you might want to specify your environment, like the version of your compiler, OS, etc.
– anatolyg
Nov 22 at 14:21
Also, you might want to specify your environment, like the version of your compiler, OS, etc.
– anatolyg
Nov 22 at 14:21
Did you try
include fmt/ostream.h
like the error suggests?– xtofl
Nov 22 at 14:21
Did you try
include fmt/ostream.h
like the error suggests?– xtofl
Nov 22 at 14:21
1
1
@MikeSadler What type are you trying to format? Wild guess -- are you using
std::string
or similar, and forgot to #include <string>
in your source?– PaulMcKenzie
Nov 22 at 14:32
@MikeSadler What type are you trying to format? Wild guess -- are you using
std::string
or similar, and forgot to #include <string>
in your source?– PaulMcKenzie
Nov 22 at 14:32
1
1
ok. I think you should write up the solution, since I only gave hints and you know the library better than I do.
– PaulMcKenzie
Nov 22 at 14:49
ok. I think you should write up the solution, since I only gave hints and you know the library better than I do.
– PaulMcKenzie
Nov 22 at 14:49
|
show 9 more comments
1 Answer
1
active
oldest
votes
up vote
2
down vote
With @PaulMcKenzie pointing me in the right direction, it seems that I was trying to log a type of string that spdlog cannot handle by default (std::wstrings).
Visual Studio's Intellisense seemed to be confused by the templating, making it appear to be happy with my sending spdlog::warn a std::wstring.
Solution: either just use std::string, or if you want to use wstrings you (probably) need to define a custome formatter for them.
1
You can define SPDLOG_WCHAR_TO_UTF8_SUPPORT before including spdlog.h to format wstrings like this: logger->info(L”some wstring param: {}”, wstr);
– GabiMe
Nov 24 at 11:05
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
With @PaulMcKenzie pointing me in the right direction, it seems that I was trying to log a type of string that spdlog cannot handle by default (std::wstrings).
Visual Studio's Intellisense seemed to be confused by the templating, making it appear to be happy with my sending spdlog::warn a std::wstring.
Solution: either just use std::string, or if you want to use wstrings you (probably) need to define a custome formatter for them.
1
You can define SPDLOG_WCHAR_TO_UTF8_SUPPORT before including spdlog.h to format wstrings like this: logger->info(L”some wstring param: {}”, wstr);
– GabiMe
Nov 24 at 11:05
add a comment |
up vote
2
down vote
With @PaulMcKenzie pointing me in the right direction, it seems that I was trying to log a type of string that spdlog cannot handle by default (std::wstrings).
Visual Studio's Intellisense seemed to be confused by the templating, making it appear to be happy with my sending spdlog::warn a std::wstring.
Solution: either just use std::string, or if you want to use wstrings you (probably) need to define a custome formatter for them.
1
You can define SPDLOG_WCHAR_TO_UTF8_SUPPORT before including spdlog.h to format wstrings like this: logger->info(L”some wstring param: {}”, wstr);
– GabiMe
Nov 24 at 11:05
add a comment |
up vote
2
down vote
up vote
2
down vote
With @PaulMcKenzie pointing me in the right direction, it seems that I was trying to log a type of string that spdlog cannot handle by default (std::wstrings).
Visual Studio's Intellisense seemed to be confused by the templating, making it appear to be happy with my sending spdlog::warn a std::wstring.
Solution: either just use std::string, or if you want to use wstrings you (probably) need to define a custome formatter for them.
With @PaulMcKenzie pointing me in the right direction, it seems that I was trying to log a type of string that spdlog cannot handle by default (std::wstrings).
Visual Studio's Intellisense seemed to be confused by the templating, making it appear to be happy with my sending spdlog::warn a std::wstring.
Solution: either just use std::string, or if you want to use wstrings you (probably) need to define a custome formatter for them.
answered Nov 22 at 14:54
Mike Sadler
61111024
61111024
1
You can define SPDLOG_WCHAR_TO_UTF8_SUPPORT before including spdlog.h to format wstrings like this: logger->info(L”some wstring param: {}”, wstr);
– GabiMe
Nov 24 at 11:05
add a comment |
1
You can define SPDLOG_WCHAR_TO_UTF8_SUPPORT before including spdlog.h to format wstrings like this: logger->info(L”some wstring param: {}”, wstr);
– GabiMe
Nov 24 at 11:05
1
1
You can define SPDLOG_WCHAR_TO_UTF8_SUPPORT before including spdlog.h to format wstrings like this: logger->info(L”some wstring param: {}”, wstr);
– GabiMe
Nov 24 at 11:05
You can define SPDLOG_WCHAR_TO_UTF8_SUPPORT before including spdlog.h to format wstrings like this: logger->info(L”some wstring param: {}”, wstr);
– GabiMe
Nov 24 at 11:05
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53432887%2fspdlog-error-dont-know-how-to-format-the-type-include-fmt-ostream-h-if-it-pr%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You might want to add a Minimal, Complete, and Verifiable example
– anatolyg
Nov 22 at 14:17
Also, you might want to specify your environment, like the version of your compiler, OS, etc.
– anatolyg
Nov 22 at 14:21
Did you try
include fmt/ostream.h
like the error suggests?– xtofl
Nov 22 at 14:21
1
@MikeSadler What type are you trying to format? Wild guess -- are you using
std::string
or similar, and forgot to#include <string>
in your source?– PaulMcKenzie
Nov 22 at 14:32
1
ok. I think you should write up the solution, since I only gave hints and you know the library better than I do.
– PaulMcKenzie
Nov 22 at 14:49