restash_rails 0.1.7 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e653abd68914a9a8afa818de203da149347eef30
4
- data.tar.gz: 76c295256ce30c2997dedfbb46ebb1d313ea7155
3
+ metadata.gz: 1345e42b815d953f6ac46464983868a4b2b3860d
4
+ data.tar.gz: 531b9b6ee7571d592d26e491cb399ef87b7363d6
5
5
  SHA512:
6
- metadata.gz: c581737904df1e09d16f4e3ca47e0070b973ea3664faba0e629f8b5890d6497b5221c710c2643ec76f990d1f376aea42b9af3ec84931282854ba65cac35c4efa
7
- data.tar.gz: 984feef7f2f69b40488102525e4e44331a7cb2bae1e7340123b8673ba8861fd99bc11e8b37d62b24947b495d80b3c65bbde27422c6e170119fdc24b841960384
6
+ metadata.gz: 8f932fbeec5c1ac0382e692ce884e318084693c1607bcda7580e4e2d7330a290815a6078c69bb2dce5bdebbe25ca61e264a7ef27eb36b93487dfb188bb635f33
7
+ data.tar.gz: e8fc82c7ce76052261d466875a629a80c8c9bbe9d74c3555fc26c534f7adc8cd1a040462d9f009c5f9a6b5dc46c5bf50eb2a3a9a1f7266e9d27c1f42f1793b99
data/.travis.yml CHANGED
@@ -1,5 +1,18 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.4.0
5
- before_install: gem install bundler -v 1.14.5
4
+ - 2.4
5
+ - head
6
+ matrix:
7
+ allow_failures:
8
+ - rvm: head
9
+ before_install: gem install bundler
10
+ deploy:
11
+ provider: rubygems
12
+ api_key:
13
+ secure: qs/Ss9SJXZWG+ScR0hmjUAyQEq5+e/xq0Pp+ppeGtItpL577s40NWcGsX+F/oxWLu6GK+T6pOCxQmU43ezOAjC96lXJpnfY3FFR+F4CJcOE+K+I2W67JZeaXHsAXOhOIh3wLrevsoAJkMpps+GrY907dUQWIdbNSsu0yk1LCew1r7Alz3ziEz7vCJ6XBwIW3TrF+Xx8o+JB7Y3shPCzGFrZ+PTSnE4Qgp/SwsVcsKrAaxsb4EKOB/UKR6Ph3bHrs7zEeoIY/nUjOKM077aNcVifgynhc3BZNTe3TsOssNS7MeMk19tThOE5opiNhz5fPc6tEjgIQXvwrYnQhiwQ4MhTxZuCduPVGVvsCoxgEH0WFjyDBwDNrTBpBo8fBahGljqqjdtVoPXQ305s5Vo5yG3juvr5E9bXyY8OB7NpRMRXWp4AmPGL0x6SFGPguW22tG8xKrn6wKalrbBG3dwJVt6AVq6xgZyGSh70iMCTVESk5J/yI9wlrWE+4+UsCYNMkGPQQaUE13/ehLSovdZA5fNTWcG7uYiIBX88MnhUBh+KSuMkv10r3aexilU228xUnZKzwQv+FaGvUerekpsiiq4dthQaWXnnvx/QtmwXIGHulCUZgB3Ou2fiS8Td2cobIu9777VyfTWuoqqDZjHxOp8a8sI6ylV20oQdefnuQiNk=
14
+ gem: restash_rails
15
+ on:
16
+ rvm: 2.4
17
+ branch: master
18
+ repo: YotpoLtd/restash-rails
@@ -3,7 +3,7 @@ require 'tcp_timeout'
3
3
  module RestashRails
4
4
  class Logger
5
5
  include ::Logger::Severity
6
- attr_accessor :app_name, :level, :outputter, :formatter, :logstash_host, :logstash_port, :timeout_options
6
+ attr_accessor :app_name, :level, :outputter, :formatter, :logstash_host, :logstash_port, :timeout_options, :output_type
7
7
  DEFAULT_TIMEOUT = 0.010
8
8
 
9
9
  def initialize(configs)
@@ -11,6 +11,7 @@ module RestashRails
11
11
  @logstash_host = configs[:host] || '127.0.0.1' #logstash host
12
12
  @logstash_port = configs[:port].to_i || 5960 #logstash port
13
13
  @app_name = configs[:app_name] || ENV['APP_NAME'] || Rails.application.class.name
14
+ @output_type = configs[:output_type] || 'tcp'
14
15
  #TCP connection timeouts in milliseconds
15
16
  if configs[:timeout_options].present?
16
17
  configs[:timeout_options].each{ |k,v| configs[:timeout_options][k] = v.to_f }
@@ -19,6 +20,7 @@ module RestashRails
19
20
  @timeout_options = { connect_timeout: DEFAULT_TIMEOUT, write_timeout: DEFAULT_TIMEOUT, read_timeout: DEFAULT_TIMEOUT }
20
21
  end
21
22
  set_formatter(configs)
23
+ @stdout_logger = ::Logger.new(STDOUT)
22
24
  end
23
25
 
24
26
  ::Logger::Severity.constants.each do |severity|
@@ -75,12 +77,24 @@ module RestashRails
75
77
 
76
78
  def write(data)
77
79
  json_data = data.to_json
80
+ case @output_type.downcase
81
+ when 'tcp'
82
+ write_to_tcp(json_data)
83
+ when 'stdout'
84
+ write_to_stdout(json_data, data[:severity].downcase)
85
+ end
86
+ rescue => e
87
+ @stdout_logger.error({ status: "Failed to write data to #{logstash_host}:#{logstash_port}", exception: e, data: data })
88
+ end
89
+
90
+ def write_to_stdout(json_data, severity)
91
+ @stdout_logger.send(severity, json_data)
92
+ end
93
+
94
+ def write_to_tcp(json_data)
78
95
  sock = ::TCPTimeout::TCPSocket.new(logstash_host, logstash_port, timeout_options)
79
96
  sock.write(json_data)
80
97
  sock.close
81
- rescue => e
82
- failures_logger = ::Logger.new(STDOUT)
83
- failures_logger.error({ status: "Failed to write data to #{logstash_host}:#{logstash_port}", exception: e, data: data })
84
98
  end
85
99
 
86
100
  def environment
@@ -1,3 +1,3 @@
1
1
  module RestashRails
2
- VERSION = '0.1.7'
2
+ VERSION = '0.2.1'
3
3
  end
@@ -6,8 +6,8 @@ require 'restash_rails/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'restash_rails'
8
8
  spec.version = RestashRails::VERSION
9
- spec.authors = ['dmitri86git']
10
- spec.email = ['dmitri@yotpo.com']
9
+ spec.authors = ['dmitri86git', 'Ariel Cabib', 'Vladislav Shub']
10
+ spec.email = ['rubygems@yotpo.com']
11
11
 
12
12
  spec.summary = 'This gem sends your Rails application logs to logstash.'
13
13
  spec.description = 'Add configurations to application.config.restash_rails and have fun.'
metadata CHANGED
@@ -1,14 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restash_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - dmitri86git
8
+ - Ariel Cabib
9
+ - Vladislav Shub
8
10
  autorequire:
9
11
  bindir: exe
10
12
  cert_chain: []
11
- date: 2017-06-27 00:00:00.000000000 Z
13
+ date: 2017-09-06 00:00:00.000000000 Z
12
14
  dependencies:
13
15
  - !ruby/object:Gem::Dependency
14
16
  name: bundler
@@ -82,7 +84,7 @@ dependencies:
82
84
  version: '0'
83
85
  description: Add configurations to application.config.restash_rails and have fun.
84
86
  email:
85
- - dmitri@yotpo.com
87
+ - rubygems@yotpo.com
86
88
  executables: []
87
89
  extensions: []
88
90
  extra_rdoc_files: []
@@ -138,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
140
  version: '0'
139
141
  requirements: []
140
142
  rubyforge_project:
141
- rubygems_version: 2.6.12
143
+ rubygems_version: 2.6.13
142
144
  signing_key:
143
145
  specification_version: 4
144
146
  summary: This gem sends your Rails application logs to logstash.