console-adapter-rails 0.3.4 → 0.4.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 +4 -4
- checksums.yaml.gz.sig +2 -2
- data/lib/console/adapter/rails/logger.rb +13 -6
- data/lib/console/adapter/rails/railtie.rb +40 -0
- data/lib/console/adapter/rails/version.rb +1 -1
- data/lib/console/adapter/rails.rb +3 -16
- data/readme.md +2 -3
- data.tar.gz.sig +0 -0
- metadata +6 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5cc4bca3597337b67f0d19a87e57e5bd5e989f3e99052e6a07968db52e4e77a1
|
|
4
|
+
data.tar.gz: 2a2cd5896bf6966db23d612a05f481c41b44735ee8a36e4ea7bd1c0d6e6b7a70
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 02a6978fad7e5c8d645af5e5994b610e1b71b3c618858de3a4d621c5387cb3964102e4306f0941b6c117b710ccc1d46e2a52b45a738bbb288d663da1949426bf
|
|
7
|
+
data.tar.gz: ec8cffd46a7cd02fe812713fd87123af1ffbd880f19d79b45b8ad731def893148d2069084211ee6125ea0893971a8c83decaecc996781e8aca89be083e9aecde
|
checksums.yaml.gz.sig
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
�;������!��;��7��oIo0�k�܂��ֹ�e�џk˂�ڇ����t�ԕ��J���MCuߧi]�w똾X��fa�C�F�����$����t�����-�jX�X=!�b��(}0�ϱ,���-�W���G�L����l���������NNK�./0%���T��x��?'�F?�n3Eч�.&�o���d�^��O��]<$�m�Rx� uî������@_��Tb�)���S�Ǜ���p���-Y/$A���^qbC���b�PF�Q���;�K&b�
|
|
2
1
|
�X�Z��
|
|
3
|
-
|
|
2
|
+
�h�;���;ad� ��6�D��U�|�����ޥ�����RO %cY�蠂&��2�J�1��+d_~���DŤ��u�Y>��%�g_OICI�#�a�
|
|
3
|
+
�{ӦUw�
|
|
@@ -12,9 +12,11 @@ require 'active_support/logger_silence'
|
|
|
12
12
|
|
|
13
13
|
if ActiveSupport::Logger.respond_to?(:logger_outputs_to?)
|
|
14
14
|
# https://github.com/rails/rails/issues/44800
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
module ActiveSupport
|
|
16
|
+
class Logger
|
|
17
|
+
def self.logger_outputs_to?(*)
|
|
18
|
+
true
|
|
19
|
+
end
|
|
18
20
|
end
|
|
19
21
|
end
|
|
20
22
|
end
|
|
@@ -30,6 +32,14 @@ module Console
|
|
|
30
32
|
@silence_key = :"#{self.class}.silence.#{object_id}"
|
|
31
33
|
end
|
|
32
34
|
|
|
35
|
+
def local_level= severity
|
|
36
|
+
Fiber[@silence_key] = severity
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def local_level
|
|
40
|
+
Fiber[@silence_key]
|
|
41
|
+
end
|
|
42
|
+
|
|
33
43
|
# Silences the logger for the duration of the block.
|
|
34
44
|
def silence(severity = Logger::ERROR)
|
|
35
45
|
current = Fiber[@silence_key]
|
|
@@ -56,9 +66,6 @@ module Console
|
|
|
56
66
|
configuration.logger = ActiveSupport::TaggedLogging.new(
|
|
57
67
|
Logger.new(::Rails)
|
|
58
68
|
)
|
|
59
|
-
|
|
60
|
-
# Delete `Rails::Rack::Logger` as it also doubles up on request logs:
|
|
61
|
-
configuration.middleware.delete ::Rails::Rack::Logger
|
|
62
69
|
end
|
|
63
70
|
end
|
|
64
71
|
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Released under the MIT License.
|
|
4
|
+
# Copyright, 2023, by Samuel Williams.
|
|
5
|
+
|
|
6
|
+
require 'action_controller/log_subscriber'
|
|
7
|
+
require 'action_view/log_subscriber'
|
|
8
|
+
|
|
9
|
+
module Console
|
|
10
|
+
module Adapter
|
|
11
|
+
module Rails
|
|
12
|
+
# Hook into Rails startup process and replace Rails.logger with our custom hooks
|
|
13
|
+
class Railtie < ::Rails::Railtie
|
|
14
|
+
initializer 'console.adapter.rails', before: :initialize_logger do |app|
|
|
15
|
+
# 1. Set up Console to be used as the Rails logger
|
|
16
|
+
Logger.apply!(configuration: app.config)
|
|
17
|
+
|
|
18
|
+
# 2. Remove the Rails::Rack::Logger middleware as it also doubles up on request logs
|
|
19
|
+
app.middleware.delete ::Rails::Rack::Logger
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# 3. Remove existing log subscribers for ActionController and ActionView
|
|
23
|
+
config.after_initialize do
|
|
24
|
+
::ActionController::LogSubscriber.detach_from :action_controller
|
|
25
|
+
|
|
26
|
+
# Silence the default action view logs, e.g. "Rendering text template" etc
|
|
27
|
+
::ActionView::LogSubscriber.detach_from :action_view
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
config.after_initialize do
|
|
31
|
+
# 4. Add a new log subscriber for ActionController
|
|
32
|
+
ActionController.apply!
|
|
33
|
+
|
|
34
|
+
# 5. (optionally) Add a new log subscriber for ActiveRecord
|
|
35
|
+
# ActiveRecord.apply!
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -6,27 +6,14 @@
|
|
|
6
6
|
require_relative 'rails/logger'
|
|
7
7
|
require_relative 'rails/action_controller'
|
|
8
8
|
require_relative 'rails/active_record'
|
|
9
|
+
require_relative 'rails/railtie'
|
|
9
10
|
|
|
10
11
|
module Console
|
|
11
12
|
module Adapter
|
|
12
13
|
# A Rails adapter for the console logger.
|
|
13
14
|
module Rails
|
|
14
|
-
#
|
|
15
|
-
|
|
16
|
-
# @parameter configuration [Rails::Configuration] The configuration object to use.
|
|
17
|
-
def self.apply!(notifications: ActiveSupport::Notifications, configuration: ::Rails.configuration)
|
|
18
|
-
if configuration
|
|
19
|
-
Logger.apply!(configuration: configuration)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
if notifications
|
|
23
|
-
# Clear out all the existing subscribers otherwise you'll get double the logs:
|
|
24
|
-
notifications.notifier = ActiveSupport::Notifications::Fanout.new
|
|
25
|
-
|
|
26
|
-
# Add our own subscribers:
|
|
27
|
-
Rails::ActionController.apply!(notifications: notifications)
|
|
28
|
-
# Rails::ActiveRecord.apply!(notifications: notifications)
|
|
29
|
-
end
|
|
15
|
+
# Placeholder to remain compatible with older clients
|
|
16
|
+
def self.apply!
|
|
30
17
|
end
|
|
31
18
|
end
|
|
32
19
|
end
|
data/readme.md
CHANGED
|
@@ -7,10 +7,9 @@ Status](https://github.com/socketry/console-adapter-rails/workflows/Test/badge.s
|
|
|
7
7
|
|
|
8
8
|
## Usage
|
|
9
9
|
|
|
10
|
-
Please see the [project documentation](https://socketry.github.io/console-adapter-rails) for more details.
|
|
10
|
+
Please see the [project documentation](https://socketry.github.io/console-adapter-rails/) for more details.
|
|
11
11
|
|
|
12
|
-
- [Getting Started](https://github.
|
|
13
|
-
explains how to integrate the `console-adapter-rails` gem into your Rails application.
|
|
12
|
+
- [Getting Started](https://socketry.github.io/console-adapter-rails/guides/getting-started/index) - This guide explains how to integrate the `console-adapter-rails` gem into your Rails application.
|
|
14
13
|
|
|
15
14
|
## Contributing
|
|
16
15
|
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: console-adapter-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
@@ -37,7 +37,7 @@ cert_chain:
|
|
|
37
37
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
|
38
38
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
|
39
39
|
-----END CERTIFICATE-----
|
|
40
|
-
date:
|
|
40
|
+
date: 2024-04-04 00:00:00.000000000 Z
|
|
41
41
|
dependencies:
|
|
42
42
|
- !ruby/object:Gem::Dependency
|
|
43
43
|
name: console
|
|
@@ -91,13 +91,15 @@ files:
|
|
|
91
91
|
- lib/console/adapter/rails/action_controller.rb
|
|
92
92
|
- lib/console/adapter/rails/active_record.rb
|
|
93
93
|
- lib/console/adapter/rails/logger.rb
|
|
94
|
+
- lib/console/adapter/rails/railtie.rb
|
|
94
95
|
- lib/console/adapter/rails/version.rb
|
|
95
96
|
- license.md
|
|
96
97
|
- readme.md
|
|
97
98
|
homepage: https://github.com/socketry/console-adapter-rails
|
|
98
99
|
licenses:
|
|
99
100
|
- MIT
|
|
100
|
-
metadata:
|
|
101
|
+
metadata:
|
|
102
|
+
documentation_uri: https://socketry.github.io/console-adapter-rails/
|
|
101
103
|
post_install_message:
|
|
102
104
|
rdoc_options: []
|
|
103
105
|
require_paths:
|
|
@@ -113,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
113
115
|
- !ruby/object:Gem::Version
|
|
114
116
|
version: '0'
|
|
115
117
|
requirements: []
|
|
116
|
-
rubygems_version: 3.
|
|
118
|
+
rubygems_version: 3.5.3
|
|
117
119
|
signing_key:
|
|
118
120
|
specification_version: 4
|
|
119
121
|
summary: Adapt Rails logs and events to the console gem.
|
metadata.gz.sig
CHANGED
|
Binary file
|