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的」版本。