Convert warden to use log4r
This commit is contained in:
parent
52f3f8aa67
commit
e4c0a0bf0a
|
@ -1,3 +1,5 @@
|
||||||
|
require "log4r"
|
||||||
|
|
||||||
module Vagrant
|
module Vagrant
|
||||||
class Action
|
class Action
|
||||||
# The action warden is a middleware which injects itself between
|
# The action warden is a middleware which injects itself between
|
||||||
|
@ -16,6 +18,7 @@ module Vagrant
|
||||||
def initialize(actions, env)
|
def initialize(actions, env)
|
||||||
@stack = []
|
@stack = []
|
||||||
@actions = actions.map { |m| finalize_action(m, env) }
|
@actions = actions.map { |m| finalize_action(m, env) }
|
||||||
|
@logger = Log4r::Logger.new("vagrant::action::warden")
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
|
@ -26,7 +29,7 @@ module Vagrant
|
||||||
# of "recoverable" middlewares in case something goes wrong!
|
# of "recoverable" middlewares in case something goes wrong!
|
||||||
raise Errors::VagrantInterrupt if env.interrupted?
|
raise Errors::VagrantInterrupt if env.interrupted?
|
||||||
action = @actions.shift
|
action = @actions.shift
|
||||||
env["logger"].info("warden") { "Calling action: #{action}" }
|
@logger.info("Calling action: #{action}")
|
||||||
@stack.unshift(action).first.call(env)
|
@stack.unshift(action).first.call(env)
|
||||||
raise Errors::VagrantInterrupt if env.interrupted?
|
raise Errors::VagrantInterrupt if env.interrupted?
|
||||||
rescue SystemExit
|
rescue SystemExit
|
||||||
|
@ -34,7 +37,7 @@ module Vagrant
|
||||||
# we just exit immediately.
|
# we just exit immediately.
|
||||||
raise
|
raise
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
env["logger"].info("warden") { "Error occurred: #{e}" }
|
@logger.error("Error occurred: #{e}")
|
||||||
env["vagrant.error"] = e
|
env["vagrant.error"] = e
|
||||||
|
|
||||||
# Something went horribly wrong. Start the rescue chain then
|
# Something went horribly wrong. Start the rescue chain then
|
||||||
|
@ -50,7 +53,7 @@ module Vagrant
|
||||||
def begin_rescue(env)
|
def begin_rescue(env)
|
||||||
@stack.each do |act|
|
@stack.each do |act|
|
||||||
if act.respond_to?(:recover)
|
if act.respond_to?(:recover)
|
||||||
env["logger"].info("warden") { "Calling recover: #{act}" }
|
@logger.info("Calling recover: #{act}")
|
||||||
act.recover(env)
|
act.recover(env)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue