Module: Goat::Log
- Included in:
- Goat
- Defined in:
- lib/goat/net-common.rb
Class Method Summary collapse
- .lockpath ⇒ Object
- .log(lvl, msg, termmsg = nil) ⇒ Object
- .log_message(msg) ⇒ Object
- .logf ⇒ Object
- .logname ⇒ Object
- .logpath ⇒ Object
Class Method Details
.lockpath ⇒ Object
11 |
# File 'lib/goat/net-common.rb', line 11 def self.lockpath; "/tmp/#{logname}.lock"; end |
.log(lvl, msg, termmsg = nil) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/goat/net-common.rb', line 14 def self.log(lvl, msg, termmsg=nil) logf.puts("#{Time.now.asctime} #{msg}") logf.flush termmsg ||= msg $stderr.puts(termmsg[0..90]) end |
.log_message(msg) ⇒ Object
22 23 24 |
# File 'lib/goat/net-common.rb', line 22 def self.(msg) log("#{msg['type']} #{msg.inspect}", "#{Term::ANSIColor.green(msg['type'])}: #{msg.inspect}") end |
.logf ⇒ Object
12 |
# File 'lib/goat/net-common.rb', line 12 def self.logf; @log ||= File.open(logpath, 'a'); end |
.logname ⇒ Object
9 |
# File 'lib/goat/net-common.rb', line 9 def self.logname; File.basename($0); end |
.logpath ⇒ Object
10 |
# File 'lib/goat/net-common.rb', line 10 def self.logpath; "/tmp/#{logname}.log"; end |