logstash-logger 0.3.0 → 0.4.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: 289d8d944755e6c3be2857d075b37d8e5c560a45
4
- data.tar.gz: 8fdff518b64fdb1c71dc60ba6f9f75183a092831
3
+ metadata.gz: 4495e92019c98077d726a256f7713ffb43b1a6f2
4
+ data.tar.gz: 2768785f7ae86851d7f09d2270a5fb8565ec4080
5
5
  SHA512:
6
- metadata.gz: dc0992ffd0c6e3478d8018590bcb16fbd436713672c4fc9a6a64595d563002cea11e8f4dae61eb8c99b239f29215213c5ac1dd4dcfccf6ac766a5b241807848c
7
- data.tar.gz: ad911e6164b8fc9d53d7f0afb54b68ce0d3f8eef091f4513920cb5fab8645cb5b3366b81c7e7763d491b342140f906bad55a101b341d2857a760252f59789e4c
6
+ metadata.gz: b1931b2ca5c0bbd7bf786f04f7226d846d499bb5ec0b316412d6fc69e050bb7858cfdf201f70c09c287f225be6fdd96962bf7493cf64fc7afe5925b944eddd11
7
+ data.tar.gz: a521fe134818cc560c90a906291622352370c84ec5e9de4a9e223544426efd091b204a0724e16bf584bb554950bbb00ffe26c7b6056b839fc06d9cf51e758e92
data/.travis.yml CHANGED
@@ -1,10 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- # - ree
4
- # - 1.8.7
5
3
  - 1.9.3
6
4
  - 2.0.0
7
- # - jruby-18mode # JRuby in 1.8 mode
8
5
  - jruby-19mode # JRuby in 1.9 mode
9
6
  # - rbx-18mode
10
7
  # - rbx-19mode
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # LogStashLogger [![Build Status](https://travis-ci.org/dwbutler/logstash-logger.png?branch=master)](https://travis-ci.org/dwbutler/logstash-logger)
2
2
 
3
3
  This gem implements a subclass of Ruby's Logger class that logs directly to [logstash](http://logstash.net).
4
- It writes to a logstash listener over a TCP connection, in logstash JSON format. This is an improvement over
4
+ It writes to a logstash listener over a UDP (default) or TCP connection, in logstash JSON format. This is an improvement over
5
5
  writing to a file or syslog since logstash can receive the structured data directly.
6
6
 
7
7
  ## Features
@@ -72,15 +72,21 @@ For a more detailed discussion of UDP vs TCP, I recommend reading this article:
72
72
 
73
73
  Verified to work with:
74
74
 
75
- * Ruby 1.9.3
76
- * Ruby 2.0.0
75
+ * MRI Ruby 1.9.3
76
+ * MRI Ruby 2.0.0
77
77
  * JRuby 1.7+ (1.9 mode)
78
78
 
79
- Ruby 1.8.7 is not supported because LogStash::Event is not compatible with Ruby 1.8.7. This might change in the future.
79
+ Ruby 1.8.7 is not supported because LogStash::Event is not compatible with Ruby 1.8.7. This will probably not change.
80
80
 
81
81
  The specs don't pass in Rubinius yet, but the logger does work.
82
82
 
83
- ## Breaking change in version 0.3+
83
+ ## Breaking changes
84
+
85
+ ### Version 0.4+
86
+ Logstash::Event decided to go ahead and break the existing JSON format starting in version 1.2+. If you're using this version, you'll need to install
87
+ LogStashLogger version 0.4+. This is not backwards compatible with the old LogStash::Event v1.1.5.
88
+
89
+ ### Version 0.3+
84
90
  Earlier versions of this gem (<= 0.2.1) only implemented a TCP connection. Newer versions (>= 0.3) also implement UDP, and use that as the new default.
85
91
  Please be aware if you are using the default constructor and still require TCP, you should add an additional argument:
86
92
 
@@ -1,7 +1,7 @@
1
1
  require 'logstash-logger/version'
2
2
 
3
3
  require 'socket'
4
- require 'logstash-event'
4
+ require 'logstash/event'
5
5
 
6
6
  require 'logstash-logger/socket'
7
7
  require 'logstash-logger/logger'
@@ -2,7 +2,7 @@ class LogStashLogger < ::Logger
2
2
 
3
3
  attr_reader :client
4
4
 
5
- LOGSTASH_EVENT_FIELDS = %w(@timestamp @tags @type @source @fields @message).freeze
5
+ LOGSTASH_EVENT_FIELDS = %w(@timestamp @tags @type @source @fields message).freeze
6
6
  HOST = ::Socket.gethostname
7
7
 
8
8
  def initialize(host, port, socket_type=:udp)
@@ -24,7 +24,7 @@ class LogStashLogger < ::Logger
24
24
  end
25
25
  end
26
26
  @logdev.write(
27
- format_message(format_severity(severity), LogStash::Time.now, progname, message))
27
+ format_message(format_severity(severity), Time.now, progname, message))
28
28
  true
29
29
  end
30
30
 
@@ -51,13 +51,13 @@ class LogStashLogger < ::Logger
51
51
  event_data["@fields"].merge!(data)
52
52
  LogStash::Event.new(event_data)
53
53
  when String
54
- LogStash::Event.new("@message" => data, "@timestamp" => time)
54
+ LogStash::Event.new("message" => data, "@timestamp" => time)
55
55
  end
56
56
 
57
57
  event['severity'] ||= severity
58
58
  #event.type = progname
59
- if event.source == 'unknown'
60
- event["@source"] = HOST
59
+ if event['source'] == 'unknown'
60
+ event['source'] = HOST
61
61
  end
62
62
 
63
63
  event
@@ -1,5 +1,5 @@
1
1
  require 'logger'
2
2
 
3
3
  class LogStashLogger < ::Logger
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
@@ -17,7 +17,8 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
- gem.add_runtime_dependency 'logstash-event'
20
+ gem.add_runtime_dependency 'logstash-event', '~> 1.2'
21
21
  gem.add_development_dependency 'rspec'
22
22
  gem.add_development_dependency 'rake'
23
+ gem.add_development_dependency 'wwtd'
23
24
  end
data/spec/logger_spec.rb CHANGED
@@ -32,7 +32,7 @@ describe LogStashLogger do
32
32
  # The logstash event to log
33
33
  let(:logstash_event) do
34
34
  LogStash::Event.new.tap do |event|
35
- event.message = 'test'
35
+ event['message'] = 'test'
36
36
  event['severity'] = 'INFO'
37
37
  end
38
38
  end
@@ -72,31 +72,31 @@ describe LogStashLogger do
72
72
  logdev.should_receive(:write).and_call_original do |event|
73
73
  event.should be_a LogStash::Event
74
74
  event.source.should eql(hostname)
75
- event.message.should eql(message)
75
+ event['message'].should eql(message)
76
76
  event['severity'].should eql('INFO')
77
77
  end
78
78
 
79
79
  logger.info(message)
80
80
 
81
- listener_event.message.should == message
81
+ listener_event['message'].should == message
82
82
  end
83
83
 
84
84
  it 'takes a logstash-formatted json string as input and writes out a logstash event' do
85
85
  logdev.should_receive(:write).and_call_original do |event|
86
86
  event.should be_a LogStash::Event
87
- event.message.should eql(logstash_event.message)
87
+ event['message'].should eql(logstash_event['message'])
88
88
  event.source.should eql(hostname)
89
89
  end
90
90
 
91
91
  logger.info(logstash_event.to_json)
92
92
 
93
- listener_event.message.should == logstash_event.message
93
+ listener_event['message'].should == logstash_event['message']
94
94
  end
95
95
 
96
96
  it 'takes a LogStash::Event as input and writes it out intact' do
97
97
  logdev.should_receive(:write).and_call_original do |event|
98
98
  event.should be_a LogStash::Event
99
- event.message.should eql(logstash_event.message)
99
+ event['message'].should eql(logstash_event['message'])
100
100
  event['severity'].should eql(logstash_event['severity'])
101
101
  event.timestamp.should eql(logstash_event.timestamp)
102
102
  event.source.should eql(hostname)
@@ -104,26 +104,26 @@ describe LogStashLogger do
104
104
 
105
105
  logger.warn(logstash_event)
106
106
 
107
- listener_event.message.should == logstash_event.message
107
+ listener_event['message'].should == logstash_event['message']
108
108
  listener_event['severity'].should == logstash_event['severity']
109
109
  end
110
110
 
111
111
  it 'takes a data hash as input and writes out a logstash event' do
112
112
  data = {
113
- "@message" => 'test',
113
+ "message" => 'test',
114
114
  'severity' => 'INFO'
115
115
  }
116
116
 
117
117
  logdev.should_receive(:write).and_call_original do |event|
118
118
  event.should be_a LogStash::Event
119
- event.message.should eql('test')
119
+ event['message'].should eql('test')
120
120
  event['severity'].should eql('INFO')
121
121
  event.source.should eql(hostname)
122
122
  end
123
123
 
124
124
  logger.info(data.dup)
125
125
 
126
- listener_event.message.should == data["@message"]
126
+ listener_event['message'].should == data["message"]
127
127
  listener_event['severity'].should == data['severity']
128
128
  end
129
129
 
metadata CHANGED
@@ -1,23 +1,37 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.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: 2013-04-08 00:00:00.000000000 Z
11
+ date: 2013-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-event
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - '>='
18
32
  - !ruby/object:Gem::Version
19
33
  version: '0'
20
- type: :runtime
34
+ type: :development
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
@@ -25,7 +39,7 @@ dependencies:
25
39
  - !ruby/object:Gem::Version
26
40
  version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
- name: rspec
42
+ name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - '>='
@@ -39,7 +53,7 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: rake
56
+ name: wwtd
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - '>='
@@ -91,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
105
  version: '0'
92
106
  requirements: []
93
107
  rubyforge_project:
94
- rubygems_version: 2.0.0
108
+ rubygems_version: 2.0.3
95
109
  signing_key:
96
110
  specification_version: 4
97
111
  summary: LogStash Logger for ruby