Module: EY::LoggedOutput
- Included in:
- DeployBase, Server, Strategies::Git
- Defined in:
- lib/engineyard-serverside/logged_output.rb
Defined Under Namespace
Classes: Tee
Constant Summary collapse
- @@logfile =
Tee
File.join(ENV['HOME'], 'ey.log')
- @@verbose =
false
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.logfile ⇒ Object
26 27 28 |
# File 'lib/engineyard-serverside/logged_output.rb', line 26 def self.logfile @@logfile end |
.logfile=(filename) ⇒ Object
21 22 23 24 |
# File 'lib/engineyard-serverside/logged_output.rb', line 21 def self.logfile=(filename) File.unlink filename if File.exist?(filename) # start fresh @@logfile = filename end |
.verbose=(v) ⇒ Object
31 32 33 |
# File 'lib/engineyard-serverside/logged_output.rb', line 31 def self.verbose=(v) @@verbose = !!v end |
.verbose? ⇒ Boolean
35 36 37 |
# File 'lib/engineyard-serverside/logged_output.rb', line 35 def self.verbose? @@verbose end |
Instance Method Details
#debug(msg) ⇒ Object
49 50 51 52 53 |
# File 'lib/engineyard-serverside/logged_output.rb', line 49 def debug(msg) with_logfile do |log| log << "#{msg}\n" end end |
#info(msg) ⇒ Object
43 44 45 46 47 |
# File 'lib/engineyard-serverside/logged_output.rb', line 43 def info(msg) with_logfile do |log| Tee.new($stdout, log) << (msg + "\n") end end |
#logged_system(cmd) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/engineyard-serverside/logged_output.rb', line 55 def logged_system(cmd) with_logfile do |log| out = verbose? ? Tee.new($stdout, log) : log err = Tee.new($stderr, log) # we always want to see errors out << ":: running #{cmd}\n" # :quiet means don't raise an error on nonzero exit status status = Open4.spawn cmd, 0 => '', 1 => out, 2 => err, :quiet => true status.exitstatus == 0 end end |
#verbose? ⇒ Boolean
39 40 41 |
# File 'lib/engineyard-serverside/logged_output.rb', line 39 def verbose? EY::LoggedOutput.verbose? end |