From 25dac92eeb1ffa83ec549bfed0b19672c5847d80 Mon Sep 17 00:00:00 2001 From: John Keiser Date: Mon, 31 Aug 2015 14:38:50 -0700 Subject: Pass deprecations through formatter instead of logs --- lib/chef/event_dispatch/base.rb | 15 ++++++++++----- lib/chef/event_dispatch/dispatcher.rb | 4 +++- 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'lib/chef/event_dispatch') diff --git a/lib/chef/event_dispatch/base.rb b/lib/chef/event_dispatch/base.rb index 0ae5101029..1c9a58be23 100644 --- a/lib/chef/event_dispatch/base.rb +++ b/lib/chef/event_dispatch/base.rb @@ -47,14 +47,19 @@ class Chef def ohai_completed(node) end - # Already have a client key, assuming this node has registered. + # Announce that we're not going to register the client. Generally because + # we already have the private key, or because we're deliberately not using + # a key. def skipping_registration(node_name, config) end - # About to attempt to register as +node_name+ + # About to attempt to create a private key registered to the server with + # client +node_name+. def registration_start(node_name, config) end + # Successfully created the private key and registered this client with the + # server. def registration_completed end @@ -340,7 +345,6 @@ class Chef def resource_completed(resource) end - # A stream has opened. def stream_opened(stream, options = {}) end @@ -376,8 +380,9 @@ class Chef def whyrun_assumption(action, resource, message) end - ## TODO: deprecation warning. this way we can queue them up and present - # them all at once. + # Emit a message about something being deprecated. + def deprecation(message, location=caller(2..2)[0]) + end # An uncategorized message. This supports the case that a user needs to # pass output that doesn't fit into one of the callbacks above. Note that diff --git a/lib/chef/event_dispatch/dispatcher.rb b/lib/chef/event_dispatch/dispatcher.rb index 9e17d78507..0c5b27514c 100644 --- a/lib/chef/event_dispatch/dispatcher.rb +++ b/lib/chef/event_dispatch/dispatcher.rb @@ -28,6 +28,9 @@ class Chef # Define a method that will be forwarded to all def self.def_forwarding_method(method_name) define_method(method_name) do |*args| + if method_name == :deprecation && args.size == 1 + args << caller(2..2)[0] + end @subscribers.each do |s| # Skip new/unsupported event names. if s.respond_to?(method_name) @@ -49,4 +52,3 @@ class Chef end end end - -- cgit v1.2.1