Module: EY::Serverside::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
27 28 29 |
# File 'lib/engineyard-serverside/logged_output.rb', line 27 def self.logfile @@logfile end |
.logfile=(filename) ⇒ Object
22 23 24 25 |
# File 'lib/engineyard-serverside/logged_output.rb', line 22 def self.logfile=(filename) File.unlink filename if File.exist?(filename) # start fresh @@logfile = filename end |
.verbose=(v) ⇒ Object
32 33 34 |
# File 'lib/engineyard-serverside/logged_output.rb', line 32 def self.verbose=(v) @@verbose = !!v end |
.verbose? ⇒ Boolean
36 37 38 |
# File 'lib/engineyard-serverside/logged_output.rb', line 36 def self.verbose? @@verbose end |
Instance Method Details
#debug(msg) ⇒ Object
50 51 52 53 54 |
# File 'lib/engineyard-serverside/logged_output.rb', line 50 def debug(msg) with_logfile do |log| log << "#{msg}\n" end end |
#info(msg) ⇒ Object
44 45 46 47 48 |
# File 'lib/engineyard-serverside/logged_output.rb', line 44 def info(msg) with_logfile do |log| Tee.new($stdout, log) << (msg + "\n") end end |
#logged_system(cmd) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/engineyard-serverside/logged_output.rb', line 56 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
40 41 42 |
# File 'lib/engineyard-serverside/logged_output.rb', line 40 def verbose? EY::Serverside::LoggedOutput.verbose? end |