civo-logger 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/civo/logger/middleware.rb +6 -4
- data/lib/civo/logger/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a88c07b3787247daf0aa50cb12f5377acc37929
|
4
|
+
data.tar.gz: ba8479b59da46eeec1458c8735b17de50fab93ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5249af8f606b36fe341dcd900d6ebbc133ebfdbba4d4ec17d2fa22419de99a1d6d8b69fb86552c2b47261c225689c368e8e164b943d6f9390b26bbaf0476bea
|
7
|
+
data.tar.gz: 228c0547def962ec150d59a0f0d97a3707c21bdcd76024a507331b7ef357a62df7865b607fb5c0c98d6672b3a5c979bb0e7802d03ba18d946d9b83d83fd959d5
|
@@ -7,9 +7,11 @@ require "rack/body_proxy"
|
|
7
7
|
module Civo
|
8
8
|
class PerRequestLogger < ActiveSupport::LogSubscriber
|
9
9
|
cattr_accessor :redis
|
10
|
+
cattr_accessor :expires_in
|
10
11
|
STATS_RESOLUTION = 5.minutes
|
11
12
|
|
12
13
|
def initialize(app, taggers = nil)
|
14
|
+
self.class.expires_in ||= 24.hours.to_i
|
13
15
|
@app = app
|
14
16
|
@taggers = taggers || []
|
15
17
|
Rails.logger = ActionController::Base.logger = ActiveRecord::Base.logger = self
|
@@ -109,7 +111,7 @@ module Civo
|
|
109
111
|
|
110
112
|
def end_worker
|
111
113
|
puts @lines.join("\n") if Rails.env.production?
|
112
|
-
@redis.set("#{app_name}:log:#{@key}", @lines.join("\n"),
|
114
|
+
@redis.set("#{app_name}:log:#{@key}", @lines.join("\n"), ex: self.class.expires_in)
|
113
115
|
rescue Redis::TimeoutError, Redis::CannotConnectError => e
|
114
116
|
puts "ERROR! Redis error #{e.message}"
|
115
117
|
ensure
|
@@ -186,13 +188,13 @@ module Civo
|
|
186
188
|
@output = body.to_s
|
187
189
|
end
|
188
190
|
|
189
|
-
@redis.set("#{app_name}:log:#{@key}", @log[0, 65535],
|
190
|
-
@redis.set("#{app_name}:log-output:#{@key}", @output,
|
191
|
+
@redis.set("#{app_name}:log:#{@key}", @log[0, 65535], ex: self.class.expires_in)
|
192
|
+
@redis.set("#{app_name}:log-output:#{@key}", @output, ex: self.class.expires_in)
|
191
193
|
|
192
194
|
puts "#{request.request_method}-#{request.fullpath.gsub("/", "_")}-#{@output.length}-#{@status}-#{@time_taken}" if Rails.env.production?
|
193
195
|
|
194
196
|
@redis.set("#{app_name}:log-request-summary:#{@key}",
|
195
|
-
"#{request.request_method}:#{request.fullpath.gsub("/", "_")}:#{@output.length}:#{@status}:#{@time_taken}",
|
197
|
+
"#{request.request_method}:#{request.fullpath.gsub("/", "_")}:#{@output.length}:#{@status}:#{@time_taken}", ex: self.class.expires_in)
|
196
198
|
puts @log if Rails.env.production?
|
197
199
|
|
198
200
|
stat_key = Time.zone.at(Time.zone.now.to_i / STATS_RESOLUTION * STATS_RESOLUTION).strftime("%Y%m%d-%H%I%S")
|
data/lib/civo/logger/version.rb
CHANGED