Class: Logger::LogDevice

Inherits:
Object
  • Object
show all
Defined in:
lib/log.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#devsObject (readonly)

Returns the value of attribute devs.



18
19
20
# File 'lib/log.rb', line 18

def devs
  @devs
end

Instance Method Details

#attach(log) ⇒ Object



20
21
22
23
# File 'lib/log.rb', line 20

def attach(log)
  @devs ||= {}
  @devs[log] = open_logfile(log)
end

#detach(log) ⇒ Object



25
26
27
28
29
# File 'lib/log.rb', line 25

def detach(log)
  @devs ||= {}
  @devs[log].close
  @devs.delete(log)
end

#old_writeObject



31
# File 'lib/log.rb', line 31

alias_method :old_write, :write

#write(message) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/log.rb', line 33

def write(message)
  old_write(message)

  @devs ||= {}
  @devs.each do |log, dev|
    dev.write(message)
  end
end