logstash-logger 0.24.1 → 0.25.0

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: '072939788bcf388d76724ff50216a9428402634c'
4
- data.tar.gz: b56a87e489b4f61d01d729007e9fe193e7557722
3
+ metadata.gz: 5e1ac7a22d1e29a706c724c69e31f6d8481af909
4
+ data.tar.gz: 87a7b265d354455021af800ae4c22bf28ee8e3cf
5
5
  SHA512:
6
- metadata.gz: 47ff10a039ff172bf2fc2f220258c42a40d7c5a33721b4e6091b1764f808156b22119f99994327dfbceb72fda116072fa07c7df5230ad068d782208bbc77303b
7
- data.tar.gz: 81d52c7aadfde04bd54cfa4b875c378c7c977cea6b6ccd4178acdd14815a160ea18dc67aff34f11f86b5c19daa7f77db2d0aeda76343fbdea705992597f724ce
6
+ metadata.gz: 9ed6a184198bde25c4a0fdbe0e4b563642e4b62ac343ae9996b07511d1b9295d37d7a5f38bcf950790b92ee1bfc1ababee32631db1f0bfcf5032f092bfd9128c
7
+ data.tar.gz: cac8e3fd8a892e38b1f1a01e201bbeb51bad6cb2669adbd5c317b1cedbcf208c60cdd89445e18e16b38e1576473fac104d72f2aa0ead8113455c48f8152e31bf
data/.travis.yml CHANGED
@@ -5,40 +5,24 @@ cache: bundler
5
5
  after_success:
6
6
  bundle exec codeclimate-test-reporter
7
7
  rvm:
8
- - 1.9.3
9
- - 2.0.0
10
- - 2.1.9
11
- - 2.2.6
12
- - 2.3.3
13
- - 2.4.0
14
- - jruby-19mode
8
+ - 2.2.7
9
+ - 2.3.4
10
+ - 2.4.1
15
11
  - jruby-9.1.5.0
16
12
  - rubinius-3
17
13
  gemfile:
18
- - gemfiles/rails_3.2.gemfile
19
14
  - gemfiles/rails_4.0.gemfile
20
15
  - gemfiles/rails_4.1.gemfile
21
16
  - gemfiles/rails_4.2.gemfile
22
17
  - gemfiles/rails_5.0.gemfile
18
+ - gemfiles/rails_5.1.gemfile
23
19
  matrix:
24
- exclude:
25
- - rvm: 1.9.3
26
- gemfile: gemfiles/rails_5.0.gemfile
27
- - rvm: jruby-19mode
28
- gemfile: gemfiles/rails_5.0.gemfile
29
- - rvm: 2.0.0
30
- gemfile: gemfiles/rails_5.0.gemfile
31
- - rvm: 2.1.9
32
- gemfile: gemfiles/rails_5.0.gemfile
33
- - rvm: 2.2.5
34
- gemfile: gemfiles/rails_3.2.gemfile
35
- - rvm: 2.3.1
36
- gemfile: gemfiles/rails_3.2.gemfile
37
20
  allow_failures:
38
21
  - rvm: rubinius-3
39
- - rvm: 2.4.0
40
- - rvm: jruby-19mode
41
- - rvm: jruby-9.1.5.0
22
+ - rvm: 2.4.1
23
+ gemfile: gemfiles/rails_4.0.gemfile
24
+ - rvm: 2.4.1
25
+ gemfile: gemfiles/rails_4.1.gemfile
42
26
  addons:
43
27
  code_climate:
44
28
  repo_token: 4d712355fa2863c0f33f413eeede4e52cc221c4bc989a692d97574b1f6010b69
data/Appraisals CHANGED
@@ -1,6 +1,6 @@
1
- appraise "rails-3.2" do
2
- gem "rails", "~> 3.2.18"
3
- end
1
+ #appraise "rails-3.2" do
2
+ #gem "rails", "~> 3.2.18"
3
+ #end
4
4
 
5
5
  appraise "rails-4.0" do
6
6
  gem "rails", "~> 4.0.0"
@@ -17,3 +17,7 @@ end
17
17
  appraise "rails-5.0" do
18
18
  gem "rails", "~> 5.0.0"
19
19
  end
20
+
21
+ appraise "rails-5.1" do
22
+ gem "rails", "~> 5.1.0"
23
+ end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.25.0
2
+
3
+ - Drops support for Rails 3.2, MRI Ruby < 2.2, and JRuby 1.7, since these have been EOL'ed.
4
+ - Adds support for customizing events on a per-logger level. [#113](https://github.com/dwbutler/logstash-logger/pull/113)
5
+
1
6
  ## 0.24.1
2
7
 
3
8
  - Fixes logging of a hash with symbol keys. [#116](https://github.com/dwbutler/logstash-logger/pull/116)
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # LogStashLogger
2
- [![Build Status](https://travis-ci.org/dwbutler/logstash-logger.svg?branch=master)](https://travis-ci.org/dwbutler/logstash-logger) [![Code Climate](https://codeclimate.com/github/dwbutler/logstash-logger/badges/gpa.svg)](https://codeclimate.com/github/dwbutler/logstash-logger) [![codecov.io](http://codecov.io/github/dwbutler/logstash-logger/coverage.svg?branch=master)](http://codecov.io/github/dwbutler/logstash-logger?branch=master)
2
+ [![Build Status](https://travis-ci.org/dwbutler/logstash-logger.svg?branch=master)](https://travis-ci.org/dwbutler/logstash-logger) [![Code Climate](https://codeclimate.com/github/dwbutler/logstash-logger/badges/gpa.svg)](https://codeclimate.com/github/dwbutler/logstash-logger) [![codecov.io](http://codecov.io/github/dwbutler/logstash-logger/coverage.svg?branch=master)](http://codecov.io/github/dwbutler/logstash-logger?branch=master) [![Gem Version](https://badge.fury.io/rb/logstash-logger.svg)](https://badge.fury.io/rb/logstash-logger)
3
3
 
4
4
  LogStashLogger extends Ruby's `Logger` class to log directly to
5
5
  [Logstash](https://www.elastic.co/products/logstash).
@@ -306,6 +306,13 @@ config = LogStashLogger.configure do |config|
306
306
  end
307
307
  ```
308
308
 
309
+ You can also customize events on a per-logger basis by passing a callable object
310
+ (lambda or proc) to the `customize_event` option when creating a logger:
311
+
312
+ ```ruby
313
+ LogStashLogger.new(customize_event: ->(event){ event['other_field'] = 'other_field' })
314
+ ```
315
+
309
316
  ## Buffering / Automatic Retries
310
317
 
311
318
  For devices that establish a connection to a remote service, log messages are buffered internally
@@ -394,7 +401,7 @@ end
394
401
 
395
402
  ## Rails Integration
396
403
 
397
- Verified to work with both Rails 3, 4, and 5.
404
+ Supports Rails 4 and 5.
398
405
 
399
406
  By default, every Rails log message will be written to logstash in `LogStash::Event` JSON format.
400
407
 
@@ -690,11 +697,11 @@ end
690
697
 
691
698
  Verified to work with:
692
699
 
693
- * MRI Ruby 1.9.3, 2.0, 2.1, 2.2, 2.3
694
- * JRuby 1.7, 9.0
700
+ * MRI Ruby 2.2 - 2.4
701
+ * JRuby 9.x
695
702
  * Rubinius
696
703
 
697
- Ruby 1.8.7 is not supported.
704
+ Ruby versions < 2.2 are EOL'ed and no longer supported.
698
705
 
699
706
  ## What type of logger should I use?
700
707
 
@@ -760,6 +767,11 @@ for other fields.
760
767
 
761
768
  ## Breaking changes
762
769
 
770
+ ### Version 0.25+
771
+
772
+ Rails 3.2, MRI Ruby < 2.2, and JRuby 1.7 are no longer supported, since they have been
773
+ EOL'ed. If you are on an older version of Ruby, you will need to use 0.24 or below.
774
+
763
775
  ### Version 0.5+
764
776
  * The `source` event key has been replaced with `host` to better match the latest logstash.
765
777
  * The `(host, port, type)` constructor has been deprecated in favor of an options hash constructor.
@@ -804,6 +816,7 @@ logger = LogStashLogger.new('localhost', 5228, :tcp)
804
816
  * [glaszig](https://github.com/glaszig)
805
817
  * [Bin Lan](https://github.com/lanxx019)
806
818
  * [Joao Fernandes](https://github.com/jcmfernandes)
819
+ * [CoolElvis](https://github.com/coolelvis)
807
820
 
808
821
  ## Contributing
809
822
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "codecov", :require => false, :group => :test
6
- gem "codeclimate-test-reporter", :group => :test, :require => nil
5
+ gem "codecov", require: false, group: :test
6
+ gem "codeclimate-test-reporter", group: :test, require: nil
7
7
  gem "rails", "~> 4.0.0"
8
8
 
9
- gemspec :path => "../"
9
+ gemspec path: "../"
@@ -2,8 +2,8 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "codecov", :require => false, :group => :test
6
- gem "codeclimate-test-reporter", :group => :test, :require => nil
5
+ gem "codecov", require: false, group: :test
6
+ gem "codeclimate-test-reporter", group: :test, require: nil
7
7
  gem "rails", "~> 4.1.1"
8
8
 
9
- gemspec :path => "../"
9
+ gemspec path: "../"
@@ -2,8 +2,8 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "codecov", :require => false, :group => :test
6
- gem "codeclimate-test-reporter", :group => :test, :require => nil
5
+ gem "codecov", require: false, group: :test
6
+ gem "codeclimate-test-reporter", group: :test, require: nil
7
7
  gem "rails", "~> 4.2.0"
8
8
 
9
- gemspec :path => "../"
9
+ gemspec path: "../"
@@ -2,8 +2,8 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "codecov", :require => false, :group => :test
6
- gem "codeclimate-test-reporter", :group => :test, :require => nil
5
+ gem "codecov", require: false, group: :test
6
+ gem "codeclimate-test-reporter", group: :test, require: nil
7
7
  gem "rails", "~> 5.0.0"
8
8
 
9
- gemspec :path => "../"
9
+ gemspec path: "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "codecov", require: false, group: :test
6
+ gem "codeclimate-test-reporter", group: :test, require: nil
7
+ gem "rails", "~> 5.1.0"
8
+
9
+ gemspec path: "../"
@@ -10,11 +10,11 @@ module LogStashLogger
10
10
  autoload :Cee, 'logstash-logger/formatter/cee'
11
11
  autoload :CeeSyslog, 'logstash-logger/formatter/cee_syslog'
12
12
 
13
- def self.new(formatter_type)
14
- build_formatter(formatter_type)
13
+ def self.new(formatter_type, customize_event: nil)
14
+ build_formatter(formatter_type, customize_event)
15
15
  end
16
16
 
17
- def self.build_formatter(formatter_type)
17
+ def self.build_formatter(formatter_type, customize_event)
18
18
  formatter_type ||= DEFAULT_FORMATTER
19
19
 
20
20
  formatter = if custom_formatter_instance?(formatter_type)
@@ -22,7 +22,7 @@ module LogStashLogger
22
22
  elsif custom_formatter_class?(formatter_type)
23
23
  formatter_type.new
24
24
  else
25
- formatter_klass(formatter_type).new
25
+ formatter_klass(formatter_type).new(customize_event: customize_event)
26
26
  end
27
27
 
28
28
  formatter.send(:extend, ::LogStashLogger::TaggedLogging::Formatter)
@@ -9,6 +9,11 @@ module LogStashLogger
9
9
  class Base < ::Logger::Formatter
10
10
  include ::LogStashLogger::TaggedLogging::Formatter
11
11
 
12
+ def initialize(customize_event: nil)
13
+ @customize_event = customize_event
14
+ super()
15
+ end
16
+
12
17
  def call(severity, time, progname, message)
13
18
  @event = build_event(message, severity, time)
14
19
  end
@@ -45,6 +50,8 @@ module LogStashLogger
45
50
 
46
51
  LogStashLogger.configuration.customize_event_block.call(event) if LogStashLogger.configuration.customize_event_block.respond_to?(:call)
47
52
 
53
+ @customize_event.call(event) if @customize_event
54
+
48
55
  # In case Time#to_json has been overridden
49
56
  if event.timestamp.is_a?(Time)
50
57
  event.timestamp = event.timestamp.iso8601(3)
@@ -46,7 +46,7 @@ module LogStashLogger
46
46
  end
47
47
 
48
48
  def self.build_logger(opts)
49
- formatter = Formatter.new(opts.delete(:formatter))
49
+ formatter = Formatter.new(opts.delete(:formatter), customize_event: opts.delete(:customize_event))
50
50
 
51
51
  logger = case opts[:type]
52
52
  when :multi_logger
@@ -1,3 +1,3 @@
1
1
  module LogStashLogger
2
- VERSION = "0.24.1"
2
+ VERSION = "0.25.0"
3
3
  end
@@ -21,25 +21,14 @@ Gem::Specification.new do |gem|
21
21
  gem.add_runtime_dependency 'logstash-event', '~> 1.2'
22
22
 
23
23
  gem.add_development_dependency 'rails'
24
- if RUBY_VERSION < '2'
25
- gem.add_development_dependency 'mime-types', '< 3'
26
- end
27
24
  gem.add_development_dependency 'redis'
28
25
  gem.add_development_dependency 'poseidon'
29
26
  gem.add_development_dependency 'aws-sdk'
30
27
 
31
- if RUBY_VERSION < '2' || defined?(JRUBY_VERSION)
28
+ if defined?(JRUBY_VERSION)
32
29
  gem.add_development_dependency 'SyslogLogger'
33
30
  end
34
31
 
35
- if RUBY_VERSION < '2'
36
- gem.add_development_dependency 'json', '~> 1.8'
37
- end
38
-
39
- if RUBY_VERSION < '2.1'
40
- gem.add_development_dependency 'nokogiri', '~> 1.6.8'
41
- end
42
-
43
32
  gem.add_development_dependency 'rspec', '>= 3'
44
33
  gem.add_development_dependency 'rake'
45
34
  gem.add_development_dependency 'pry'
data/spec/logger_spec.rb CHANGED
@@ -115,4 +115,14 @@ describe LogStashLogger do
115
115
  expect(listener_event["test1"]).to eq("response1")
116
116
  end
117
117
 
118
+ describe 'customize_event on instance' do
119
+ let!(:customize_event) { ->(event){ event['custom'] = 'custom' } }
120
+ let!(:logger) { LogStashLogger.new(host: host, port: port, type: connection_type, sync: true, customize_event: customize_event)}
121
+
122
+ specify 'logger produce messages with custom field' do
123
+ logger.info('test')
124
+ expect(listener_event['custom']).to eq('custom')
125
+ end
126
+ end
127
+
118
128
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.1
4
+ version: 0.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Butler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-07 00:00:00.000000000 Z
11
+ date: 2017-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-event
@@ -173,6 +173,7 @@ files:
173
173
  - gemfiles/rails_4.1.gemfile
174
174
  - gemfiles/rails_4.2.gemfile
175
175
  - gemfiles/rails_5.0.gemfile
176
+ - gemfiles/rails_5.1.gemfile
176
177
  - lib/logstash-logger.rb
177
178
  - lib/logstash-logger/buffer.rb
178
179
  - lib/logstash-logger/configuration.rb