【发布时间】:2021-08-18 14:05:35
【问题描述】:
按照此处Boost.Log, using custom attributes in filename or target value of configuration file 提出的问题,我尝试开发建议的解决方案,但由于wchar_t 与char 在尝试设置文件名称时遇到了Windows 上的构建问题。
Error C2664 'boost::log::v2s_mt_nt6::basic_formatter<char>::result_type boost::log::v2s_mt_nt6::basic_formatter<char>::operator ()(const boost::log::v2s_mt_nt6::record_view &,boost::log::v2s_mt_nt6::basic_formatting_ostream<char,std::char_traits<char>,std::allocator<char>> &) const': cannot convert argument 2 from 'boost::log::v2s_mt_nt6::sinks::file::file_name_composer_adapter<boost::log::v2s_mt_nt6::basic_formatter<char>>::stream_type' to 'boost::log::v2s_mt_nt6::basic_formatting_ostream<char,std::char_traits<char>,std::allocator<char>> &'
file: boost\log\sinks\text_multifile_backend.hpp 107
stream_type being ostream of wchar_t due to Windows
if (boost::optional< std::string > param = settings["FileName"]) {
auto fmt = logging::parse_formatter((*param));
auto composer = sinks::file::as_file_name_composer(fmt);
backend->set_file_name_composer(composer);
}
如何使 parse_formatter 与 wchar_t 一起使用?
我也尝试使用 wchar_t 作为 sink_factory + std::wstring 的类型,但它也没有构建
Error C2664 'boost::log::v2s_mt_nt6::basic_formatter<wchar_t>::result_type boost::log::v2s_mt_nt6::basic_formatter<wchar_t>::operator ()(const boost::log::v2s_mt_nt6::record_view &,boost::log::v2s_mt_nt6::basic_formatting_ostream<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>> &) const': cannot convert argument 2 from 'boost::log::v2s_mt_nt6::expressions::aux::stream_ref<boost::log::v2s_mt_nt6::basic_formatting_ostream<char,std::char_traits<char>,std::allocator<char>>>' to 'boost::log::v2s_mt_nt6::basic_formatting_ostream<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>> &'
file: boost\log\detail\light_function.hpp 362
向作曲家提供'std::locale("en_US.UTF-8")' 不会改变任何东西,因为它是运行时
"expr::stream << expr::format(*param)" 的注释与格式化程序相同
我正在使用 boost_1_70_0
你知道有什么解决办法吗?
谢谢!
【问题讨论】: