Skip to content
This repository has been archived by the owner on Dec 8, 2020. It is now read-only.

Commit

Permalink
Remove from rails 23
Browse files Browse the repository at this point in the history
  • Loading branch information
binarylogic committed Dec 14, 2016
1 parent 10a9003 commit 74cd6f3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
34 changes: 18 additions & 16 deletions lib/timber/log_devices/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DeliveryError < StandardError; end
# attempt to deliver logs to the Timber API. The HTTP client buffers logs between calls.
def initialize(api_key, options = {})
@api_key = api_key
@buffer = []
@buffer = nil
@monitor = Monitor.new
@delivery_thread = Thread.new do
at_exit { deliver }
Expand All @@ -58,25 +58,27 @@ def close

private
def deliver
body = @buffer.read
@monitor.synchronize {
body = @buffer.read

request = Net::HTTP::Post.new(API_URI.request_uri).tap do |req|
req['Authorization'] = authorization_payload
req['Connection'] = CONNECTION_HEADER
req['Content-Type'] = CONTENT_TYPE
req['User-Agent'] = USER_AGENT
req.body = body
end
request = Net::HTTP::Post.new(API_URI.request_uri).tap do |req|
req['Authorization'] = authorization_payload
req['Connection'] = CONNECTION_HEADER
req['Content-Type'] = CONTENT_TYPE
req['User-Agent'] = USER_AGENT
req.body = body
end

HTTPS.request(request).tap do |res|
code = res.code.to_i
if code < 200 || code >= 300
raise DeliveryError.new("Bad response from Timber API - #{res.code}: #{res.body}")
HTTPS.request(request).tap do |res|
code = res.code.to_i
if code < 200 || code >= 300
raise DeliveryError.new("Bad response from Timber API - #{res.code}: #{res.body}")
end
Config.instance.logger.debug("Success! #{code}: #{res.body}")
end
Config.instance.logger.debug("Success! #{code}: #{res.body}")
end

@buffer.clear
@buffer.clear
}
end

def authorization_payload
Expand Down
2 changes: 1 addition & 1 deletion spec/timber/logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
end
end

context "with TaggedLogging" do
context "with TaggedLogging", :rails_23 => false do
let(:logger) { ActiveSupport::TaggedLogging.new(Timber::Logger.new(io)) }

it "should format properly with events" do
Expand Down

0 comments on commit 74cd6f3

Please sign in to comment.