Skip to content

Commit

Permalink
logger refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Patten committed Sep 17, 2012
1 parent 7aa11be commit e9bbfa8
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 99 deletions.
4 changes: 2 additions & 2 deletions bin/cc-knife
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env ruby
require 'cucumber-chef'

$logger = Cucumber::Chef::Logger.new
$logger.level = (Cucumber::Chef.is_rc? ? Cucumber::Chef::Logger::DEBUG : Cucumber::Chef::Logger::INFO)
$logger = ZTK::Logger.new(Cucumber::Chef.log_file)
Cucumber::Chef.is_rc? and ($logger.level = ZTK::Logger::DEBUG)

# if we have bundler binstubs use that; otherwise attempt to detect
knife = (Cucumber::Chef.locate(:file, "bin", "knife") rescue nil)
Expand Down
4 changes: 2 additions & 2 deletions bin/cucumber-chef
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ class CucumberChef < Thor
exit(255)
end

$logger = Cucumber::Chef::Logger.new
Cucumber::Chef.is_rc? and ($logger.level = Cucumber::Chef::Logger::DEBUG)
$logger = ZTK::Logger.new(Cucumber::Chef.log_file)
Cucumber::Chef.is_rc? and ($logger.level = ZTK::Logger::DEBUG)

message = "cucumber-chef v#{Cucumber::Chef::VERSION}"
puts(set_color(message, :green, true))
Expand Down
4 changes: 2 additions & 2 deletions bin/push-cucumber-chef
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ def run(command)
@ssh.exec(command)
end

$logger = Cucumber::Chef::Logger.new
$logger.level = (Cucumber::Chef.is_rc? ? Cucumber::Chef::Logger::DEBUG : Cucumber::Chef::Logger::INFO)
$logger = ZTK::Logger.new(Cucumber::Chef.log_file)
Cucumber::Chef.is_rc? and ($logger.level = ZTK::Logger::DEBUG)

message = "push-cucumber-chef v#{Cucumber::Chef::VERSION}"
puts(message)
Expand Down
90 changes: 0 additions & 90 deletions lib/cucumber/chef/logger.rb

This file was deleted.

5 changes: 3 additions & 2 deletions lib/cucumber/chef/templates/cucumber/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ class CustomWorld

################################################################################

$logger = Cucumber::Chef::Logger.new
Cucumber::Chef.is_rc? and ($logger.level = Cucumber::Chef::Logger::DEBUG)
# $logger = ZTK::Logger.new(Cucumber::Chef.log_file)
$logger = ZTK::Logger.new(Cucumber::Chef.log_file)
Cucumber::Chef.is_rc? and ($logger.level = ZTK::Logger::DEBUG)

message = "cucumber-chef v#{Cucumber::Chef::VERSION}"
print(" * #{message}")
Expand Down
6 changes: 6 additions & 0 deletions lib/cucumber/chef/utility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ def external_ip
%x( wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//' ).chomp
end

def log_file
config_path = File.join(Cucumber::Chef.locate_parent(".chef"), ".cucumber-chef")
FileUtils.mkdir_p(config_path)
File.join(config_path, "cucumber-chef.log")
end

################################################################################

end
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
require 'cucumber-chef'

dev_null = File.open("/dev/null", "w")
$logger = Cucumber::Chef::Logger.new(dev_null)
$logger = ZTK::Logger.new(dev_null)

require 'simplecov'
SimpleCov.start do
Expand Down

0 comments on commit e9bbfa8

Please sign in to comment.