Module: Cucumber::Chef::Utility::LogHelper
- Included in:
- Cucumber::Chef::Utility
- Defined in:
- lib/cucumber/chef/utility/log_helper.rb
Instance Method Summary collapse
- #log_dependencies ⇒ Object
- #log_details ⇒ Object
- #log_key_value(key, value, max_key_length) ⇒ Object
- #log_page_break(max_key_length, char = '-') ⇒ Object
- #logger ⇒ Object
Instance Method Details
#log_dependencies ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/cucumber/chef/utility/log_helper.rb', line 36 def log_dependencies dependencies = { "cucumber_chef_version" => Cucumber::Chef::VERSION.inspect, "fog_version" => ::Fog::VERSION.inspect, "ruby_version" => RUBY_VERSION.inspect, "ruby_patchlevel" => RUBY_PATCHLEVEL.inspect, "ruby_platform" => RUBY_PLATFORM.inspect, "ztk_version" => ::ZTK::VERSION.inspect } if RUBY_VERSION >= "1.9" dependencies.merge!("ruby_engine" => RUBY_ENGINE.inspect) end dependencies end |
#log_details ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/cucumber/chef/utility/log_helper.rb', line 53 def log_details { "program" => $0.to_s.inspect, "uname" => %x(uname -a).chomp.strip.inspect, "chef_repo" => chef_repo.inspect, "log_file" => log_file.inspect, "config_rb" => config_rb.inspect, "labfile" => labfile.inspect } end |
#log_key_value(key, value, max_key_length) ⇒ Object
28 29 30 |
# File 'lib/cucumber/chef/utility/log_helper.rb', line 28 def log_key_value(key, value, max_key_length) $logger.info { " %s%s: %s" % [ key.upcase, '.' * (max_key_length - key.length), value.to_s ] } end |
#log_page_break(max_key_length, char = '-') ⇒ Object
32 33 34 |
# File 'lib/cucumber/chef/utility/log_helper.rb', line 32 def log_page_break(max_key_length, char='-') $logger.info { (char * (max_key_length * 2)) } end |
#logger ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/cucumber/chef/utility/log_helper.rb', line 64 def logger if (!defined?($logger) || $logger.nil?) $logger = ZTK::Logger.new(Cucumber::Chef.log_file) if Cucumber::Chef.is_rc? $logger.level = ZTK::Logger::DEBUG end dependencies = log_dependencies details = log_details max_key_length = [dependencies.keys.map(&:length).max, details.keys.map(&:length).max].max + 2 log_page_break(max_key_length, '=') details.sort.each do |key, value| log_key_value(key, value, max_key_length) end log_page_break(max_key_length) dependencies.sort.each do |key, value| log_key_value(key, value, max_key_length) end log_page_break(max_key_length) end $logger end |