civo-logger 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7279fc671bb4f72639b0a55999da868224ef580c
4
- data.tar.gz: b7e3d445f7317efb9f75671033650dc47100c13b
3
+ metadata.gz: 515c5c709b4ea752a37008aaaefd5152d45a89b5
4
+ data.tar.gz: 232305a2db4797df78812f66f3908cd28daca2a6
5
5
  SHA512:
6
- metadata.gz: 89c05c183c50bfe7a11bf326a1e2b559ae07554b737f155f0d8d0d322982ea941a8740222bf88f8058a430877f578b0623273ab82d49083463318bc74dac89f4
7
- data.tar.gz: 40a042984a983fe945f1fbedc71bfb18ae41eb8009a9a1aadbd6527ea7caf95b978895507aa7cef424b0b9153eab5a38a49785472b9591373026f405d0d0823f
6
+ metadata.gz: ad7dcfa1ae4253b63e1d1cad63fd600ed668ed98fffe95da615d0e1aa202863090cf4120a182860009407574776ed97300bae0d2dfac0fe97e447d1b32b6d04a
7
+ data.tar.gz: c91e4ff306f301741790299d5fd42070bf3f9ef9c3aff8119ddaa0669a6c8b63410c77710b0bd08c8c62a384fc8d4512ee47344d4d64ceb5b6e8713c849299d4
@@ -14,7 +14,7 @@ module Civo
14
14
  Rails.logger = ActionController::Base.logger = ActiveRecord::Base.logger = self
15
15
  $stdout.sync = true
16
16
  if ENV["RAILS_LOGGER_HOSTNAME"].present?
17
- @redis = Redis.new(host: ENV["RAILS_LOGGER_HOSTNAME"], port: Rails.application.config.x.redis_port, password: ENV["RAILS_LOGGER_PASSWORD"])
17
+ @redis = Redis.new(host: ENV["RAILS_LOGGER_HOSTNAME"], port: Rails.application.config.x.redis_port, password: ENV["RAILS_LOGGER_PASSWORD"], timeout: 1)
18
18
  else
19
19
  @redis = Redis.current
20
20
  end
@@ -26,6 +26,10 @@ module Civo
26
26
  call_app(request, env)
27
27
  end
28
28
 
29
+ def app_name
30
+ ENV["APP_NAME"] || "unknown-app"
31
+ end
32
+
29
33
  def debug(message = "")
30
34
  message = yield if block_given?
31
35
  return if message.blank?
@@ -99,7 +103,7 @@ module Civo
99
103
  end
100
104
 
101
105
  def end_worker
102
- @redis.set("civo-api:log:#{@key}", @lines.join("\n"), expires_in: 1.hour)
106
+ @redis.set("#{app_name}:log:#{@key}", @lines.join("\n"), expires_in: 1.hour)
103
107
  puts @lines.join("\n") if Rails.env.production?
104
108
  @recording = false
105
109
  end
@@ -170,22 +174,22 @@ module Civo
170
174
  end
171
175
 
172
176
  if send_request?(request)
173
- @redis.set("civo-api:log:#{@key}", @log[0, 65535], expires_in: 1.hour)
174
- @redis.set("civo-api:log-output:#{@key}", @output, expires_in: 1.hour)
177
+ @redis.set("#{app_name}:log:#{@key}", @log[0, 65535], expires_in: 1.hour)
178
+ @redis.set("#{app_name}:log-output:#{@key}", @output, expires_in: 1.hour)
175
179
 
176
180
  puts "#{request.request_method}-#{request.fullpath.gsub("/", "_")}-#{@output.length}-#{@status}-#{@time_taken}" if Rails.env.production?
177
181
 
178
- @redis.set("civo-api:log-request-summary:#{@key}",
182
+ @redis.set("#{app_name}:log-request-summary:#{@key}",
179
183
  "#{request.request_method}:#{request.fullpath.gsub("/", "_")}:#{@output.length}:#{@status}:#{@time_taken}", expires_in: 1.hour)
180
184
  puts @log if Rails.env.production?
181
185
 
182
186
  stat_key = Time.zone.at(Time.zone.now.to_i / STATS_RESOLUTION * STATS_RESOLUTION).strftime("%Y%m%d-%H%I%S")
183
187
  if @status.to_i > 399
184
- @redis.incr("civo-api:req-stat-failure:#{stat_key}")
185
- @redis.expire("civo-api:req-stat-failure:#{stat_key}", 7.days)
188
+ @redis.incr("#{app_name}:req-stat-failure:#{stat_key}")
189
+ @redis.expire("#{app_name}:req-stat-failure:#{stat_key}", 7.days)
186
190
  else
187
- @redis.incr("civo-api:req-stat-success:#{stat_key}")
188
- @redis.expire("civo-api:req-stat-success:#{stat_key}", 7.days)
191
+ @redis.incr("#{app_name}:req-stat-success:#{stat_key}")
192
+ @redis.expire("#{app_name}:req-stat-success:#{stat_key}", 7.days)
189
193
  end
190
194
  end
191
195
 
@@ -1,5 +1,5 @@
1
1
  module Civo
2
2
  module Logger
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.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.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Jeffries