logfmtxx icon indicating copy to clipboard operation
logfmtxx copied to clipboard

log without explicit logfmtxx::field{}

Open hmoffatt opened this issue 1 month ago • 2 comments

Is it possible to omit the explicit logfmtxx::field{}? It makes logging quite wordy.

In the hackernews discussion there was a demonstration of using an initializer_list instead. https://news.ycombinator.com/item?id=39925699#39928104

hmoffatt avatar Nov 07 '25 06:11 hmoffatt

Hi,

If the demonstration you speak of is https://gcc.godbolt.org/z/dK7Tq6hja, they do so by introducing a type Any. Aren't we loosing some type safety?

linkdd avatar Nov 07 '25 10:11 linkdd

I'm not sure. Any is a wrapper around std::any. How would it be misused? Ultimately it just has to be anything that is streamable.

hmoffatt avatar Nov 08 '25 05:11 hmoffatt