diff --git a/plugins/commands/serve/mappers.rb b/plugins/commands/serve/mappers.rb index 4d93d98d9..32e25119e 100644 --- a/plugins/commands/serve/mappers.rb +++ b/plugins/commands/serve/mappers.rb @@ -152,7 +152,7 @@ module VagrantPlugins end if a.is_a?(Google::Protobuf::Any) non_any = unany(a) - logger.debug("extracted any proto message #{a.class} -> #{non_any}") + logger.debug { "extracted any proto message #{a.class} -> #{non_any}" } a = non_any end if name @@ -184,7 +184,7 @@ module VagrantPlugins # If the value given is the desired type, just return the value return value if value != GENERATE && !to.nil? && value.is_a?(to) - logger.debug("starting value mapping process #{value.class} -> #{to.nil? ? 'unknown' : to.inspect}") + logger.debug { "starting value mapping process #{value.class} -> #{to.nil? ? 'unknown' : to.inspect}" } if value.nil? && to val = (extra_args + known_arguments).detect do |item| item.is_a?(to) @@ -202,7 +202,7 @@ module VagrantPlugins # If the provided value is a protobuf value, just return that value if value.is_a?(Google::Protobuf::Value) - logger.debug("direct return of protobuf value contents - #{value.to_ruby}") + logger.debug { "direct return of protobuf value contents - #{value.to_ruby}" } return value.to_ruby end @@ -218,7 +218,7 @@ module VagrantPlugins m.output.ancestors.include?(Google::Protobuf::MessageExts) next m if !m.inputs.first.valid?(SDK::FuncSpec::Value) || m.inputs.first.valid?(value) - logger.trace("removing mapper - invalid funcspec match - #{m}") + logger.trace { "removing mapper - invalid funcspec match - #{m}" } nil end.compact map_mapper.mappers.replace(valid_mappers) @@ -329,7 +329,7 @@ module VagrantPlugins # Now send the arguments through the mapping process result = Array.new.tap do |result_args| args.each_with_index do |arg, i| - logger.debug("mapping funcspec value #{arg.inspect} to expected type #{expect[i]}") + logger.debug { "mapping funcspec value #{arg.inspect} to expected type #{expect[i]}" } result_args << map(arg, *(extra_args + result_args), to: expect[i]) end end @@ -358,7 +358,7 @@ module VagrantPlugins "FuncSpec value of type `#{v.class}' has no valid mappers" end result = m.first.call(v) - logger.trace("converted funcspec argument #{v} -> #{result}") + logger.trace { "converted funcspec argument #{v} -> #{result}" } result end end diff --git a/plugins/commands/serve/mappers/direct.rb b/plugins/commands/serve/mappers/direct.rb index 0c713c4f4..6ca23d852 100644 --- a/plugins/commands/serve/mappers/direct.rb +++ b/plugins/commands/serve/mappers/direct.rb @@ -40,7 +40,7 @@ module VagrantPlugins begin mappers.map(v) rescue => err - logger.debug("Failed to map value #{v} - #{err}\n#{err.backtrace.join("\n")}") + logger.debug { "Failed to map value #{v} - #{err}\n#{err.backtrace.join("\n")}" } raise end end @@ -64,7 +64,7 @@ module VagrantPlugins begin mappers.map(a, to: Google::Protobuf::Any) rescue => err - logger.debug("Failed to map value #{a} - #{err}\n#{err.backtrace.join("\n")}") + logger.debug { "Failed to map value #{a} - #{err}\n#{err.backtrace.join("\n")}" } raise end end diff --git a/plugins/commands/serve/mappers/environment.rb b/plugins/commands/serve/mappers/environment.rb index 750dc9c54..3f5e1a237 100644 --- a/plugins/commands/serve/mappers/environment.rb +++ b/plugins/commands/serve/mappers/environment.rb @@ -16,7 +16,7 @@ module VagrantPlugins def converter(project, ui, cacher) cid = project.resource_id return cacher.get(cid) if cacher.registered?(cid) - logger.warn("cache miss for environment with project resource id #{cid} cache=#{cacher} !!") + logger.warn { "cache miss for environment with project resource id #{cid} cache=#{cacher} !!" } env = Vagrant::Environment.new(ui: ui, client: project) cacher.register(cid, env) env @@ -66,7 +66,7 @@ module VagrantPlugins def converter(project, cacher, mapper) cid = project.resource_id return cacher.get(cid) if cacher.registered?(cid) - logger.warn("cache miss for environment with project resource id #{cid} cache=#{cacher}") + logger.warn { "cache miss for environment with project resource id #{cid} cache=#{cacher}" } ui = mapper.map(project, to: Vagrant::UI::Remote) env = Vagrant::Environment.new(client: project, ui: ui) cacher.register(cid, env) diff --git a/plugins/commands/serve/mappers/internal/graph/search.rb b/plugins/commands/serve/mappers/internal/graph/search.rb index f87ea019f..107411b40 100644 --- a/plugins/commands/serve/mappers/internal/graph/search.rb +++ b/plugins/commands/serve/mappers/internal/graph/search.rb @@ -36,7 +36,8 @@ module VagrantPlugins # @raises [NoPathError] when no path can be determined def path(src, dst) @m.synchronize do - logger.debug("finding path #{src} -> #{dst}") + logger.debug { "finding path #{src} -> #{dst}" } + @root = src # We know the root is our final destination, so flop the graph before searching @@ -67,8 +68,8 @@ module VagrantPlugins graph.remove_vertex(v) } - logger.trace("graph after DFS reduction:\n#{graph.reverse.inspect}") - logger.trace("generating list of required vertices for path #{src} -> #{dst}") + logger.trace { "graph after DFS reduction:\n#{graph.reverse.inspect}" } + logger.trace { "generating list of required vertices for path #{src} -> #{dst}" } if !graph.vertices.include?(src) raise NoPathError, @@ -88,7 +89,7 @@ module VagrantPlugins "Path generation failed to reach destination (#{src} -> #{dst&.type&.inspect})" end - logger.trace("required vertices list generation complete for path #{src} -> #{dst}") + logger.trace { "required vertices list generation complete for path #{src} -> #{dst}" } # Remove all extraneous vertices (graph.vertices - required_vertices).each do |vrt| @@ -98,7 +99,7 @@ module VagrantPlugins graph.reverse! graph.break_cycles!(src) if !graph.acyclic? - logger.debug("graph after acyclic breakage:\n#{graph.reverse.inspect}") + logger.debug { "graph after acyclic breakage:\n#{graph.reverse.inspect}" } # Apply topological sort to the graph so we have # a proper order for execution @@ -137,17 +138,19 @@ module VagrantPlugins def generate_path(src, dst) begin path = graph.shortest_path(src, dst) - o = Array(path).reverse.map { |v| - " #{v} ->" - }.join("\n") - logger.trace("path generation #{dst} -> #{src}\n#{o}") + logger.trace { + o = Array(path).reverse.map { |v| + " #{v} ->" + }.join("\n") + "path generation #{dst} -> #{src}\n#{o}" + } if path.nil? raise NoPathError, "Path generation failed to reach destination (#{dst} -> #{src})" end expand_path(path, dst, graph) rescue InvalidVertex => err - logger.trace("invalid vertex in path, removing (#{err.vertex})") + logger.trace { "invalid vertex in path, removing (#{err.vertex})" } graph.remove_vertex(err.vertex) retry end @@ -158,22 +161,22 @@ module VagrantPlugins path.each do |v| new_path << v next if !v.incoming_edges_required - logger.trace("validating incoming edges for vertex #{v}") + logger.trace { "validating incoming edges for vertex #{v}" } outs = graph.out_vertices(v) g = graph.clone g.remove_vertex(v) outs.each do |src| ipath = g.shortest_path(src, dst) if ipath.nil? || ipath.empty? - logger.trace("failed to find validating path from #{dst} -> #{src}") + logger.trace { "failed to find validating path from #{dst} -> #{src}" } raise InvalidVertex.new(v) else - logger.trace("found validating path from #{dst} -> #{src}") + logger.trace { "found validating path from #{dst} -> #{src}" } end ipath = expand_path(ipath, dst, g) new_path += ipath end - logger.trace("incoming edge validation complete for vertex #{v}") + logger.trace { "incoming edge validation complete for vertex #{v}" } end new_path end diff --git a/plugins/commands/serve/mappers/known_types.rb b/plugins/commands/serve/mappers/known_types.rb index 0c66558d7..6e524c208 100644 --- a/plugins/commands/serve/mappers/known_types.rb +++ b/plugins/commands/serve/mappers/known_types.rb @@ -53,7 +53,7 @@ module VagrantPlugins end SDK::Args::Array.new(list: r) rescue => err - logger.error("array mapping to proto failed: #{err}") + logger.error { "array mapping to proto failed: #{err}" } raise end end @@ -83,7 +83,7 @@ module VagrantPlugins r end rescue => err - logger.error("proto mapping to array failed: #{err}") + logger.error { "proto mapping to array failed: #{err}" } raise end end @@ -128,7 +128,7 @@ module VagrantPlugins end SDK::Args::Hash.new(fields: fields) rescue => err - logger.error("hash mapping to proto failed: #{err}") + logger.error { "hash mapping to proto failed: #{err}" } raise end end @@ -178,7 +178,7 @@ module VagrantPlugins end end rescue => err - logger.error("proto mapping to hash failed: #{err}") + logger.error { "proto mapping to hash failed: #{err}" } raise end end diff --git a/plugins/commands/serve/mappers/mapper.rb b/plugins/commands/serve/mappers/mapper.rb index 8dc7035cd..c6dda3652 100644 --- a/plugins/commands/serve/mappers/mapper.rb +++ b/plugins/commands/serve/mappers/mapper.rb @@ -72,7 +72,7 @@ module VagrantPlugins if m.output.ancestors.include?(Google::Protobuf::MessageExts) names = registered.map(&:name) next if names.include?("#{m.output.name}ToAny") - logger.trace("generating new Any converter #{m.output.name}ToAny") + logger.trace { "generating new Any converter #{m.output.name}ToAny" } Class.new(Mapper).class_eval(" def self.name '#{m.output.name}' + 'ToAny' @@ -173,7 +173,7 @@ module VagrantPlugins input.valid?(arg) end if value.nil? && input.type != NilClass - logger.error("missing input for type `#{input.type}' - #{args.inspect}") + logger.error { "missing input for type `#{input.type}' - #{args.inspect}" } raise ArgumentError, "Failed to locate required argument of type `#{input.type}'" end