Class: CloudLogger::Papertrail

Inherits:
Base
  • Object
show all
Defined in:
lib/papertrail.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Papertrail

Returns a new instance of Papertrail.



5
6
7
8
# File 'lib/papertrail.rb', line 5

def initialize(options)
  @user = options[:user]
  @pass = options[:pass]
end

Instance Method Details

#log(message) ⇒ Object



10
11
12
# File 'lib/papertrail.rb', line 10

def log(message)
  raise "sending logs is not supported for the Papertrail driver"
end

#search(query) {|result| ... } ⇒ Object

Yields:

  • (result)


14
15
16
17
18
19
20
21
# File 'lib/papertrail.rb', line 14

def search(query)
  raw_response = RestClient.get("https://#{@user}:#{@pass}@papertrailapp.com/api/vi/events/search.json", {:params => {:q => query}})
  result = JSON.parse(raw_response)['events'].map do |log_entry|
    CloudLogger::Event.new(log_entry['message'], log_entry['received_at'])
  end 
  yield result if block_given?
  result
end