spdlog error: “don't know how to format the type, include fmt/ostream.h if it provides an operator<<...












0















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]










share|improve this question




















  • 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
















0















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]










share|improve this question




















  • 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














0












0








0


0






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]










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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














  • 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








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












1 Answer
1






active

oldest

votes


















2














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.






share|improve this answer



















  • 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











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
});


}
});














draft saved

draft discarded


















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









2














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.






share|improve this answer



















  • 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
















2














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.






share|improve this answer



















  • 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














2












2








2







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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










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














  • 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


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

TypeError: fit_transform() missing 1 required positional argument: 'X'