Skip to content

Commit

Permalink
add simple loggly service
Browse files Browse the repository at this point in the history
On push, log individual commits to a Loggly HTTP input.
  • Loading branch information
Mike Blume committed Dec 1, 2011
1 parent ff462ae commit e428a26
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/loggly
@@ -0,0 +1,19 @@
Loggly
========

This service hook allows you to log pushed commits directly to a Loggly HTTP
input.

Install Notes
-------------

1. input token -- take this from the detail page for your HTTP input.

Developer Notes
---------------

data
- input_token

payload
- refer to docs/github_payload
12 changes: 12 additions & 0 deletions services/loggly.rb
@@ -0,0 +1,12 @@
class Service::Loggly < Service
string :input_token

def receive_push
http.headers['Content-Type'] = 'application/json'
url = "https://logs.loggly.com/inputs/#{data['input_token']}"
payload['commits'].each { |commit| http_post url, commit.to_json }
end
end



22 changes: 22 additions & 0 deletions test/loggly.rb
@@ -0,0 +1,22 @@
class JiraTest < Service::TestCase
def setup
@stubs = Faraday::Adapter::Test::Stubs.new
end

def test_push
@stubs.post "/inputs/input-foo" do |env|
assert_equal 'application/json', env[:request_headers]['Content-Type']
assert_equal 'logs.loggly.com', env[:url].host
[200, {}, '']
end

svc = service(
{"input_token" => "input-foo"},
payload)
svc.receive_push
end

def service(*args)
super Service::Loggly, *args
end
end

0 comments on commit e428a26

Please sign in to comment.