Class: LogStashLogger::Device::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash-logger/device/base.rb

Direct Known Subclasses

Balancer, Connectable, File, IO, MultiDelegator

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Base

Returns a new instance of Base.



7
8
9
# File 'lib/logstash-logger/device/base.rb', line 7

def initialize(opts={})
  @sync = opts[:sync]
end

Instance Attribute Details

#ioObject (readonly)

Returns the value of attribute io.



4
5
6
# File 'lib/logstash-logger/device/base.rb', line 4

def io
  @io
end

#syncObject

Returns the value of attribute sync.



5
6
7
# File 'lib/logstash-logger/device/base.rb', line 5

def sync
  @sync
end

Instance Method Details

#closeObject



23
24
25
26
27
28
29
# File 'lib/logstash-logger/device/base.rb', line 23

def close
  @io && @io.close
rescue => e
  warn "#{self.class} - #{e.class} - #{e.message}"
ensure
  @io = nil
end

#flushObject



19
20
21
# File 'lib/logstash-logger/device/base.rb', line 19

def flush
  @io && @io.flush
end

#to_ioObject



11
12
13
# File 'lib/logstash-logger/device/base.rb', line 11

def to_io
  @io
end

#write(message) ⇒ Object



15
16
17
# File 'lib/logstash-logger/device/base.rb', line 15

def write(message)
  @io.write(message)
end