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

Add with-extra-context macro #262

Closed
wants to merge 2 commits into from
Closed

Add with-extra-context macro #262

wants to merge 2 commits into from

Conversation

DeLaGuardo
Copy link

This macro is usefull when you don't know full context at logging time.

E.g. for more detailed logging during evaluation some logical steps:

(let [session (get-random-session)]
  (with-context {:session "some random session"}
    (log "Catch request")
    (let [user (get-user-data)]
      (with-extra-context {:user user}
        (info "log user data with session as a scope")))))

This macro is usefull when you don't know full context at logging time.

E.g. for more detailed logging during evaluation some logical steps:

```
(let [session (get-random-session)]
  (with-context {:session "some random session"}
    (log "Catch request")
    (let [user (get-user-data)]
      (with-extra-context {:user user}
        (info "log user data with session as a scope")))))
```
@ptaoussanis
Copy link
Member

Hi Kirill, thanks for this! Hope you're well!

To be honest I'm not too keen on adding another macro just for this. It's already pretty easy for someone to do (with-context (merge *context* {}) ...).

Appreciate the PR though, thanks!

@ptaoussanis ptaoussanis closed this May 5, 2020
@b-ryan
Copy link

b-ryan commented Sep 2, 2020

Just wanted to throw in my 2c, which is that I expected with-context to work this way and spent a bit searching the docs for this functionality. Perhaps an acceptable alternative would be to provide your suggestion when searching the readme or the docs for with-context. Overall it didn't take too long to arrive here though.

@b-ryan
Copy link

b-ryan commented Sep 2, 2020

To clarify: when I said "Perhaps an acceptable alternative..." I mean acceptable from your point of view, not mine :D

@ptaoussanis ptaoussanis mentioned this pull request Sep 26, 2020
ptaoussanis added a commit that referenced this pull request Sep 26, 2020
ptaoussanis added a commit that referenced this pull request Sep 27, 2020
ptaoussanis added a commit that referenced this pull request Oct 1, 2020
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

Successfully merging this pull request may close these issues.

None yet

3 participants