forked from github/github-services
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
On push, log individual commits to a Loggly HTTP input.
- Loading branch information
Mike Blume
committed
Dec 1, 2011
1 parent
ff462ae
commit e428a26
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |