
On 03/18/2010 07:51 PM, Stewart, Robert wrote:
Vicente's corrected version:
void my_formatter(std::ostream& strm, logging::record const& rec) { fmt::stream<< rec.line_id()<< ":<"<< rec.severity_level() << "> "<< rec.message() }
I doubt the lambda version can be clearer than that and it would certainly lead to more chances to make hard to diagnose syntax mistakes. Concerns from others about reinvention, in this case inventing your own lambda support, means that users cannot apply whatever knowledge they may have with using other lambda libraries to understanding errors in using yours. Vicente's suggested syntax is clear, simple, and permits meaningful, direct compile diagnostics. It is worth serious consideration.
I agree that it is very clear, but I fail to see how it can be supported without hardcoding the line_id and severity_level attributes into the record. I think that something like that could be done, however: strm << line_id(rec) << ":<" << severity_level(rec) << "> " << rec.message();