civo-logger 0.1.1 → 0.1.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 +13 -9
- 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: 515c5c709b4ea752a37008aaaefd5152d45a89b5
|
4
|
+
data.tar.gz: 232305a2db4797df78812f66f3908cd28daca2a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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("
|
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("
|
174
|
-
@redis.set("
|
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("
|
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("
|
185
|
-
@redis.expire("
|
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("
|
188
|
-
@redis.expire("
|
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
|
|
data/lib/civo/logger/version.rb
CHANGED