On 07:45 pm, email@example.com wrote:
On Fri, Jun 14, 2013 at 1:41 AM, Jamu Kakar firstname.lastname@example.org wrote:
On Thu, Jun 13, 2013 at 6:41 PM, Facundo Batista email@example.com wrote:
Mmm... which is the problem with doing:
log.msg("Foo happened. Relevant information includes: " "bar=%s baz=%s boz=%s", bar, baz, boz)
Is way more readable, and in the practice the code will just need to do something like:
The example above could be written in a logfmt-compatible way as:
log.msg("message=Foo happened bar=%s baz=%s boz=%s", bar, baz, boz)
This is as readable as what you have above while being a touch easier to parse. The main point that logs are data and should emitted in a way that makes consuming them easy is a good one regardless of the format you choose. I do wonder if logfmt is unnecessary and if simply dumping JSON objects would be just as good... logfmt is slightly prettier but the JSON approach has the advantage of having a parser available in basically every language anyone would ever care about.
I think both of these should be avoided because they require the user to specify string interpolation themselves. I'd prefer to avoid that entirely, by default.
log.msg("Foo happened**", bar=bar, baz=baz, boz=boz)
This is better because:
- it keeps the data structured
- it is a lot less typing
** I would prefer this part to be "foo", but I'll keep these discussions separate :)
I think that I agree with this, except I wonder if you could supply some more realistic examples here. Let's say I have a somewhat complex 50kloc application with a log event emitted around once every 10 lines.
After I use up "foo", "bar", "baz", and "quux" I start having to refer to the hacker dictionary. This doesn't get me very close to the 5000 event identifiers I'll need. How does someone come up with this in the real world?