Module: Goat::Log

Included in:
Goat
Defined in:
lib/goat/net-common.rb

Class Method Summary collapse

Class Method Details

.lockpathObject



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.log_message(msg)
  log("#{msg['type']} #{msg.inspect}", "#{Term::ANSIColor.green(msg['type'])}: #{msg.inspect}")
end

.logfObject



12
# File 'lib/goat/net-common.rb', line 12

def self.logf; @log ||= File.open(logpath, 'a'); end

.lognameObject



9
# File 'lib/goat/net-common.rb', line 9

def self.logname; File.basename($0); end

.logpathObject



10
# File 'lib/goat/net-common.rb', line 10

def self.logpath; "/tmp/#{logname}.log"; end