{"action":"created","issue":{"url":"https://api.github.com/repos/ptaoussanis/timbre/issues/207","repository_url":"https://api.github.com/repos/ptaoussanis/timbre","labels_url":"https://api.github.com/repos/ptaoussanis/timbre/issues/207/labels{/name}","comments_url":"https://api.github.com/repos/ptaoussanis/timbre/issues/207/comments","events_url":"https://api.github.com/repos/ptaoussanis/timbre/issues/207/events","html_url":"https://github.com/ptaoussanis/timbre/issues/207","id":193835227,"number":207,"title":"Question re: Manipulating log messages using middleware","user":{"login":"scstarkey","id":1728638,"avatar_url":"https://avatars.githubusercontent.com/u/1728638?v=3","gravatar_id":"","url":"https://api.github.com/users/scstarkey","html_url":"https://github.com/scstarkey","followers_url":"https://api.github.com/users/scstarkey/followers","following_url":"https://api.github.com/users/scstarkey/following{/other_user}","gists_url":"https://api.github.com/users/scstarkey/gists{/gist_id}","starred_url":"https://api.github.com/users/scstarkey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scstarkey/subscriptions","organizations_url":"https://api.github.com/users/scstarkey/orgs","repos_url":"https://api.github.com/users/scstarkey/repos","events_url":"https://api.github.com/users/scstarkey/events{/privacy}","received_events_url":"https://api.github.com/users/scstarkey/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-06T17:31:33Z","updated_at":"2016-12-07T16:03:40Z","closed_at":null,"body":"Greetings,\r\n\r\nNot being familiar with this particular logging library, I'm unclear on how to manipulate log messages. I'm attempting to stamp request IDs onto all log messages for a particular thread with the following function and macro:\r\n\r\n    (defn prepend-thread-id [data]\r\n      (let [{:keys [?msg-fmt vargs]} data)]\r\n        (assoc data :vargs (into [*thread-id*] vargs)\r\n                    :?msg-fmt (str \"[%s] \" ?msg-fmt))))\r\n\r\n    (defmacro with-thread-context [& body]\r\n      `(binding [*thread-id* (slug/random-slug)]\r\n         (log/with-merged-config {:middleware [prepend-thread-id]}\r\n                                 ~@body)))\r\n\r\nI can see the middleware being called, but the resulting log output seems to be unchanged. Am I manipulating the wrong things? What is a better way to go about this?\r\n\r\nIs it better to set up a custom log format and context? Thing is I may or may not have a thread-id stamped, so I only want to update the message conditionally.\r\n\r\nThanks so much for your help!\r\n\r\nAll the best,\r\n\r\nStephen."},"comment":{"url":"https://api.github.com/repos/ptaoussanis/timbre/issues/comments/265488120","html_url":"https://github.com/ptaoussanis/timbre/issues/207#issuecomment-265488120","issue_url":"https://api.github.com/repos/ptaoussanis/timbre/issues/207","id":265488120,"user":{"login":"ryfow","id":717985,"avatar_url":"https://avatars.githubusercontent.com/u/717985?v=3","gravatar_id":"","url":"https://api.github.com/users/ryfow","html_url":"https://github.com/ryfow","followers_url":"https://api.github.com/users/ryfow/followers","following_url":"https://api.github.com/users/ryfow/following{/other_user}","gists_url":"https://api.github.com/users/ryfow/gists{/gist_id}","starred_url":"https://api.github.com/users/ryfow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryfow/subscriptions","organizations_url":"https://api.github.com/users/ryfow/orgs","repos_url":"https://api.github.com/users/ryfow/repos","events_url":"https://api.github.com/users/ryfow/events{/privacy}","received_events_url":"https://api.github.com/users/ryfow/received_events","type":"User","site_admin":false},"created_at":"2016-12-07T16:03:40Z","updated_at":"2016-12-07T16:03:40Z","body":"I'm also interested in an answer to this from @ptaoussanis.\r\n\r\nIn the mean time, I do know that you can change `:msg_` as I did here: https://github.com/ptaoussanis/timbre/pull/200#issuecomment-259541170\r\n\r\nAs I say in the comment, I don't know if it's a good idea or not."}}
{"actor":{"display_login":"ryfow"}}