Class: Lumberjack::Device::Multi

Inherits:
Lumberjack::Device show all
Defined in:
lib/lumberjack/device/multi.rb

Overview

This is a logging device that forward log entries to multiple other devices.

Instance Method Summary collapse

Methods inherited from Lumberjack::Device

#cleanup_files!, #do_once

Constructor Details

#initialize(*devices) ⇒ Multi

Returns a new instance of Multi.



7
8
9
# File 'lib/lumberjack/device/multi.rb', line 7

def initialize(*devices)
  @devices = devices.flatten
end

Instance Method Details

#closeObject



23
24
25
26
27
# File 'lib/lumberjack/device/multi.rb', line 23

def close
  @devices.each do |device|
    device.close
  end
end

#datetime_formatObject



35
36
37
# File 'lib/lumberjack/device/multi.rb', line 35

def datetime_format
  @devices.detect(&:datetime_format).datetime_format
end

#datetime_format=(format) ⇒ Object



39
40
41
42
43
# File 'lib/lumberjack/device/multi.rb', line 39

def datetime_format=(format)
  @devices.each do |device|
    device.datetime_format = format
  end
end

#flushObject



17
18
19
20
21
# File 'lib/lumberjack/device/multi.rb', line 17

def flush
  @devices.each do |device|
    device.flush
  end
end

#reopen(logdev = nil) ⇒ Object



29
30
31
32
33
# File 'lib/lumberjack/device/multi.rb', line 29

def reopen(logdev = nil)
  @devices.each do |device|
    device.reopen(logdev = nil)
  end
end

#write(entry) ⇒ Object



11
12
13
14
15
# File 'lib/lumberjack/device/multi.rb', line 11

def write(entry)
  @devices.each do |device|
    device.write(entry)
  end
end