doctor 0.4.0 → 0.5.0

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: aa53bbc4b3dc84ef40c049489b041061b4f4fff4
4
- data.tar.gz: 00a901ad5b44d8aa0ef4354a1060816047bfb3a0
3
+ metadata.gz: 18197643e4b8cd0d0ff9ccafb49e6b2040a6bf59
4
+ data.tar.gz: 0a9e698f2b4a8e49713479bd3dcf56e1a8af5cdf
5
5
  SHA512:
6
- metadata.gz: 4b3a3154fe6994b82b303732faac28a6b1a64d4a84f216ab702b14576006f922afe5603d3cb0d53cf82ae9181f130cccb69d20e22ebc71645e617152030d8cb2
7
- data.tar.gz: 288a8c58b2499e78e138f14bfa0896fb54b7875675b81f5a7c89a7b011a3630d078d862df2a9146aaeb7a836d5e2b987d0f13d570b93c242b4a14ac8c43d0890
6
+ metadata.gz: daefc650c78da2bcd1f5af3f350edbfe538ae3526fce3af8802fc0388d9d60d436c4bc36d0145c4b59d8848a603381b2f2726eebc8cfba26b651b098f51ff7b9
7
+ data.tar.gz: 22794a5e9d90673893481ea5d5da282b40ac64a89824e1b70a8bdb5dd250f577214682ce776cacb1daac5e23ea4cf199646d8006aeafae4700bce067a2429ffe
@@ -1,5 +1,59 @@
1
+ require 'rails/all'
2
+
1
3
  module Doctor
2
4
  class Engine < ::Rails::Engine
3
5
  isolate_namespace Doctor
6
+
7
+ # config that will allow the user to turn of the log feature
8
+ config.use_same_log_file = false
9
+
10
+ initializer('doctor', after: 'sprockets.environment') do |app|
11
+ next if app.config.use_same_log_file
12
+
13
+ Rails::Rack::Logger.class_eval do
14
+ def call_with_doctor(env)
15
+ logs = nil
16
+ begin
17
+ logs = backup_current_logs
18
+
19
+ define_doctor_log_if_needed(env)
20
+
21
+ call_without_doctor(env)
22
+ ensure
23
+ return_logs(logs) unless logs.nil?
24
+ end
25
+ end
26
+
27
+ alias_method_chain :call, :doctor
28
+
29
+ private
30
+
31
+ def return_logs(logs)
32
+ Rails.logger = logs.rails unless logs.rails.nil?
33
+
34
+ ActiveRecord::Base.logger = logs.active_record unless logs.active_record.nil?
35
+
36
+ ActionController::Base.logger = logs.action_controller unless logs.action_controller.nil?
37
+ end
38
+
39
+ def backup_current_logs
40
+ OpenStruct.new(
41
+ rails: Rails.logger,
42
+ active_record: ActiveRecord::Base.logger,
43
+ action_controller: ActionController::Base.logger
44
+ )
45
+ end
46
+
47
+ def define_doctor_log_if_needed(env)
48
+ return unless env['PATH_INFO'].include?('doctor/health_check')
49
+
50
+ doctor_log = Logger.new("#{Rails.root}/log/doctor.log")
51
+
52
+ Rails.logger = doctor_log
53
+ ActiveRecord::Base.logger = doctor_log
54
+ ActionController::Base.logger = doctor_log
55
+ end
56
+ end
57
+ end
4
58
  end
5
59
  end
@@ -1,3 +1,3 @@
1
1
  module Doctor
2
- VERSION = "0.4.0"
2
+ VERSION = '0.5.0'
3
3
  end
metadata CHANGED
@@ -1,15 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doctor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - uaiHebert
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-02 00:00:00.000000000 Z
11
+ date: 2016-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.1'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '3.1'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
13
33
  - !ruby/object:Gem::Dependency
14
34
  name: sys-filesystem
15
35
  requirement: !ruby/object:Gem::Requirement