0
int main()
{
    std::map<std::string, std::string> o;
    o["foo"] = "foo value";
    spdlog::info(o);
    return 0;
}

Got error: static_assert failed due to requirement 'formattable' "Cannot format argument. To make type T formattable provide a formatter specialization: https://fmt.dev/latest/api.html#formatting-user-defined-types"

langyu
  • 68
  • 1
  • 7

1 Answers1

0

spdlog only support types that have operator << (with #include <fmt/ostream.h>)

You have 2 options:

  • Implement function: std::ostream& operator <<(std::ostream&, const std::map<std::string, std::string>&)
  • Log key and value in the loop:
for (const auto&[k, v] : o)
{
    spdlog::info("key is {}, value is {}", k, v);
}
Tihran
  • 106
  • 4