Set GRPC to use our logger

This commit is contained in:
Chris Roberts 2019-09-09 20:31:26 -07:00
parent 5c09116f53
commit c789fbf440
1 changed files with 21 additions and 0 deletions

View File

@ -1,6 +1,17 @@
require "log4r" require "log4r"
require "vagrant/go_plugin/core" require "vagrant/go_plugin/core"
require "vagrant/go_plugin/vagrant_proto/vagrant_services_pb"
module RubyLogger
include Vagrant::Util::Logger
end
module GRPC
extend Vagrant::Util::Logger
end
module Vagrant module Vagrant
module GoPlugin module GoPlugin
# Interface for go-plugin integration # Interface for go-plugin integration
@ -15,11 +26,15 @@ module Vagrant
attach_function :_setup, :Setup, [:enable_logger, :timestamps, :log_level], :bool attach_function :_setup, :Setup, [:enable_logger, :timestamps, :log_level], :bool
attach_function :_teardown, :Teardown, [], :void attach_function :_teardown, :Teardown, [], :void
attach_function :_reset, :Reset, [], :void
attach_function :_load_plugins, :LoadPlugins, [:plugin_directory], :bool attach_function :_load_plugins, :LoadPlugins, [:plugin_directory], :bool
attach_function :_list_providers, :ListProviders, [], :plugin_result attach_function :_list_providers, :ListProviders, [], :plugin_result
attach_function :_list_synced_folders, :ListSyncedFolders, [], :plugin_result attach_function :_list_synced_folders, :ListSyncedFolders, [], :plugin_result
def initialize def initialize
Vagrant::Proto.instance_eval do
::GRPC.extend(Vagrant::Util::Logger)
end
setup setup
end end
@ -72,6 +87,12 @@ module Vagrant
end end
end end
def reset
logger.debug("running go-plugin interface reset")
_reset
logger.debug("completed go-plugin interface reset")
end
# Teardown any plugins that may be currently active # Teardown any plugins that may be currently active
def teardown def teardown
logger.debug("starting teardown of go-plugin interface") logger.debug("starting teardown of go-plugin interface")