0
class SeverityLevelFormatter {
private:
mutable boost::wformat format_;
public:
SeverityLevelFormatter(const std::wstring& format) : format_(format) {
}
void operator() (logging::wformatting_ostream& strm, const logging::value_ref<logging::trivial::severity_level>& value) const {
strm << boost::wformat(format_) % to_string(value.get());
}
};
class ServerityFormatterFactory : public logging::basic_formatter_factory<wchar_t, logging::trivial::severity_level> {
public:
formatter_type create_formatter(const logging::attribute_name& name, const args_map& args) {
auto it = args.find(L"format");
if (it != args.end()) {
return boost::phoenix::bind(SeverityLevelFormatter(it->second), expr::stream, expr::attr<logging::trivial::severity_level>(name));
}
else {
return expr::stream << expr::attr<logging::trivial::severity_level>(name);
}
}
};
logging::register_formatter_factory(logging::aux::default_attribute_names::severity().string(), boost::make_shared<ServerityFormatterFactory>());
register_formatter_factory在这种情况下似乎不起作用。 但是,如果我使用基于ServerityFormatterFactory的'char',它就可以工作。Boost日志text_file_backend没有wchar_t版本?
我觉得这可能是因为在“升压/日志/片/ text_file_backend.hpp”中定义的text_file_backend不具有“wchar_t的”版本。