How do you code for storing a logger in context.Value? The same usual issues with lacking a shared logger interface happens or did I miss something neat?
On Fri, 25 Aug 2017, 08:26 Peter Mogensen <a...@one.com> wrote: > > > On 2017-08-25 05:38, buchanae.o...@gmail.com wrote: > > - We create a child logger instance which has the ID preconfigured, and > > pass that to some function calls. [3] > > I think several log packages has the feature build in. > > > instances everywhere. I think we can make either work, and so far > > neither is an obvious choice. What do you think? > > IMHO ideally, you should use local logger instances. But that of course > only becomes gradually more relevant the larger and more modularized the > application becomes. > > > A third, interesting option might be to add all logging configuration to > > the context using context.Value, > > I'd prefer this option in many cases. However, I probably wouldn't put > formatting preferences into context.Value. > > A third way to use flexible logging is to have a global logger registry > like the python "logging" package where each part of the code can > acquire its logger with GetLogger(name). Loggers are then arranged in a > hierarchy so you don't have to configure formatting for each individually. > > /Peter > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.