Доброго времени суток!
Есть задача: писать каждый тип сообщений (предупреждения, ошибки, инфо и дебаг) каждый в свой файл.
в общем, на такой код
enum severity_level
{
debug,
info,
warning,
error,
nolog
};
void TLogger::AddFileLog(severity_level level, const std::string & fname)
{
namespace keywords = boost::log::keywords;
boost::log::add_file_log
(
keywords::file_name = fname, /*< file name pattern >*/
keywords::rotation_size = sizelog, /*< rotate files every 10 MiB... >*/
keywords::format = "[%TimeStamp%]: %Message%",/*< log record format >*/
keywords::filter=[&]()->bool{return level==loglevel;}
);
}
In file included from /usr/include/boost/log/utility/setup/file.hpp:28:0,
from logger.cpp:23:
/usr/include/boost/log/detail/sink_init_helpers.hpp: In instantiation of ‘void boost::log::v2s_mt_posix::aux::setup_filter(SinkT&, const ArgsT&, mpl_::false_) [with SinkT = boost::log::v2s_mt_posix::sinks::synchronous_sink<boost::log::v2s_mt_posix::sinks::text_file_backend>; ArgsT = boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::filter, const TLogger::AddFileLog(severity_level, const string&)::<lambda()> >, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::format, const char [25]>, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::file_name, const std::basic_string<char> >, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::rotation_size, int>, boost::parameter::aux::empty_arg_list> > > >; mpl_::false_ = mpl_::bool_<false>]’:
/usr/include/boost/log/utility/setup/file.hpp:89:108: required from ‘boost::shared_ptr<boost::log::v2s_mt_posix::sinks::synchronous_sink<boost::log::v2s_mt_posix::sinks::text_file_backend> > boost::log::v2s_mt_posix::aux::add_file_log(const ArgsT&) [with ArgsT = boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::filter, const TLogger::AddFileLog(severity_level, const string&)::<lambda()> >, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::format, const char [25]>, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::file_name, const std::basic_string<char> >, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::rotation_size, int>, boost::parameter::aux::empty_arg_list> > > >]’
/usr/include/boost/log/utility/setup/file.hpp:127:1: required from ‘boost::shared_ptr<boost::log::v2s_mt_posix::sinks::synchronous_sink<boost::log::v2s_mt_posix::sinks::text_file_backend> > boost::log::v2s_mt_posix::add_file_log(const T0&, const T1&, const T2&, const T3&) [with T0 = boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::file_name, const std::basic_string<char> >; T1 = boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::rotation_size, int>; T2 = boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::format, const char [25]>; T3 = boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::filter, const TLogger::AddFileLog(severity_level, const string&)::<lambda()> >]’
logger.cpp:37:5: required from here
/usr/include/boost/log/detail/sink_init_helpers.hpp:74:60: error: no matching function for call to ‘acquire_filter(const TLogger::AddFileLog(severity_level, const string&)::<lambda()>&)’
s.set_filter(aux::acquire_filter(args[keywords::filter]));
^
/usr/include/boost/log/detail/sink_init_helpers.hpp:74:60: note: candidates are:
/usr/include/boost/log/detail/sink_init_helpers.hpp:47:15: note: template<class CharT> boost::log::v2s_mt_posix::filter boost::log::v2s_mt_posix::aux::acquire_filter(const CharT*)
inline filter acquire_filter(const CharT* filter)
^
/usr/include/boost/log/detail/sink_init_helpers.hpp:47:15: note: template argument deduction/substitution failed:
/usr/include/boost/log/detail/sink_init_helpers.hpp:74:60: note: mismatched types ‘const CharT*’ and ‘TLogger::AddFileLog(severity_level, const string&)::<lambda()>’
s.set_filter(aux::acquire_filter(args[keywords::filter]));
^
/usr/include/boost/log/detail/sink_init_helpers.hpp:52:15: note: template<class CharT, class TraitsT, class AllocatorT> boost::log::v2s_mt_posix::filter boost::log::v2s_mt_posix::aux::acquire_filter(const std::basic_string<_CharT, _Traits, _Alloc>&)
inline filter acquire_filter(std::basic_string< CharT, TraitsT, AllocatorT > const& filter)
^
/usr/include/boost/log/detail/sink_init_helpers.hpp:52:15: note: template argument deduction/substitution failed:
/usr/include/boost/log/detail/sink_init_helpers.hpp:74:60: note: ‘const TLogger::AddFileLog(severity_level, const string&)::<lambda()>’ is not derived from ‘const std::basic_string<_CharT, _Traits, _Alloc>’
s.set_filter(aux::acquire_filter(args[keywords::filter]));
^
/usr/include/boost/log/detail/sink_init_helpers.hpp:60:9: note: template<class FilterT> typename boost::enable_if<boost::phoenix::is_actor<T>, const FilterT&>::type boost::log::v2s_mt_posix::aux::acquire_filter(const FilterT&)
>::type acquire_filter(FilterT const& filter)
^
/usr/include/boost/log/detail/sink_init_helpers.hpp:60:9: note: template argument deduction/substitution failed:
/usr/include/boost/log/detail/sink_init_helpers.hpp: In substitution of ‘template<class FilterT> typename boost::enable_if<boost::phoenix::is_actor<T>, const FilterT&>::type boost::log::v2s_mt_posix::aux::acquire_filter(const FilterT&) [with FilterT = TLogger::AddFileLog(severity_level, const string&)::<lambda()>]’:
/usr/include/boost/log/detail/sink_init_helpers.hpp:74:60: required from ‘void boost::log::v2s_mt_posix::aux::setup_filter(SinkT&, const ArgsT&, mpl_::false_) [with SinkT = boost::log::v2s_mt_posix::sinks::synchronous_sink<boost::log::v2s_mt_posix::sinks::text_file_backend>; ArgsT = boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::filter, const TLogger::AddFileLog(severity_level, const string&)::<lambda()> >, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::format, const char [25]>, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::file_name, const std::basic_string<char> >, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::rotation_size, int>, boost::parameter::aux::empty_arg_list> > > >; mpl_::false_ = mpl_::bool_<false>]’
/usr/include/boost/log/utility/setup/file.hpp:89:108: required from ‘boost::shared_ptr<boost::log::v2s_mt_posix::sinks::synchronous_sink<boost::log::v2s_mt_posix::sinks::text_file_backend> > boost::log::v2s_mt_posix::aux::add_file_log(const ArgsT&) [with ArgsT = boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::filter, const TLogger::AddFileLog(severity_level, const string&)::<lambda()> >, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::format, const char [25]>, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::file_name, const std::basic_string<char> >, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::rotation_size, int>, boost::parameter::aux::empty_arg_list> > > >]’
/usr/include/boost/log/utility/setup/file.hpp:127:1: required from ‘boost::shared_ptr<boost::log::v2s_mt_posix::sinks::synchronous_sink<boost::log::v2s_mt_posix::sinks::text_file_backend> > boost::log::v2s_mt_posix::add_file_log(const T0&, const T1&, const T2&, const T3&) [with T0 = boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::file_name, const std::basic_string<char> >; T1 = boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::rotation_size, int>; T2 = boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::format, const char [25]>; T3 = boost::parameter::aux::tagged_argument<boost::log::v2s_mt_posix::keywords::tag::filter, const TLogger::AddFileLog(severity_level, const string&)::<lambda()> >]’
logger.cpp:37:5: required from here
/usr/include/boost/log/detail/sink_init_helpers.hpp:60:9: error: no type named ‘type’ in ‘struct boost::enable_if<boost::phoenix::is_actor<TLogger::AddFileLog(severity_level, const string&)::<lambda()>, void>, const TLogger::AddFileLog(severity_level, const string&)::<lambda()>&>’
Что не так и как поправить?