justlogging-rails 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -13,4 +13,5 @@ capybara-*.html
13
13
  /spec/tmp/*
14
14
  **.orig
15
15
  rerun.txt
16
- pickle-email-*.html
16
+ pickle-email-*.html
17
+ *.gem
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
12
12
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
13
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
14
  gem.name = "justlogging-rails"
15
- gem.require_paths = ["lib"]
15
+ gem.require_paths = ["lib", "resources"]
16
16
  gem.version = Justlogging::VERSION
17
17
 
18
18
  gem.add_dependency 'rails'
@@ -10,6 +10,7 @@ module Justlogging
10
10
  @active = true
11
11
  @thread = Thread.new do
12
12
  while true do
13
+ Rails.logger.info 'Sending queue'
13
14
  if (@queue.any? && @active == true)
14
15
  send_queue
15
16
  end
@@ -19,6 +20,7 @@ module Justlogging
19
20
  end
20
21
 
21
22
  def add_to_queue(transaction)
23
+ Rails.logger.info 'added transaction to queue'
22
24
  @queue << transaction
23
25
  end
24
26
 
@@ -30,12 +32,19 @@ module Justlogging
30
32
  Net::HTTP.new(uri.host, uri.port).tap do |http|
31
33
  if uri.scheme == 'https'
32
34
  http.use_ssl = true
35
+ if File.exist?(OpenSSL::X509::DEFAULT_CERT_FILE)
36
+ http.ca_file = OpenSSL::X509::DEFAULT_CERT_FILE
37
+ else
38
+ http.ca_file = File.expand_path(File.join("..", "..", "..", "resources", "ca-bundle.crt"), __FILE__)
39
+ end
33
40
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
34
41
  end
35
42
  end
36
43
  end
37
44
 
38
45
  def send_queue
46
+ Rails.logger.info 'building JSON'
47
+
39
48
  json = ActiveSupport::JSON.encode @queue
40
49
  request = Net::HTTP::Post.new(uri.request_uri)
41
50
  request.set_form_data('api_key' => Justlogging.config[:api_key], 'log_entries' => json)
@@ -43,9 +52,12 @@ module Justlogging
43
52
  begin
44
53
  result = http_client.request(request)
45
54
  code = result.code
46
- rescue
55
+ rescue => error
56
+ Rails.logger.info "Error: #{error.message}"
47
57
  code = nil
48
58
  end
59
+ Rails.logger.info "Sent queue #{code}"
60
+
49
61
  handle_result(code)
50
62
  end
51
63
 
@@ -1,3 +1,3 @@
1
1
  module Justlogging
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end