Class: Lumberjack::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Client

Returns a new instance of Client.


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/lumberjack/client.rb', line 10

def initialize(opts={})
  @opts = {
    :port => 0,
    :addresses => [],
    :ssl_certificate => nil,
    :ssl => true,
    :json => false,
  }.merge(opts)

  @opts[:addresses] = [@opts[:addresses]] if @opts[:addresses].class == String
  raise "Must set a port." if @opts[:port] == 0
  raise "Must set atleast one address" if @opts[:addresses].empty? == 0
  raise "Must set a ssl certificate or path" if @opts[:ssl_certificate].nil? && @opts[:ssl]

  @socket = connect
end

Instance Method Details

#hostObject


46
47
48
# File 'lib/lumberjack/client.rb', line 46

def host
  @socket.host
end

#write(elements, opts = {}) ⇒ Object


41
42
43
# File 'lib/lumberjack/client.rb', line 41

def write(elements, opts={})
  @socket.write_sync(elements, opts)
end