From e4c0a0bf0a0bb805a85d9c879e12f06b1dae9c81 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 1 Dec 2011 09:57:35 -0800 Subject: [PATCH] Convert warden to use log4r --- lib/vagrant/action/warden.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/vagrant/action/warden.rb b/lib/vagrant/action/warden.rb index 73be36053..9ee779177 100644 --- a/lib/vagrant/action/warden.rb +++ b/lib/vagrant/action/warden.rb @@ -1,3 +1,5 @@ +require "log4r" + module Vagrant class Action # The action warden is a middleware which injects itself between @@ -16,6 +18,7 @@ module Vagrant def initialize(actions, env) @stack = [] @actions = actions.map { |m| finalize_action(m, env) } + @logger = Log4r::Logger.new("vagrant::action::warden") end def call(env) @@ -26,7 +29,7 @@ module Vagrant # of "recoverable" middlewares in case something goes wrong! raise Errors::VagrantInterrupt if env.interrupted? action = @actions.shift - env["logger"].info("warden") { "Calling action: #{action}" } + @logger.info("Calling action: #{action}") @stack.unshift(action).first.call(env) raise Errors::VagrantInterrupt if env.interrupted? rescue SystemExit @@ -34,7 +37,7 @@ module Vagrant # we just exit immediately. raise rescue Exception => e - env["logger"].info("warden") { "Error occurred: #{e}" } + @logger.error("Error occurred: #{e}") env["vagrant.error"] = e # Something went horribly wrong. Start the rescue chain then @@ -50,7 +53,7 @@ module Vagrant def begin_rescue(env) @stack.each do |act| if act.respond_to?(:recover) - env["logger"].info("warden") { "Calling recover: #{act}" } + @logger.info("Calling recover: #{act}") act.recover(env) end end