Module: Railstash

Defined in:
lib/railstash.rb,
lib/railstash/railtie.rb,
lib/railstash/version.rb,
lib/railstash/subscribers.rb,
lib/railstash/instrumentation.rb

Defined Under Namespace

Modules: Instrumentation Classes: ControllerLogSubscriber, Railtie

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

._log(data) ⇒ Object



35
36
37
38
# File 'lib/railstash.rb', line 35

def self._log(data)
  logstash_event = ::LogStash::Event.new(data)
  Railstash.logger << logstash_event.to_json + "\n"
end

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Railstash)

    the object that the method was called on



11
12
13
# File 'lib/railstash.rb', line 11

def self.configure
  yield self
end

.log(data) ⇒ Object



28
29
30
31
32
33
# File 'lib/railstash.rb', line 28

def self.log(data)
  data[:tags] ||= ["log"]
  run_callbacks :on_log_callbacks, data

  _log(data)
end

.log_action(context, data) ⇒ Object



23
24
25
26
# File 'lib/railstash.rb', line 23

def self.log_action(context, data)
  run_callbacks :on_log_action_callbacks, context, data
  log(data.merge(Railstash::Instrumentation.extract_context_data(context)))
end

.on_log(&block) ⇒ Object



15
16
17
# File 'lib/railstash.rb', line 15

def self.on_log(&block)
  self.on_log_callbacks << block
end

.on_log_action(&block) ⇒ Object



19
20
21
# File 'lib/railstash.rb', line 19

def self.on_log_action(&block)
  self.on_log_action_callbacks << block
end

.run_callbacks(chain, *args) ⇒ Object



40
41
42
# File 'lib/railstash.rb', line 40

def self.run_callbacks(chain, *args)
  send(chain).each { |callback| callback.call(*args) }
end