Class: Logging::Appenders::Flowdock

Inherits:
Logging::Appender
  • Object
show all
Includes:
Buffering
Defined in:
lib/logging/appenders/flowdock.rb

Overview

This class provides an Appender that can write to a Flowdock service over UDP.

Constant Summary collapse

DEFAULT_OPTS =

We use a background flusher instead, as the connection to Flowdock can be quite slow:

{
  flush_period: 1,
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, opts = {}) ⇒ Flowdock

Creates a new Flowdock Appender that will use the given host and port as the Flowdock server destination.

Parameters:

  • name (String)

    Stream ID to differentiate in the Flowdock server

  • api_token (String)
  • flow_user (String)


27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/logging/appenders/flowdock.rb', line 27

def initialize(name, opts = {})
  @api_token = opts[:api_token]
  @flow_user = opts[:flow_user]

  fail ArgumentError, 'Empty api_token and flow_user is not appropriate' unless api_token && !api_token.empty? && flow_user && !flow_user.empty?

  # Initialise flow var:
  flow

  super
  configure_buffering(DEFAULT_OPTS.merge(opts))
end

Instance Attribute Details

#api_tokenObject (readonly)

Returns the value of attribute api_token.



19
20
21
# File 'lib/logging/appenders/flowdock.rb', line 19

def api_token
  @api_token
end

#flowObject (readonly)

Returns the value of attribute flow.



19
20
21
# File 'lib/logging/appenders/flowdock.rb', line 19

def flow
  @flow
end

#flow_userObject (readonly)

Returns the value of attribute flow_user.



19
20
21
# File 'lib/logging/appenders/flowdock.rb', line 19

def flow_user
  @flow_user
end

Instance Method Details

#close(*args) ⇒ Object



44
45
46
47
48
49
# File 'lib/logging/appenders/flowdock.rb', line 44

def close(*args)
  super
  @flow = nil

  self
end