我正在尝试使用spdlog创建具有多个接收器的记录器。
我确实使用显式std::initializer_list
成功创建了一个:
spdlog::sink_ptr consoleSink = make_shared<spdlog::sinks::stdout_color_sink_mt>();
spdlog::sink_ptr fileSink
= make_shared<spdlog::sinks::rotating_file_sink_mt>("logs/email.txt", 4_M, 3);
std::initializer_list<spdlog::sink_ptr> sinks = {consoleSink, fileSink};
auto slog = make_shared<spdlog::logger>("email", sinks);
但是由于某种原因,它不能隐式工作:
spdlog::sink_ptr consoleSink = make_shared<spdlog::sinks::stdout_color_sink_mt>();
spdlog::sink_ptr fileSink
= make_shared<spdlog::sinks::rotating_file_sink_mt>("logs/email.txt", 4_M, 3);
auto slog = make_shared<spdlog::logger>("email", {consoleSink, fileSink});
编译说:
error: no matching function for call to 'make_shared'
candidate template ignored: substitution failure [with _Tp = spdlog::logger]:
deduced incomplete pack <char const (&)[6], (no value)> for template parameter '_Args'
make_shared(_Args&&... __args)