Only add exception logger to non-generic methods

This commit is contained in:
sophia 2022-01-05 16:12:02 -06:00 committed by Paul Hinze
parent 441f82760b
commit 0dcefddae4
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0

View File

@ -4,7 +4,13 @@ module VagrantPlugins
# Adds exception logging to all public instance methods
module ExceptionLogger
def self.included(klass)
klass.public_instance_methods.each do |m_name|
# Get all the public instance methods. Need to search ancestors as well
# for modules like the Guest service which includes the CapabilityPlatform
# module
klass_public_instance_methods = klass.public_instance_methods
# Remove all generic instance methods from the list of ones to modify
logged_methods = klass_public_instance_methods - Object.public_instance_methods
logged_methods.each do |m_name|
klass.define_method(m_name) do |*args, **opts, &block|
begin
super(*args, **opts, &block)