Boost.Log:与Phoenix流格式一起使用时,add_console_log是不明确的?

时间:2014-01-03 23:15:40

标签: c++ visual-c++ boost c++11

我觉得我在这里缺少一些基本的东西。我在我的C ++ 11应用程序中设置了这样的日志记录:

    auto format = expr::stream
        << "[" << expr::attr<Severity>("Severity") << "] "
        << expr::format_date_time<boost::posix_time::ptime>("TimeStamp", "%d/%m/%Y %H:%M:%S") << ": "
        << expr::message;

    add_console_log(std::clog, keywords::format = format);
    add_file_log("isis.log", keywords::format = format);

    add_common_attributes();

这对于add_file_log调用很有用,正如预期的那样。但是add_console_log调用我得到一个关于它不明确的编译错误。我在这里承认我自己的弱点在于发现这些基于模板的深层错误几乎难以辨认,但在我看来,这应该是一个相对标准的用例。

我真的不想粘贴整个错误字符串(它很大),但这里是重要部分:

error C2668: 'boost::log::v2s_mt_nt5::add_console_log' : ambiguous call to overloaded function
1>          c:\code\boost_1_55_0\boost\log\utility\setup\console.hpp(134): could be 'boost::shared_ptr<boost::log::v2s_mt_nt5::sinks::synchronous_sink<boost::log::v2s_mt_nt5::sinks::text_ostream_backend>> boost::log::v2s_mt_nt5::add_console_log<char,boost::parameter::aux::tagged_argument<Keyword,boost::phoenix::actor<Expr>>>(std::basic_ostream<char,std::char_traits<char>> &,const ArgT1 &)'
1>          with
1>          [
1>              Keyword=boost::log::v2s_mt_nt5::keywords::tag::format
1>  ,            Expr=boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_left,boost::proto::argsns_::list2<boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_left,boost::proto::argsns_::list2<boost::phoenix::actor<boost::log::v2s_mt_nt5::expressions::aux::attribute_output_terminal<boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_left,boost::proto::argsns_::list2<boost::phoenix::actor<boost::log::v2s_mt_nt5::expressions::aux::attribute_output_terminal<boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_left,boost::proto::argsns_::list2<boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<boost::phoenix::argument<2>>,0>>,boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<char [2]>,0>>>,2>>,Isis::Severity,boost::log::v2s_mt_nt5::fallback_to_none,boost::log::v2s_mt_nt5::to_log_fun<void>>>,boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<char [3]>,0>>>,2>>,boost::posix_time::ptime,boost::log::v2s_mt_nt5::fallback_to_none,boost::log::v2s_mt_nt5::aux::light_function<void (boost::log::v2s_mt_nt5::basic_formatting_ostream<char,std::char_traits<char>,std::allocator<char>> &,const boost::posix_time::ptime &)>>>,boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<char [3]>,0>>>,2>>,boost::log::v2s_mt_nt5::expressions::attribute_actor<boost::mpl::vector2<std::string,std::wstring>,boost::log::v2s_mt_nt5::fallback_to_none,boost::log::v2s_mt_nt5::expressions::tag::message,boost::phoenix::actor>>,2>
1>  ,            ArgT1=boost::parameter::aux::tagged_argument<boost::log::v2s_mt_nt5::keywords::tag::format,boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_left,boost::proto::argsns_::list2<boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_left,boost::proto::argsns_::list2<boost::phoenix::actor<boost::log::v2s_mt_nt5::expressions::aux::attribute_output_terminal<boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_left,boost::proto::argsns_::list2<boost::phoenix::actor<boost::log::v2s_mt_nt5::expressions::aux::attribute_output_terminal<boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_left,boost::proto::argsns_::list2<boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<boost::phoenix::argument<2>>,0>>,boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<char [2]>,0>>>,2>>,Isis::Severity,boost::log::v2s_mt_nt5::fallback_to_none,boost::log::v2s_mt_nt5::to_log_fun<void>>>,boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<char [3]>,0>>>,2>>,boost::posix_time::ptime,boost::log::v2s_mt_nt5::fallback_to_none,boost::log::v2s_mt_nt5::aux::light_function<void (boost::log::v2s_mt_nt5::basic_formatting_ostream<char,std::char_traits<char>,std::allocator<char>> &,const boost::posix_time::ptime &)>>>,boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<char [3]>,0>>>,2>>,boost::log::v2s_mt_nt5::expressions::attribute_actor<boost::mpl::vector2<std::string,std::wstring>,boost::log::v2s_mt_nt5::fallback_to_none,boost::log::v2s_mt_nt5::expressions::tag::message,boost::phoenix::actor>>,2>>>
1>          ]
1>          c:\code\boost_1_55_0\boost\log\utility\setup\console.hpp(60): or       'boost::shared_ptr<boost::log::v2s_mt_nt5::sinks::synchronous_sink<boost::log::v2s_mt_nt5::sinks::text_ostream_backend>> boost::log::v2s_mt_nt5::aux::add_console_log<char,boost::parameter::aux::tagged_argument<Keyword,boost::phoenix::actor<Expr>>>(std::basic_ostream<char,std::char_traits<char>> &,const ArgsT &)' [found using argument-dependent lookup]
1>          with
1>          [
1>              Keyword=boost::log::v2s_mt_nt5::keywords::tag::format
1>  ,            Expr=boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_left,boost::proto::argsns_::list2<boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_left,boost::proto::argsns_::list2<boost::phoenix::actor<boost::log::v2s_mt_nt5::expressions::aux::attribute_output_terminal<boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_left,boost::proto::argsns_::list2<boost::phoenix::actor<boost::log::v2s_mt_nt5::expressions::aux::attribute_output_terminal<boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_left,boost::proto::argsns_::list2<boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<boost::phoenix::argument<2>>,0>>,boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<char [2]>,0>>>,2>>,Isis::Severity,boost::log::v2s_mt_nt5::fallback_to_none,boost::log::v2s_mt_nt5::to_log_fun<void>>>,boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<char [3]>,0>>>,2>>,boost::posix_time::ptime,boost::log::v2s_mt_nt5::fallback_to_none,boost::log::v2s_mt_nt5::aux::light_function<void (boost::log::v2s_mt_nt5::basic_formatting_ostream<char,std::char_traits<char>,std::allocator<char>> &,const boost::posix_time::ptime &)>>>,boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<char [3]>,0>>>,2>>,boost::log::v2s_mt_nt5::expressions::attribute_actor<boost::mpl::vector2<std::string,std::wstring>,boost::log::v2s_mt_nt5::fallback_to_none,boost::log::v2s_mt_nt5::expressions::tag::message,boost::phoenix::actor>>,2>
1>  ,            ArgsT=boost::parameter::aux::tagged_argument<boost::log::v2s_mt_nt5::keywords::tag::format,boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_left,boost::proto::argsns_::list2<boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_left,boost::proto::argsns_::list2<boost::phoenix::actor<boost::log::v2s_mt_nt5::expressions::aux::attribute_output_terminal<boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_left,boost::proto::argsns_::list2<boost::phoenix::actor<boost::log::v2s_mt_nt5::expressions::aux::attribute_output_terminal<boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_left,boost::proto::argsns_::list2<boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<boost::phoenix::argument<2>>,0>>,boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<char [2]>,0>>>,2>>,Isis::Severity,boost::log::v2s_mt_nt5::fallback_to_none,boost::log::v2s_mt_nt5::to_log_fun<void>>>,boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<char [3]>,0>>>,2>>,boost::posix_time::ptime,boost::log::v2s_mt_nt5::fallback_to_none,boost::log::v2s_mt_nt5::aux::light_function<void (boost::log::v2s_mt_nt5::basic_formatting_ostream<char,std::char_traits<char>,std::allocator<char>> &,const boost::posix_time::ptime &)>>>,boost::phoenix::actor<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<char [3]>,0>>>,2>>,boost::log::v2s_mt_nt5::expressions::attribute_actor<boost::mpl::vector2<std::string,std::wstring>,boost::log::v2s_mt_nt5::fallback_to_none,boost::log::v2s_mt_nt5::expressions::tag::message,boost::phoenix::actor>>,2>>>
1>          ]

作为补充信息,如果我将格式用作代码中的变量,或者将整个格式块移动到内联到add_console_log调用,则无关紧要。文档清楚地指出add_file_log和add_console_log都应该接受流样式格式化块,所以我不知所措。我甚至不知道从哪种方式开始,可以去除格式参数以消除歧义(如果这甚至是答案)。

编译器是Visual C ++ 12(Visual Studio 2013)。

0 个答案:

没有答案