console-adapter-rails 0.6.0 → 0.7.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 +0 -0
- data/context/index.yaml +2 -0
- data/lib/console/adapter/rails/action_controller.rb +18 -2
- data/lib/console/adapter/rails/active_record.rb +1 -0
- data/lib/console/adapter/rails/railtie.rb +18 -14
- data/lib/console/adapter/rails/version.rb +2 -2
- data/readme.md +7 -7
- data.tar.gz.sig +0 -0
- metadata +4 -2
- 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: 22f3bdcce8df798abb9d013c9c5ecbe9e41694a37ac0f3cc0d4cf70763ec98e8
|
|
4
|
+
data.tar.gz: ae9bc8c19ff6f3fe5e31e3447d0ba5d9faa7d6691280d9b22b77e41b0099fd1d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b540ef6e3c7c2387efd9c4dec9f7cca4bd12b6e936e81881d345a7f1c053981b75aa9afd21504dda0c142d1b08d9e475bcbb0b34dca44faf968ce290640bc925
|
|
7
|
+
data.tar.gz: 875cbe82136ef8b6ad18b3fecb9f1777228272b67a22d3607e273055889e6f18130298db0318426004c7e491849fd11796fe103ed175a2675863fd29500d6f41
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/context/index.yaml
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
---
|
|
4
4
|
description: Adapt Rails logs and events to the console gem.
|
|
5
5
|
metadata:
|
|
6
|
+
bug_tracker_uri: https://github.com/socketry/console-adapter-rails/issues
|
|
7
|
+
changelog_uri: https://github.com/socketry/console-adapter-rails/blob/main/releases.md
|
|
6
8
|
documentation_uri: https://socketry.github.io/console-adapter-rails/
|
|
7
9
|
source_code_uri: https://github.com/socketry/console-adapter-rails.git
|
|
8
10
|
files:
|
|
@@ -13,6 +13,22 @@ module Console
|
|
|
13
13
|
module Rails
|
|
14
14
|
# ActionController integration for Console logger. Provides log subscribers that convert Rails ActionController events into Console-compatible log messages.
|
|
15
15
|
module ActionController
|
|
16
|
+
@log_parameters = false
|
|
17
|
+
|
|
18
|
+
# Whether filtered request parameters should be included in action controller logs.
|
|
19
|
+
#
|
|
20
|
+
# @returns [Boolean] Whether filtered request parameters are logged.
|
|
21
|
+
def self.log_parameters?
|
|
22
|
+
@log_parameters
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Configure whether filtered request parameters should be included in action controller logs.
|
|
26
|
+
#
|
|
27
|
+
# @parameter value [Boolean] Whether filtered request parameters should be logged.
|
|
28
|
+
def self.log_parameters=(value)
|
|
29
|
+
@log_parameters = value
|
|
30
|
+
end
|
|
31
|
+
|
|
16
32
|
# Represents a Rails log subscriber which is compatible with `Console::Logger`. It receives events from `ActiveSupport::Notifications` and logs them to the console.
|
|
17
33
|
class LogSubscriber < ::ActiveSupport::LogSubscriber
|
|
18
34
|
# Log an ActionController `process_action` event.
|
|
@@ -33,8 +49,8 @@ module Console
|
|
|
33
49
|
def process_action(event)
|
|
34
50
|
payload = event.payload.dup
|
|
35
51
|
|
|
36
|
-
# This may contain sensitive information:
|
|
37
|
-
|
|
52
|
+
# This may contain sensitive information, but Rails applies configured parameter filters before emitting the event:
|
|
53
|
+
payload.delete(:params) unless ActionController.log_parameters?
|
|
38
54
|
|
|
39
55
|
# These objects are not useful and may not serialize correctly:
|
|
40
56
|
headers = payload.delete(:headers)
|
|
@@ -47,6 +47,7 @@ module Console
|
|
|
47
47
|
def update_binds(payload)
|
|
48
48
|
binds = payload.delete(:binds)
|
|
49
49
|
type_casted_binds = payload.delete(:type_casted_binds)
|
|
50
|
+
type_casted_binds = type_casted_binds.call if type_casted_binds.respond_to?(:call)
|
|
50
51
|
|
|
51
52
|
if binds&.any? and type_casted_binds
|
|
52
53
|
payload[:binds] = binds.map.with_index do |attribute, index|
|
|
@@ -13,28 +13,32 @@ module Console
|
|
|
13
13
|
module Rails
|
|
14
14
|
# Hook into Rails startup process and replace Rails.logger with our custom hooks
|
|
15
15
|
class Railtie < ::Rails::Railtie
|
|
16
|
+
# Detach a Rails log subscriber using the API appropriate for its implementation.
|
|
17
|
+
#
|
|
18
|
+
# @parameter subscriber [Class] The log subscriber class to detach.
|
|
19
|
+
# @parameter namespace [Symbol] The notification namespace the subscriber is attached to.
|
|
20
|
+
def self.detach_log_subscriber(subscriber, namespace)
|
|
21
|
+
if subscriber < ::ActiveSupport::LogSubscriber
|
|
22
|
+
subscriber.detach_from(namespace)
|
|
23
|
+
else
|
|
24
|
+
::ActiveSupport.event_reporter.unsubscribe(subscriber)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# 1. Remove the Rails::Rack::Logger middleware as it also doubles up on request logs
|
|
29
|
+
config.app_middleware.delete ::Rails::Rack::Logger
|
|
30
|
+
|
|
16
31
|
initializer "console.adapter.rails", before: :initialize_logger do |app|
|
|
17
|
-
#
|
|
32
|
+
# 2. Set up Console to be used as the Rails logger
|
|
18
33
|
Logger.apply!(configuration: app.config)
|
|
19
|
-
|
|
20
|
-
# 2. Remove the Rails::Rack::Logger middleware as it also doubles up on request logs
|
|
21
|
-
app.middleware.delete ::Rails::Rack::Logger
|
|
22
34
|
end
|
|
23
35
|
|
|
24
36
|
# 3. Remove existing log subscribers for ActionController and ActionView
|
|
25
37
|
config.after_initialize do
|
|
26
|
-
|
|
27
|
-
::ActionController::LogSubscriber.detach_from :action_controller
|
|
28
|
-
else
|
|
29
|
-
::ActiveSupport.event_reporter.unsubscribe(::ActionController::LogSubscriber)
|
|
30
|
-
end
|
|
38
|
+
detach_log_subscriber(::ActionController::LogSubscriber, :action_controller)
|
|
31
39
|
|
|
32
40
|
# Silence the default action view logs, e.g. "Rendering text template" etc
|
|
33
|
-
|
|
34
|
-
::ActionView::LogSubscriber.detach_from :action_view
|
|
35
|
-
else
|
|
36
|
-
::ActiveSupport.event_reporter.unsubscribe(::ActionView::LogSubscriber)
|
|
37
|
-
end
|
|
41
|
+
detach_log_subscriber(::ActionView::LogSubscriber, :action_view)
|
|
38
42
|
end
|
|
39
43
|
|
|
40
44
|
config.after_initialize do
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Released under the MIT License.
|
|
4
|
-
# Copyright, 2023-
|
|
4
|
+
# Copyright, 2023-2026, by Samuel Williams.
|
|
5
5
|
|
|
6
6
|
# @namespace
|
|
7
7
|
module Console
|
|
@@ -9,7 +9,7 @@ module Console
|
|
|
9
9
|
module Adapter
|
|
10
10
|
# @namespace
|
|
11
11
|
module Rails
|
|
12
|
-
VERSION = "0.
|
|
12
|
+
VERSION = "0.7.0"
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
end
|
data/readme.md
CHANGED
|
@@ -26,26 +26,26 @@ Please see the [project releases](https://socketry.github.io/console-adapter-rai
|
|
|
26
26
|
|
|
27
27
|
We welcome contributions to this project.
|
|
28
28
|
|
|
29
|
-
1. Fork
|
|
29
|
+
1. Fork the repository.
|
|
30
30
|
2. Create your feature branch (`git checkout -b my-new-feature`).
|
|
31
|
-
3. Commit your changes (`git commit -am 'Add some feature'`).
|
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature.'`).
|
|
32
32
|
4. Push to the branch (`git push origin my-new-feature`).
|
|
33
|
-
5. Create new
|
|
33
|
+
5. Create a new pull request.
|
|
34
34
|
|
|
35
35
|
### Running Tests
|
|
36
36
|
|
|
37
37
|
To run the test suite:
|
|
38
38
|
|
|
39
|
-
```
|
|
40
|
-
bundle exec sus
|
|
39
|
+
``` bash
|
|
40
|
+
$ bundle exec sus
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
### Making Releases
|
|
44
44
|
|
|
45
45
|
To make a new release:
|
|
46
46
|
|
|
47
|
-
```
|
|
48
|
-
bundle exec bake gem:release:patch # or minor or major
|
|
47
|
+
``` bash
|
|
48
|
+
$ bundle exec bake gem:release:patch # or minor or major
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
### Developer Certificate of Origin
|
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.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
@@ -103,6 +103,8 @@ homepage: https://github.com/socketry/console-adapter-rails
|
|
|
103
103
|
licenses:
|
|
104
104
|
- MIT
|
|
105
105
|
metadata:
|
|
106
|
+
bug_tracker_uri: https://github.com/socketry/console-adapter-rails/issues
|
|
107
|
+
changelog_uri: https://github.com/socketry/console-adapter-rails/blob/main/releases.md
|
|
106
108
|
documentation_uri: https://socketry.github.io/console-adapter-rails/
|
|
107
109
|
source_code_uri: https://github.com/socketry/console-adapter-rails.git
|
|
108
110
|
rdoc_options: []
|
|
@@ -119,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
119
121
|
- !ruby/object:Gem::Version
|
|
120
122
|
version: '0'
|
|
121
123
|
requirements: []
|
|
122
|
-
rubygems_version: 4.0.
|
|
124
|
+
rubygems_version: 4.0.10
|
|
123
125
|
specification_version: 4
|
|
124
126
|
summary: Adapt Rails logs and events to the console gem.
|
|
125
127
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|