Logs
Opened this issue · 5 comments
This was asked on Gitter and I decided to describe how we do this and start discussion of possible directions.
We
- use lager;
- mainly use ocp;
- log with tags - here a simple macro wrapper was needed so the tags context doesn't pollute logging code. Tags are prepended to the original log message;
- log spans to a special lager sink. This means we can manage this stream independently from defaults. We log spans when they created iff "log" attribute is present. At first we logged spans in a special reporter but decided to use macros again and log synchronously;
I'm ok with lager (esp sinks) and would like to have logging here directly:
{lager_extra_sinks, [oc_log]}
- oc_log:/1,2,3 - just like lager:level but prepends tags (can be filtered I guess);
- something for logging spans :-), perhaps hook to oc_trace:start_span/finish_span.
From slack - @tsloughter: "I've been wanting to add docs about tags use with lager metadata".
Here's the lager docs on what I was thinking of https://github.com/erlang-lager/lager/#setting-dynamic-metadata-at-compile-time
Investigating this more, and not wanting to require lager, I think the best option is to wait for the new OTP logger and use it to set the metadata when a span is created. Hopefully this will be OTP 21.
Just to update this thread, now on OTP-21 the logger metadata will be set to include the trace and span ids.
Next I'll add information to the readme at least about how to use them in logger's default formatter.
I think we can close it now as support for that landed via supporting OTP 21 logger
.