logstasher 1.3.0 → 1.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
  SHA256:
3
- metadata.gz: 6404e64176a9e91e7fe16a4ad2b8a12792dfe3b570f2920ea74cfb3e201c7322
4
- data.tar.gz: 1a269a04d2b4adfdb5f01348af44a9b6103cabba7e602df6add73ea538a7ced5
3
+ metadata.gz: cc18d114cfc41499a37e388cc18a1cf2608ba935e629d6dd7c4bf6f9382bdbf1
4
+ data.tar.gz: 38646241250be07048968e31e807a5683b7342916d018220eb961465ca014307
5
5
  SHA512:
6
- metadata.gz: 6b0f34ad6389fa7f9aace7b655a5c81ba04ea4868e46d40f51438ac74eb89fb8f151b5aff3193bc4643cbd29fb7a43399bfaa79d0f7a0fb86715f1ea91774f6a
7
- data.tar.gz: a4dd6b70ea93ff535bb562789bf8ed7b083c3dd1cea40ccbd1b160349443b6bc24797797b04b89d441aae7220ddb068b91e2521a472c005d3e9269fbb45f6ce5
6
+ metadata.gz: 26124c87a8d13d71b0551d79d599eda734c656ad38576895adb59b36d1a093dc350a2a26287f373ecc3dd7782eee1ce4d78ef59a833ca791ce019c940d50e9da
7
+ data.tar.gz: 02acf571115949f295ff1dd654549bfa8d296df0f6c39ea4ab4631e8b5e5416080381386c3e44891fa1a75d4ebe4e0ad47db367247d6044938a78d0ed221b110
@@ -6,6 +6,7 @@ require 'logstasher/action_view/log_subscriber' if defined?(ActionView)
6
6
  require 'logstasher/active_job/log_subscriber' if defined?(ActiveJob)
7
7
  require 'logstasher/rails_ext/action_controller/base'
8
8
  require 'logstasher/custom_fields'
9
+ require 'logstasher/event'
9
10
  require 'request_store'
10
11
  require 'active_support/core_ext/module/attribute_accessors'
11
12
  require 'active_support/core_ext/string/inflections'
@@ -181,7 +182,7 @@ module LogStasher
181
182
  field_renaming.each do |old_name, new_name|
182
183
  data[new_name] = data.delete(old_name) if data.key?(old_name)
183
184
  end
184
- ::LogStash::Event.new(data.merge('source' => self.source, 'tags' => tags))
185
+ Event.new(data.merge('source' => self.source, 'tags' => tags))
185
186
  end
186
187
 
187
188
  def store
@@ -0,0 +1,35 @@
1
+ require "json"
2
+ require "time"
3
+ require "date"
4
+
5
+ module LogStasher
6
+ class Event
7
+
8
+ def initialize(data={})
9
+ @cancelled = false
10
+
11
+ @data = data
12
+ if data.include?("@timestamp")
13
+ t = data["@timestamp"]
14
+ if t.is_a?(String)
15
+ data["@timestamp"] = Time.parse(t).gmtime
16
+ end
17
+ else
18
+ data["@timestamp"] = ::Time.now.utc
19
+ end
20
+ data["@version"] = "1" if !@data.include?("@version")
21
+ end
22
+
23
+ def to_s
24
+ to_json.to_s
25
+ end
26
+
27
+ def to_json(*args)
28
+ return @data.to_json(*args)
29
+ end
30
+
31
+ def [](key)
32
+ @data[key]
33
+ end
34
+ end
35
+ end
@@ -30,7 +30,8 @@ module LogStasher
30
30
  LogStasher.process_config(app.config.logstasher, LOGSTASHER[env].symbolize_keys) if LOGSTASHER.key? env
31
31
  end
32
32
 
33
- app.config.action_dispatch.rack_cache[:verbose] = false if app.config.action_dispatch.rack_cache
33
+ app.config.action_dispatch.rack_cache[:verbose] = false if rack_cache_hashlike?(app)
34
+
34
35
  LogStasher.setup_before(app.config.logstasher) if app.config.logstasher.enabled
35
36
  end
36
37
 
@@ -39,6 +40,10 @@ module LogStasher
39
40
  LogStasher.setup(config.logstasher) if config.logstasher.enabled
40
41
  end
41
42
  end
43
+
44
+ def rack_cache_hashlike?(app)
45
+ app.config.action_dispatch.rack_cache && app.config.action_dispatch.rack_cache.respond_to?(:[]=)
46
+ end
42
47
  end
43
48
 
44
49
  def default_source
@@ -1,3 +1,3 @@
1
1
  module LogStasher
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.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: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shadab Ahmed
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-25 00:00:00.000000000 Z
11
+ date: 2020-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-event
@@ -123,6 +123,7 @@ files:
123
123
  - lib/logstasher/active_support/mailer_log_subscriber.rb
124
124
  - lib/logstasher/custom_fields.rb
125
125
  - lib/logstasher/device/redis.rb
126
+ - lib/logstasher/event.rb
126
127
  - lib/logstasher/rails_ext/action_controller/base.rb
127
128
  - lib/logstasher/rails_ext/action_controller/metal/instrumentation.rb
128
129
  - lib/logstasher/rails_ext/rack/logger.rb
@@ -132,7 +133,7 @@ homepage: https://github.com/shadabahmed/logstasher
132
133
  licenses:
133
134
  - MIT
134
135
  metadata: {}
135
- post_install_message:
136
+ post_install_message:
136
137
  rdoc_options: []
137
138
  require_paths:
138
139
  - lib
@@ -147,9 +148,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
148
  - !ruby/object:Gem::Version
148
149
  version: '0'
149
150
  requirements: []
150
- rubyforge_project:
151
- rubygems_version: 2.7.6
152
- signing_key:
151
+ rubygems_version: 3.0.3
152
+ signing_key:
153
153
  specification_version: 4
154
154
  summary: Awesome rails logs
155
155
  test_files: []