I think this is a little bit gray area. I don't really depend on the logger, as I use the global/default instance if not provided in the Context.
AFAIK Context is for the actual request, it should hold values only that specific for that request. A logger instrumented with that request (ID, parsed parameters ... etc) is such a value. But of course Peter Bourgon argues it's not :) Maybe all these could be avoided, if Context could only hold string values and keys, so it would be less easy and compelling to shovel values in it! Dragos Harabor <dh...@harabor.com> ezt írta (időpont: 2016. dec. 16., P, 1:04): > You may or may not agree with this but Peter makes the strong point of > making all dependencies explicit (skip to around 31:40 if you don't want to > watch it all): > https://www.infoq.com/presentations/go-patterns > > Even "hiding" the logger in Context is questionable many times. And yes, > it may make your API "ugly" or force you to update a bunch of function > signatures, but it's a better alternative to obfuscating behavior in the > code by using globals, using thread local storage or hiding things in > Context when they don't belong there. > > > On Thursday, December 15, 2016 at 5:24:30 AM UTC-8, DM wrote: > > Actually that is my problem changing all functions to pass on the context. > > > On 15-Dec-2016 6:51 pm, "Gulácsi Tamás" <tgula...@gmail.com> wrote: > > > Debraj Manna <subhara...@gmail.com> ezt írta (időpont: 2016. dec. 15., > Cs, 14:12): > > If I get you correctly I still have to pass the Context (with logger > attached) to all the functions where I wish to do the logging. > > If my understanding is not correct then can you please give me a small > example? > > No, you're right: you have to pass around the Context, or the logger. > > -- 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.