{"action":"created","issue":{"url":"https://api.github.com/repos/chef/chef/issues/3854","labels_url":"https://api.github.com/repos/chef/chef/issues/3854/labels{/name}","comments_url":"https://api.github.com/repos/chef/chef/issues/3854/comments","events_url":"https://api.github.com/repos/chef/chef/issues/3854/events","html_url":"https://github.com/chef/chef/pull/3854","id":104322668,"number":3854,"title":"Don't print deprecations to the console until the end","user":{"login":"jkeiser","id":654882,"avatar_url":"https://avatars.githubusercontent.com/u/654882?v=3","gravatar_id":"","url":"https://api.github.com/users/jkeiser","html_url":"https://github.com/jkeiser","followers_url":"https://api.github.com/users/jkeiser/followers","following_url":"https://api.github.com/users/jkeiser/following{/other_user}","gists_url":"https://api.github.com/users/jkeiser/gists{/gist_id}","starred_url":"https://api.github.com/users/jkeiser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkeiser/subscriptions","organizations_url":"https://api.github.com/users/jkeiser/orgs","repos_url":"https://api.github.com/users/jkeiser/repos","events_url":"https://api.github.com/users/jkeiser/events{/privacy}","received_events_url":"https://api.github.com/users/jkeiser/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/chef/chef/labels/Signed%20CLA","name":"Signed CLA","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-09-01T18:03:56Z","updated_at":"2015-09-01T20:33:06Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/chef/chef/pulls/3854","html_url":"https://github.com/chef/chef/pull/3854","diff_url":"https://github.com/chef/chef/pull/3854.diff","patch_url":"https://github.com/chef/chef/pull/3854.patch"},"body":"The purpose of this is to dedupe and collect deprecation warnings and print them all at the end of the run. What we do:\r\n\r\n1. Add a `deprecation` method to `EventHandler`. This means that Chef formatters (like the doc formatter that outputs to the console) now have control over how deprecations are printed. By default, deprecations are printed to `Chef::Log` exactly as they are now.\r\n2. Add a `Chef.log` method that will return either the current run's `EventDispatcher` or `Chef::Log` if there is none. This should be expanded later, but is @api private for now because it does not support the other log methods.\r\n3. Make the doc formatter handle deprecations differently: store all locations we noticed each separate deprecation message. Then at the end of the run, print the deprecation messages to the console.\r\n\r\nThings that would be nice but are *not* part of this to make it a reasonable sized MVP:\r\n1. A switch to turn off deprecation printing globally\r\n2. Switches to turn off specific deprecation messages\r\n3. De-dupes for other things like warnings\r\n4. `Chef.log.debug`, `info`, `error` and `warn`.\r\n5. Make the location of the deprecation easier to understand--if it's in a recipe, format it that way. Right now we show the file, which is better than nothing.\r\n6. Class deprecations more generally: instead of printing a separate message for `Property MyResource.x has an array or hash default ([])` and `Property MyResource.x has an array or hash default ([])`, print  this:\r\n   ```\r\n   Properties with array or hash defaults:\r\n     - MyResource.x ([]) - recipe[x::default]:4\r\n     - MyResource.y ({}) - recipe[x::default]:5\r\n   ```\r\n\r\nA sample run (this is the output of the test):\r\n\r\n```\r\nStarting Chef Client, version 12.5.0.current.0\r\n[2015-08-31T16:58:22-07:00] WARN: Run List override has been provided.\r\n[2015-08-31T16:58:22-07:00] WARN: Original Run List: []\r\n[2015-08-31T16:58:22-07:00] WARN: Overridden Run List: [recipe[x::default]]\r\nresolving cookbooks for run list: [\"x::default\"]\r\nSynchronizing Cookbooks:\r\n  - x (0.0.0)\r\nCompiling Cookbooks...\r\nConverging 1 resources\r\nRecipe: x::default\r\n  * my_resource[blah] action nothing (skipped due to action :nothing)\r\n[2015-08-31T16:58:22-07:00] WARN: Skipping final node save because override_runlist was given\r\n\r\nRunning handlers:\r\nRunning handlers complete\r\n\r\nDeprecated features used!\r\n  Property MyResource.x has an array or hash default ([]). This means that if one resource modifies or appends to it, all other resources of the same type will also see the changes. Either freeze the constant with `.freeze` to prevent appending, or use lazy { [] }. at 1 location:\r\n    - C:/Users/jkeiser/AppData/Local/Temp/chef_repo20150831-39476-j4xt6m/config/local-mode-cache/cache/cookbooks/x/recipes/default.rb:3:in `<class:MyResource>'\r\n  Property MyResource.y has an array or hash default ({}). This means that if one resource modifies or appends to it, all other resources of the same type will also see the changes. Either freeze the constant with `.freeze` to prevent appending, or use lazy { {} }. at 1 location:\r\n    - C:/Users/jkeiser/AppData/Local/Temp/chef_repo20150831-39476-j4xt6m/config/local-mode-cache/cache/cookbooks/x/recipes/default.rb:4:in `<class:MyResource>'\r\n  x nil currently does not overwrite the value of x. This will change in Chef 13, and the value will be set to nil instead. Please change your code to explicitly accept nil using \"property :x, [MyType, nil]\", or stop setting this value to nil. at 1 location:\r\n    - C:/Users/jkeiser/src/chef/lib/chef/property.rb:419:in `x'\r\n\r\nChef Client finished, 0/1 resources updated in 7.278835 seconds\r\n```"},"comment":{"url":"https://api.github.com/repos/chef/chef/issues/comments/136853204","html_url":"https://github.com/chef/chef/pull/3854#issuecomment-136853204","issue_url":"https://api.github.com/repos/chef/chef/issues/3854","id":136853204,"user":{"login":"danielsdeleo","id":37162,"avatar_url":"https://avatars.githubusercontent.com/u/37162?v=3","gravatar_id":"","url":"https://api.github.com/users/danielsdeleo","html_url":"https://github.com/danielsdeleo","followers_url":"https://api.github.com/users/danielsdeleo/followers","following_url":"https://api.github.com/users/danielsdeleo/following{/other_user}","gists_url":"https://api.github.com/users/danielsdeleo/gists{/gist_id}","starred_url":"https://api.github.com/users/danielsdeleo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielsdeleo/subscriptions","organizations_url":"https://api.github.com/users/danielsdeleo/orgs","repos_url":"https://api.github.com/users/danielsdeleo/repos","events_url":"https://api.github.com/users/danielsdeleo/events{/privacy}","received_events_url":"https://api.github.com/users/danielsdeleo/received_events","type":"User","site_admin":false},"created_at":"2015-09-01T20:33:06Z","updated_at":"2015-09-01T20:33:06Z","body":"LGTM now"}}