Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDC-like contexts #42

Closed
prepor opened this issue Dec 2, 2013 · 8 comments
Closed

MDC-like contexts #42

prepor opened this issue Dec 2, 2013 · 8 comments

Comments

@prepor
Copy link

prepor commented Dec 2, 2013

Hello.

How about support of MDC-like (https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/MDC.html) log's contexts? It's especially useful with structural log-appenders (like Graylog or Logstash).

@ptaoussanis
Copy link
Member

Hi Andrew, could you give me some idea of how you'd like to see this implemented (or the kind of API you'd like to see)?

Am juggling quite a few things right now, so the more info you can give me the more likely I'll be able to help out.

Cheers! :-)

@prepor
Copy link
Author

prepor commented Dec 4, 2013

So. I don't have any interesting ideas about context. Just naive with-context macro with binding inside. It sucks with async code, but in modern world we have core.async with bindings support (as i know).

@prepor prepor mentioned this issue Dec 4, 2013
@ptaoussanis
Copy link
Member

Closing for now. Between the log-config support and the relative ease of using custom dynamic bindings without Timbre's assistance, I think we're probably okay here? Feel free to reopen if you disagree. Cheers! :-)

@eoliphan
Copy link

Given that it looks like some of log-config's features are now in timbre itself, would it make sense to have this in timbre now?

Where with-context (or some alternative) merges the map arg with the existing parent value?

@ptaoussanis
Copy link
Member

@eoliphan Hi Erich, with-context was added back in 2015: https://github.com/ptaoussanis/timbre/releases/tag/v4.0.0 :-)

@eoliphan
Copy link

eoliphan commented Sep 26, 2020

Hey yeah, that's what I was referring to :). As it stands, I guess with-context is more like an NDC? The current value is the innermost context. I was looking at more MDC like behavior where the current context is the sum/union of all parents. For example:

(log/with-context
  {:outer :context}
  (log/info "outer")
  (log/with-context
    {:inner :context}
    (log/info "inner")))
; outputs
{... "context":{"outer":"context"} ...}
{... "context":{"inner":"context"} ...}

You'd want the map with both the :inner and :outer keys in the second one.

So basically a variant where the binding statement sets *context* to (merge *context* ~new-context)

@ptaoussanis
Copy link
Member

@eoliphan Hi Erich, in that case I think you're probably looking for #262.
There's been a couple requests for that now, so I'll re-open it.

@ptaoussanis
Copy link
Member

Addressed with 858830a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants