Class: Logplex::Token

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

Overview

A logplex token is required for publishing events to logplex.

To create a token, see Logplex::Channel#create_token.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, channel_id, name, token_id) ⇒ Token

Public: initialize a Logplex::Token

url - the url to logplex; see Logplex::Client.new for more info channel_id - the channel id to create a token on; see Logplex::Channel for

more info

name - the string name of this token. This name will appear in logplex

output (drains and log sessions) as the application name.

token_id - the token; usually in the form ‘t.SOME-UUID-VALUE’



22
23
24
25
26
27
# File 'lib/logplex/token.rb', line 22

def initialize(url, channel_id, name, token_id)
  @url = url
  @channel_id = channel_id
  @name = name
  @id = token_id
end

Instance Attribute Details

#channel_idObject (readonly)

Returns the value of attribute channel_id.



31
32
33
# File 'lib/logplex/token.rb', line 31

def channel_id
  @channel_id
end

#idObject

Returns the value of attribute id.



30
31
32
# File 'lib/logplex/token.rb', line 30

def id
  @id
end

#nameObject

def initialize



29
30
31
# File 'lib/logplex/token.rb', line 29

def name
  @name
end

#urlObject (readonly)

Returns the value of attribute url.



32
33
34
# File 'lib/logplex/token.rb', line 32

def url
  @url
end

Instance Method Details

#emitterObject

Public: Get an emitter suitable for publishing events with this token.

Returns a Logplex::Emitter



37
38
39
40
41
# File 'lib/logplex/token.rb', line 37

def emitter
  address = [URI.parse(@url).host, 601].join(":")
  @emitter ||= Logplex::Emitter.new(address, @id)
  return @emitter
end