spdlog error: “don't know how to format the type, include fmt/ostream.h if it provides an operator<<...
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
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 '18 at 14:17
Also, you might want to specify your environment, like the version of your compiler, OS, etc.
– anatolyg
Nov 22 '18 at 14:21
Did you tryinclude fmt/ostream.h
like the error suggests?
– xtofl
Nov 22 '18 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 '18 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 '18 at 14:49
|
show 9 more comments
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 '18 at 14:27
Mike Sadler
asked Nov 22 '18 at 14:15
Mike SadlerMike Sadler
61611024
61611024
1
You might want to add a Minimal, Complete, and Verifiable example
– anatolyg
Nov 22 '18 at 14:17
Also, you might want to specify your environment, like the version of your compiler, OS, etc.
– anatolyg
Nov 22 '18 at 14:21
Did you tryinclude fmt/ostream.h
like the error suggests?
– xtofl
Nov 22 '18 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 '18 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 '18 at 14:49
|
show 9 more comments
1
You might want to add a Minimal, Complete, and Verifiable example
– anatolyg
Nov 22 '18 at 14:17
Also, you might want to specify your environment, like the version of your compiler, OS, etc.
– anatolyg
Nov 22 '18 at 14:21
Did you tryinclude fmt/ostream.h
like the error suggests?
– xtofl
Nov 22 '18 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 '18 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 '18 at 14:49
1
1
You might want to add a Minimal, Complete, and Verifiable example
– anatolyg
Nov 22 '18 at 14:17
You might want to add a Minimal, Complete, and Verifiable example
– anatolyg
Nov 22 '18 at 14:17
Also, you might want to specify your environment, like the version of your compiler, OS, etc.
– anatolyg
Nov 22 '18 at 14:21
Also, you might want to specify your environment, like the version of your compiler, OS, etc.
– anatolyg
Nov 22 '18 at 14:21
Did you try
include fmt/ostream.h
like the error suggests?– xtofl
Nov 22 '18 at 14:21
Did you try
include fmt/ostream.h
like the error suggests?– xtofl
Nov 22 '18 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 '18 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 '18 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 '18 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 '18 at 14:49
|
show 9 more comments
1 Answer
1
active
oldest
votes
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 '18 at 11:05
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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 '18 at 11:05
add a comment |
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 '18 at 11:05
add a comment |
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 '18 at 14:54
Mike SadlerMike Sadler
61611024
61611024
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 '18 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 '18 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 '18 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 '18 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.
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 '18 at 14:17
Also, you might want to specify your environment, like the version of your compiler, OS, etc.
– anatolyg
Nov 22 '18 at 14:21
Did you try
include fmt/ostream.h
like the error suggests?– xtofl
Nov 22 '18 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 '18 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 '18 at 14:49