diff --git a/plugins/commands/serve/service/command_service.rb b/plugins/commands/serve/service/command_service.rb index 69db750f6..8b0f67a66 100644 --- a/plugins/commands/serve/service/command_service.rb +++ b/plugins/commands/serve/service/command_service.rb @@ -4,20 +4,21 @@ module VagrantPlugins module CommandServe module Service class CommandService < SDK::CommandService::Service + include Util::ServiceInfo prepend Util::HasMapper prepend Util::HasBroker + prepend Util::HasLogger prepend Util::ExceptionLogger - LOGGER = Log4r::Logger.new("vagrant::command::serve::command") def command_info_spec(*args) SDK::FuncSpec.new end def command_info(req, ctx) - ServiceInfo.with_info(ctx) do |info| + with_info(ctx) do |info| command_info = collect_command_info(info.plugin_name, []) - LOGGER.info("command info, #{command_info}") + logger.info("command info, #{command_info}") SDK::Command::CommandInfoResp.new( command_info: command_info, ) @@ -51,7 +52,7 @@ module VagrantPlugins end def execute(req, ctx) - ServiceInfo.with_info(ctx) do |info| + with_info(ctx) do |info| plugin_name = info.plugin_name ui_client, env_client, arguments = mapper.funcspec_map(req.spec) @@ -84,7 +85,7 @@ module VagrantPlugins protected def collect_command_info(plugin_name, subcommand_names) - LOGGER.info("collecting command information for #{plugin_name} #{subcommand_names}") + logger.info("collecting command information for #{plugin_name} #{subcommand_names}") options = command_options_for(plugin_name, subcommand_names) if options.nil? hlp_msg = "" @@ -130,17 +131,17 @@ module VagrantPlugins end def get_subcommands(plugin_name, subcommand_names) - LOGGER.info("collecting subcommands for #{plugin_name} #{subcommand_names}") + logger.info("collecting subcommands for #{plugin_name} #{subcommand_names}") subcommands = [] cmds = subcommands_for(plugin_name, subcommand_names) if !cmds.nil? - LOGGER.info("found subcommands #{cmds.keys}") + logger.info("found subcommands #{cmds.keys}") cmds.keys.each do |subcmd| subnms = subcommand_names.dup subcommands << collect_command_info(plugin_name, subnms.append(subcmd.to_s)) end else - LOGGER.info("no subcommands found") + logger.info("no subcommands found") end return subcommands end diff --git a/plugins/commands/serve/service/guest_service.rb b/plugins/commands/serve/service/guest_service.rb index 9f62cbea6..b8c54b3c8 100644 --- a/plugins/commands/serve/service/guest_service.rb +++ b/plugins/commands/serve/service/guest_service.rb @@ -6,11 +6,12 @@ module VagrantPlugins class GuestService < Hashicorp::Vagrant::Sdk::GuestService::Service include CapabilityPlatformService + include Util::ServiceInfo prepend Util::HasMapper prepend Util::HasBroker + prepend Util::HasLogger prepend Util::ExceptionLogger - LOGGER = Log4r::Logger.new("vagrant::command::serve::guest") def initialize(*args, **opts, &block) caps = Vagrant.plugin("2").manager.guest_capabilities @@ -44,7 +45,7 @@ module VagrantPlugins end def detect(req, ctx) - ServiceInfo.with_info(ctx) do |info| + with_info(ctx) do |info| plugin_name = info.plugin_name target = mapper.funcspec_map(req) project = target.project @@ -52,17 +53,17 @@ module VagrantPlugins machine = env.machine(target.name.to_sym, target.provider_name.to_sym) plugin = Vagrant.plugin("2").manager.guests[plugin_name.to_s.to_sym].to_a.first if !plugin - LOGGER.debug("Failed to locate guest plugin for: #{plugin_name}") + logger.debug("Failed to locate guest plugin for: #{plugin_name}") raise "Failed to locate guest plugin for: #{plugin_name.inspect}" end guest = plugin.new begin detected = guest.detect?(machine) rescue => err - LOGGER.debug("error encountered detecting guest: #{err.class} - #{err}") + logger.debug("error encountered detecting guest: #{err.class} - #{err}") detected = false end - LOGGER.debug("detected #{detected} for guest #{plugin_name}") + logger.debug("detected #{detected} for guest #{plugin_name}") SDK::Platform::DetectResp.new( detected: detected, ) @@ -80,7 +81,7 @@ module VagrantPlugins end def parents(req, ctx) - ServiceInfo.with_info(ctx) do |info| + with_info(ctx) do |info| plugin_name = info.plugin_name plugin = Vagrant.plugin("2").manager.guests[plugin_name.to_s.to_sym].to_a.first if !plugin diff --git a/plugins/commands/serve/service/host_service.rb b/plugins/commands/serve/service/host_service.rb index 47682720f..e1e6af40c 100644 --- a/plugins/commands/serve/service/host_service.rb +++ b/plugins/commands/serve/service/host_service.rb @@ -6,9 +6,11 @@ module VagrantPlugins class HostService < Hashicorp::Vagrant::Sdk::HostService::Service include CapabilityPlatformService + include Util::ServiceInfo prepend Util::HasMapper prepend Util::HasBroker + prepend Util::HasLogger prepend Util::ExceptionLogger LOGGER = Log4r::Logger.new("vagrant::command::serve::host") @@ -43,7 +45,7 @@ module VagrantPlugins end def detect(req, ctx) - ServiceInfo.with_info(ctx) do |info| + with_info(ctx) do |info| plugin_name = info.plugin_name statebag = mapper.funcspec_map(req) plugin = Vagrant.plugin("2").manager.hosts[plugin_name.to_s.to_sym].to_a.first @@ -54,10 +56,10 @@ module VagrantPlugins begin detected = host.detect?(statebag) rescue => err - LOGGER.debug("error encountered detecting host: #{err.class} - #{err}") + logger.debug("error encountered detecting host: #{err.class} - #{err}") detected = false end - LOGGER.debug("detected #{detected} for host #{plugin_name}") + logger.debug("detected #{detected} for host #{plugin_name}") SDK::Platform::DetectResp.new( detected: detected, ) @@ -75,7 +77,7 @@ module VagrantPlugins end def parents(req, ctx) - ServiceInfo.with_info(ctx) do |info| + with_info(ctx) do |info| plugin_name = info.plugin_name plugin = Vagrant.plugin("2").manager.hosts[plugin_name.to_s.to_sym].to_a.first if !plugin diff --git a/plugins/commands/serve/service/internal_service.rb b/plugins/commands/serve/service/internal_service.rb index 5ced61bb8..e68945472 100644 --- a/plugins/commands/serve/service/internal_service.rb +++ b/plugins/commands/serve/service/internal_service.rb @@ -11,10 +11,9 @@ module VagrantPlugins module Service class InternalService < Hashicorp::Vagrant::RubyVagrant::Service prepend Util::HasBroker + prepend Util::HasLogger prepend Util::ExceptionLogger - LOG = Log4r::Logger.new("vagrant::command::serve::service::internal") - def get_plugins(req, _unused_call) plugins = [] plugin_manager = Vagrant::Plugin::V2::Plugin.manager diff --git a/plugins/commands/serve/service/provider_service.rb b/plugins/commands/serve/service/provider_service.rb index 87745d19d..57ff7ad91 100644 --- a/plugins/commands/serve/service/provider_service.rb +++ b/plugins/commands/serve/service/provider_service.rb @@ -6,8 +6,11 @@ module VagrantPlugins module CommandServe module Service class ProviderService < SDK::ProviderService::Service + include Util::ServiceInfo + prepend Util::HasMapper prepend Util::HasBroker + prepend Util::HasLogger prepend Util::ExceptionLogger def usable(req, _unused_call) @@ -35,7 +38,7 @@ module VagrantPlugins end def action_up(req, ctx) - ServiceInfo.with_info(ctx) do |info| + with_info(ctx) do |info| plugin_name = info.plugin_name ui, machine = mapper.funcspec_map(req.spec)