Rename exception logger to exception transformer

The exception logger no longer logs errors. Instead it transforms
the errors into a grpc friendly format. The exception that would
have been logged at this point gets logged when the task completes.
This commit is contained in:
sophia 2022-01-11 10:09:10 -06:00 committed by Paul Hinze
parent 219473fb60
commit df5f7d40e8
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
7 changed files with 7 additions and 16 deletions

View File

@ -11,7 +11,7 @@ module VagrantPlugins
klass.prepend(Util::HasMapper) klass.prepend(Util::HasMapper)
klass.prepend(Util::HasBroker) klass.prepend(Util::HasBroker)
klass.prepend(Util::HasLogger) klass.prepend(Util::HasLogger)
klass.include(Util::ExceptionLogger) klass.include(Util::ExceptionTransformer)
klass.class_eval do klass.class_eval do
attr_reader :capabilities, :default_args attr_reader :capabilities, :default_args

View File

@ -10,7 +10,7 @@ module VagrantPlugins
prepend Util::HasMapper prepend Util::HasMapper
prepend Util::HasBroker prepend Util::HasBroker
prepend Util::HasLogger prepend Util::HasLogger
include Util::ExceptionLogger include Util::ExceptionTransformer
def command_info_spec(*args) def command_info_spec(*args)
SDK::FuncSpec.new SDK::FuncSpec.new

View File

@ -10,7 +10,7 @@ module VagrantPlugins
prepend Util::HasBroker prepend Util::HasBroker
prepend Util::HasLogger prepend Util::HasLogger
include Util::HasSeeds::Service include Util::HasSeeds::Service
include Util::ExceptionLogger include Util::ExceptionTransformer
def initialize(*args, **opts, &block) def initialize(*args, **opts, &block)
super() super()

View File

@ -12,7 +12,7 @@ module VagrantPlugins
class InternalService < Hashicorp::Vagrant::RubyVagrant::Service class InternalService < Hashicorp::Vagrant::RubyVagrant::Service
prepend Util::HasBroker prepend Util::HasBroker
prepend Util::HasLogger prepend Util::HasLogger
include Util::ExceptionLogger include Util::ExceptionTransformer
def get_plugins(req, _unused_call) def get_plugins(req, _unused_call)
plugins = [] plugins = []

View File

@ -12,7 +12,7 @@ module VagrantPlugins
prepend Util::HasMapper prepend Util::HasMapper
prepend Util::HasBroker prepend Util::HasBroker
prepend Util::HasLogger prepend Util::HasLogger
include Util::ExceptionLogger include Util::ExceptionTransformer
def usable(req, _unused_call) def usable(req, _unused_call)
nil nil

View File

@ -4,7 +4,7 @@ module VagrantPlugins
autoload :Cacher, Vagrant.source_root.join("plugins/commands/serve/util/cacher").to_s autoload :Cacher, Vagrant.source_root.join("plugins/commands/serve/util/cacher").to_s
autoload :ClientSetup, Vagrant.source_root.join("plugins/commands/serve/util/client_setup").to_s autoload :ClientSetup, Vagrant.source_root.join("plugins/commands/serve/util/client_setup").to_s
autoload :Connector, Vagrant.source_root.join("plugins/commands/serve/util/connector").to_s autoload :Connector, Vagrant.source_root.join("plugins/commands/serve/util/connector").to_s
autoload :ExceptionLogger, Vagrant.source_root.join("plugins/commands/serve/util/exception_logger").to_s autoload :ExceptionTransformer, Vagrant.source_root.join("plugins/commands/serve/util/exception_transformer").to_s
autoload :HasBroker, Vagrant.source_root.join("plugins/commands/serve/util/has_broker").to_s autoload :HasBroker, Vagrant.source_root.join("plugins/commands/serve/util/has_broker").to_s
autoload :HasLogger, Vagrant.source_root.join("plugins/commands/serve/util/has_logger").to_s autoload :HasLogger, Vagrant.source_root.join("plugins/commands/serve/util/has_logger").to_s
autoload :HasMapper, Vagrant.source_root.join("plugins/commands/serve/util/has_mapper").to_s autoload :HasMapper, Vagrant.source_root.join("plugins/commands/serve/util/has_mapper").to_s

View File

@ -2,7 +2,7 @@ module VagrantPlugins
module CommandServe module CommandServe
module Util module Util
# Adds exception logging to all public instance methods # Adds exception logging to all public instance methods
module ExceptionLogger module ExceptionTransformer
prepend Util::HasMapper prepend Util::HasMapper
def self.included(klass) def self.included(klass)
@ -26,7 +26,6 @@ module VagrantPlugins
locale: "en-US", message: err.message locale: "en-US", message: err.message
) )
) )
proto = Google::Rpc::Status.new( proto = Google::Rpc::Status.new(
code: GRPC::Core::StatusCodes::UNKNOWN, code: GRPC::Core::StatusCodes::UNKNOWN,
message: "#{err.message}\n#{err.backtrace.join("\n")}", message: "#{err.message}\n#{err.backtrace.join("\n")}",
@ -39,14 +38,6 @@ module VagrantPlugins
err.message, err.message,
{grpc_status_details_bin_trailer => encoded_proto}, {grpc_status_details_bin_trailer => encoded_proto},
) )
if self.respond_to?(:logger)
# logger.error(err.message)
# logger.debug("#{err.class}: #{err}\n#{err.backtrace.join("\n")}")
logger.debug("status: #{grpc_error.to_status}")
logger.debug("rpc status: #{grpc_error.to_rpc_status}")
end
raise grpc_error raise grpc_error
end end
end end