rails_spotlight 0.4.0 → 0.4.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3080195b8e2481d0af07b1c8a7c0e5d59dc7b90d95afc82e722514676003d01
|
4
|
+
data.tar.gz: 472e0580e0e7fceb406bc6810be98ea2945232f673deaaecd28737d3c9bf54ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f72425d6484fe1574d05d5f44189265bab421e834fdde23c9e2c96df0911f0b673750395d86e2b45563cac53dc3f0fc2d82794262c7d24ab3787161890259225
|
7
|
+
data.tar.gz: 98cf2fb54e51e960022a2819aabe04f21bfa66d2f7dd34057fb2fb2d5c4a23481c635d3f40deabc1f387d700b6a1dfb152b1ed5be0135c7ec0139e947db9cb78
|
@@ -23,11 +23,42 @@ module RailsSpotlight
|
|
23
23
|
end
|
24
24
|
return true if _skip_logging?(message)
|
25
25
|
|
26
|
-
|
26
|
+
_rails_spotlight_log(SEVERITY_MAP[severity], message, progname, :broadcast)
|
27
27
|
super(severity, message, progname) if defined?(super)
|
28
28
|
true
|
29
29
|
end
|
30
30
|
|
31
|
+
|
32
|
+
def debug(message = nil, *args, &block)
|
33
|
+
_rails_spotlight_log(:debug, message, nil, :event, &block)
|
34
|
+
super
|
35
|
+
end
|
36
|
+
|
37
|
+
def info(message = nil, *args, &block)
|
38
|
+
_rails_spotlight_log(:info, message, nil, :event, &block)
|
39
|
+
super
|
40
|
+
end
|
41
|
+
|
42
|
+
def warn(message = nil, *args, &block)
|
43
|
+
_rails_spotlight_log(:warn, message, nil, :event, &block)
|
44
|
+
super
|
45
|
+
end
|
46
|
+
|
47
|
+
def error(message = nil, *args, &block)
|
48
|
+
_rails_spotlight_log(:error, message, nil, :event, &block)
|
49
|
+
super
|
50
|
+
end
|
51
|
+
|
52
|
+
def fatal(message = nil, *args, &block)
|
53
|
+
_rails_spotlight_log(:fatal, message, nil, :event, &block)
|
54
|
+
super
|
55
|
+
end
|
56
|
+
|
57
|
+
def unknown(message = nil, *args, &block)
|
58
|
+
_rails_spotlight_log(:unknown, message, nil, :event, &block)
|
59
|
+
super
|
60
|
+
end
|
61
|
+
|
31
62
|
private
|
32
63
|
|
33
64
|
def _skip_logging?(message)
|
@@ -37,11 +68,23 @@ module RailsSpotlight
|
|
37
68
|
message.include?(::RailsSpotlight::Channels::SPOTLIGHT_CHANNEL)
|
38
69
|
end
|
39
70
|
|
40
|
-
def
|
71
|
+
def _rails_spotlight_log(level, message, progname = nil, output = :event)
|
41
72
|
callsite = Utils.dev_callsite(caller.drop(1))
|
42
73
|
name = progname.is_a?(String) || progname.is_a?(Symbol) ? progname : nil
|
43
|
-
|
74
|
+
message = yield if output == :event && message.nil? && block_given?
|
75
|
+
output == :event ? _push_event(level, message, name, callsite) : _broadcast_log(message, level, callsite, name)
|
76
|
+
rescue StandardError => e
|
77
|
+
RailsSpotlight.config.logger.fatal("#{e.message}\n #{e.backtrace.join("\n ")}")
|
78
|
+
end
|
79
|
+
|
80
|
+
def _push_event(level, message, progname = nil, callsite = {})
|
81
|
+
name = progname.is_a?(String) || progname.is_a?(Symbol) ? progname : nil
|
82
|
+
AppRequest.current.events << Event.new('rsl.notification.log', 0, 0, 0, (callsite || {}).merge(message: message, level: level, progname: name)) if AppRequest.current
|
83
|
+
rescue StandardError => e
|
84
|
+
RailsSpotlight.config.logger.fatal("#{e.message}\n #{e.backtrace.join("\n ")}")
|
85
|
+
end
|
44
86
|
|
87
|
+
def _broadcast_log(message, level, callsite = {}, name = nil)
|
45
88
|
return unless ::RailsSpotlight.config.use_action_cable?
|
46
89
|
return if message.blank?
|
47
90
|
|
@@ -14,22 +14,31 @@ module RailsSpotlight
|
|
14
14
|
|
15
15
|
private
|
16
16
|
|
17
|
-
def
|
17
|
+
def transactional(&block)
|
18
|
+
return block.call if force_execution?
|
19
|
+
|
18
20
|
ActiveRecord::Base.transaction do
|
19
|
-
begin
|
20
|
-
|
21
|
-
run
|
22
|
-
end
|
23
|
-
rescue => e # rubocop:disable Style/RescueStandardError
|
24
|
-
self.error = e
|
21
|
+
begin
|
22
|
+
block.call
|
25
23
|
ensure
|
26
|
-
raise ActiveRecord::Rollback
|
24
|
+
raise ActiveRecord::Rollback
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def transaction
|
30
|
+
begin # rubocop:disable Style/RedundantBegin
|
31
|
+
ActiveSupport::Notifications.subscribed(method(:logger), 'sql.active_record', monotonic: true) do
|
32
|
+
run
|
27
33
|
end
|
34
|
+
rescue => e # rubocop:disable Style/RescueStandardError
|
35
|
+
self.error = e
|
28
36
|
end
|
29
37
|
end
|
30
38
|
|
31
39
|
def run # rubocop:disable Metrics/AbcSize
|
32
40
|
RailsSpotlight.config.logger && RailsSpotlight.config.logger.info("Executing query: #{query}") # rubocop:disable Style/SafeNavigation
|
41
|
+
|
33
42
|
return self.result = ActiveRecord::Base.connection.exec_query(query) if connection_options.blank? || !ActiveRecord::Base.respond_to?(:connects_to)
|
34
43
|
|
35
44
|
connections = ActiveRecord::Base.connects_to(**connection_options)
|
@@ -48,7 +57,7 @@ module RailsSpotlight
|
|
48
57
|
result: result,
|
49
58
|
logs: logs,
|
50
59
|
error: error.present? ? error.inspect : nil,
|
51
|
-
|
60
|
+
query_mode: force_execution? ? 'force' : 'default'
|
52
61
|
}
|
53
62
|
end
|
54
63
|
|
@@ -80,9 +89,9 @@ module RailsSpotlight
|
|
80
89
|
|
81
90
|
def connection_options
|
82
91
|
@connection_options ||= raw_options
|
83
|
-
|
84
|
-
|
85
|
-
|
92
|
+
.symbolize_keys
|
93
|
+
.slice(:database, :shards)
|
94
|
+
.reject { |_, v| v.nil? || (!v.is_a?(TrueClass) && !v.is_a?(FalseClass) && v.empty?) } # TODO: Check for each rails version
|
86
95
|
end
|
87
96
|
|
88
97
|
def force_execution?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_spotlight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pawel Niemczyk
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack-contrib
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
version: 3.0.0
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
42
|
+
version: '8.1'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
version: 3.0.0
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
52
|
+
version: '8.1'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: action-cable-testing
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|