{"action":"created","issue":{"url":"https://api.github.com/repos/elixir-lang/elixir/issues/4417","repository_url":"https://api.github.com/repos/elixir-lang/elixir","labels_url":"https://api.github.com/repos/elixir-lang/elixir/issues/4417/labels{/name}","comments_url":"https://api.github.com/repos/elixir-lang/elixir/issues/4417/comments","events_url":"https://api.github.com/repos/elixir-lang/elixir/issues/4417/events","html_url":"https://github.com/elixir-lang/elixir/issues/4417","id":142317379,"number":4417,"title":"Consider injecting binding discards for Logger when expanding","user":{"login":"chrismccord","id":576796,"avatar_url":"https://avatars.githubusercontent.com/u/576796?v=3","gravatar_id":"","url":"https://api.github.com/users/chrismccord","html_url":"https://github.com/chrismccord","followers_url":"https://api.github.com/users/chrismccord/followers","following_url":"https://api.github.com/users/chrismccord/following{/other_user}","gists_url":"https://api.github.com/users/chrismccord/gists{/gist_id}","starred_url":"https://api.github.com/users/chrismccord/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrismccord/subscriptions","organizations_url":"https://api.github.com/users/chrismccord/orgs","repos_url":"https://api.github.com/users/chrismccord/repos","events_url":"https://api.github.com/users/chrismccord/events{/privacy}","received_events_url":"https://api.github.com/users/chrismccord/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-03-21T11:13:12Z","updated_at":"2016-03-26T11:40:21Z","closed_at":null,"body":"Unused variable warnings can be caused by a Logger macro call for a Logger level that is compiled out of the environment. For example, for the test/prod env, the following code block warns for unused `status`:\r\n\r\n```elixir\r\ndef parse_response(%{status: status, body: body}) do\r\n  Logger.debug \"Got response with status #{status}\"\r\n  JSON.decode(body)\r\nend\r\n```\r\n\r\nThe only way to solve this yourself is to add a discard or if check:\r\n\r\n```elixir\r\n_ = status\r\nLogger.debug \"Got response with status #{status}\"\r\n# or\r\nif status, do:  Logger.debug \"Got response with status #{status}\"\r\n```\r\n\r\nOne solution would be to add in discards automatically when expanding logger macros that get compiled out of the program. Whether this is worth the complexity is up for discussion, but I've been bitten by this a few times so it's worth thinking about."},"comment":{"url":"https://api.github.com/repos/elixir-lang/elixir/issues/comments/201778160","html_url":"https://github.com/elixir-lang/elixir/issues/4417#issuecomment-201778160","issue_url":"https://api.github.com/repos/elixir-lang/elixir/issues/4417","id":201778160,"user":{"login":"whatyouhide","id":3890250,"avatar_url":"https://avatars.githubusercontent.com/u/3890250?v=3","gravatar_id":"","url":"https://api.github.com/users/whatyouhide","html_url":"https://github.com/whatyouhide","followers_url":"https://api.github.com/users/whatyouhide/followers","following_url":"https://api.github.com/users/whatyouhide/following{/other_user}","gists_url":"https://api.github.com/users/whatyouhide/gists{/gist_id}","starred_url":"https://api.github.com/users/whatyouhide/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whatyouhide/subscriptions","organizations_url":"https://api.github.com/users/whatyouhide/orgs","repos_url":"https://api.github.com/users/whatyouhide/repos","events_url":"https://api.github.com/users/whatyouhide/events{/privacy}","received_events_url":"https://api.github.com/users/whatyouhide/received_events","type":"User","site_admin":false},"created_at":"2016-03-26T11:40:21Z","updated_at":"2016-03-26T11:40:21Z","body":"@ericmj will open a PR for variables then :)."}}