Class: CloudLogger::Loggly
- Inherits:
-
Base
- Object
- Base
- CloudLogger::Loggly
- Defined in:
- lib/loggly.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ Loggly
constructor
a json object with a data property which is an array with zero or more elements ResponseMatcher = /[s*({.*?)s]/m.
- #log(log_data) ⇒ Object
- #search(query) {|result| ... } ⇒ Object
Constructor Details
#initialize(options) ⇒ Loggly
a json object with a data property which is an array with zero or more elements ResponseMatcher = /[s*({.*?)s]/m
9 10 11 12 13 14 15 |
# File 'lib/loggly.rb', line 9 def initialize() @subdomain = [:subdomain] @user = [:user] @pass = [:pass] @key = [:key] @ec2 = [:ec2] ||= false end |
Instance Method Details
#log(log_data) ⇒ Object
17 18 19 20 |
# File 'lib/loggly.rb', line 17 def log(log_data) ec2flag = @ec2 ? 'ec2.' : '' RestClient.post("https://#{ec2flag}logs-01.loggly.com/inputs/#{@key}", log_data) end |
#search(query) {|result| ... } ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/loggly.rb', line 22 def search(query) raw_response = RestClient.get("https://#{@user}:#{@pass}@#{@subdomain}.loggly.com/api/search", {:params => {:q => query}}) result = JSON.parse(raw_response)['data'].map do |log_entry| CloudLogger::Event.new(log_entry['text'], log_entry['timestamp']) end yield result if block_given? result end |