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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d6b9a95a776580137a4982bdca4294a0abf6bf0
4
- data.tar.gz: 77216d7a025059bf1a7c715b21c5afc925e06fab
3
+ metadata.gz: 4a88c07b3787247daf0aa50cb12f5377acc37929
4
+ data.tar.gz: ba8479b59da46eeec1458c8735b17de50fab93ec
5
5
  SHA512:
6
- metadata.gz: 337eb390831966284b2e6caebfa77787cbc5da6d024a96358dc7dd4b3fcb980e5b53bf1ce32247c3eb7474db4e7d4bf0e7794e4e65747a29234bdce2712af341
7
- data.tar.gz: 54a381dfb8c7e53633b52c5eeb7f6c6fe81a47a0a9c5874c21a698614481657131b13d25ef38f0c2dd9f8d3b6e9096e5af7ef1a1b3d66c1d16088561d79711c2
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"), expires_in: 1.hour)
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], expires_in: 1.hour)
190
- @redis.set("#{app_name}:log-output:#{@key}", @output, expires_in: 1.hour)
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}", expires_in: 1.hour)
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")
@@ -1,5 +1,5 @@
1
1
  module Civo
2
2
  module Logger
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: civo-logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Jeffries