logstasher 0.6.5 → 0.7.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: 11247b1380b660b07d61c1ba3cb09a03e9c73c19
4
- data.tar.gz: ad2c0ec6e3ba892c970646bc01f8afeecaa61a89
3
+ metadata.gz: 1310d59f79f4794fe052862abab980070abbb608
4
+ data.tar.gz: 8c3ba40e9e3cb8adf4cffe4ce1253bdda0687dc4
5
5
  SHA512:
6
- metadata.gz: f06b0803dffdb63f6e971ce000b16346488243a092ff32ee2dbbbcc636cca1cc4bdc66f766507365c109da407fe73f92b622e17ca04668f805dff2ee254e7be6
7
- data.tar.gz: c1ef1086dd6b3ddb32fa1c1e9b480bfbedc4d6d4e9508eb34a2820e32d18de24de498554c90416e6da5ba4007debc6ddf997d33129d1fb5621238a8843437cbd
6
+ metadata.gz: 8ac20d33342fb3576d7bdbdb097d251b764ec79e1ae30d38892cf4697aa3873ed3b785dbe96fb9d069857a21a51856de380daf758a9c408015ff8c4a06c31b4b
7
+ data.tar.gz: a64a27166802d4538d120a8d53386c10e3fed3d64e8916da027adce0b11b91ca415a85817879df73065546b8e98466209f8c09e31b628d72f430100d3c37f632
data/lib/logstasher.rb CHANGED
@@ -116,11 +116,20 @@ module LogStasher
116
116
 
117
117
  def log(severity, msg)
118
118
  if self.logger && self.logger.send("#{severity}?")
119
- event = LogStash::Event.new('@source' => self.source, '@fields' => {:message => msg, :level => severity}, '@tags' => ['log'])
120
- self.logger << event.to_json + "\n"
119
+ data = {'level' => severity}
120
+ if msg.respond_to?(:to_hash)
121
+ data.merge!(msg.to_hash)
122
+ else
123
+ data['message'] = msg
124
+ end
125
+ self.logger << build_logstash_event(data, ['log']).to_json + "\n"
121
126
  end
122
127
  end
123
128
 
129
+ def build_logstash_event(data, tags)
130
+ LogStash::Event.new(data.merge('source' => self.source, 'tags' => tags))
131
+ end
132
+
124
133
  def store
125
134
  if RequestStore.store[STORE_KEY].nil?
126
135
  # Get each store it's own private Hash instance.
@@ -156,7 +165,9 @@ module LogStasher
156
165
  private
157
166
 
158
167
  def new_logger(path)
159
- FileUtils.touch path # prevent autocreate messages in log
168
+ if path.is_a? String
169
+ FileUtils.touch path # prevent autocreate messages in log
170
+ end
160
171
  Logger.new path
161
172
  end
162
173
  end
@@ -15,8 +15,8 @@ module LogStasher
15
15
 
16
16
  tags = ['request']
17
17
  tags.push('exception') if payload[:exception]
18
- event = LogStash::Event.new(data.merge('source' => LogStasher.source, 'tags' => tags))
19
- LogStasher.logger << event.to_json + "\n"
18
+
19
+ LogStasher.logger << LogStasher.build_logstash_event(data, tags).to_json + "\n"
20
20
  end
21
21
 
22
22
  def redirect_to(event)
@@ -122,8 +122,7 @@ module LogStasher
122
122
 
123
123
  def process_event(event, tags)
124
124
  data = LogStasher.request_context.merge(extract_metadata(event.payload))
125
- event = LogStash::Event.new(data.merge('source' => LogStasher.source, 'tags' => tags))
126
- logger << event.to_json + "\n"
125
+ logger << LogStasher.build_logstash_event(data, tags).to_json + "\n"
127
126
  end
128
127
 
129
128
  def extract_metadata(payload)
@@ -1,3 +1,3 @@
1
1
  module LogStasher
2
- VERSION = "0.6.5"
2
+ VERSION = "0.7.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstasher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shadab Ahmed
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-15 00:00:00.000000000 Z
11
+ date: 2015-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-event
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rspec
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -114,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
128
  version: '0'
115
129
  requirements: []
116
130
  rubyforge_project:
117
- rubygems_version: 2.2.2
131
+ rubygems_version: 2.4.8
118
132
  signing_key:
119
133
  specification_version: 4
120
134
  summary: Awesome rails logs