console-adapter-rails 0.5.1 → 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/logger.rb +20 -1
- data/lib/console/adapter/rails/railtie.rb +19 -15
- data/lib/console/adapter/rails/version.rb +2 -2
- data/lib/console/adapter/rails.rb +1 -1
- data/license.md +2 -1
- data/readme.md +23 -3
- data/releases.md +4 -0
- data.tar.gz.sig +0 -0
- metadata +8 -5
- 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|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
# Released under the MIT License.
|
|
4
4
|
# Copyright, 2023-2025, by Samuel Williams.
|
|
5
5
|
# Copyright, 2024, by Michael Adams.
|
|
6
|
+
# Copyright, 2026, by Yasha Krasnou.
|
|
6
7
|
|
|
7
8
|
require "console/compatible/logger"
|
|
8
9
|
|
|
@@ -83,7 +84,25 @@ module Console
|
|
|
83
84
|
def add(severity, message = nil, progname = nil, &block)
|
|
84
85
|
return if silenced?(severity)
|
|
85
86
|
|
|
86
|
-
|
|
87
|
+
if formatter.respond_to?(:tag_stack)
|
|
88
|
+
tags = formatter.tag_stack.tags
|
|
89
|
+
|
|
90
|
+
options = tags.each_with_object({}) do |tag, memo|
|
|
91
|
+
next unless tag.respond_to?(:to_hash)
|
|
92
|
+
|
|
93
|
+
tag.to_hash.each do |key, value|
|
|
94
|
+
case key
|
|
95
|
+
when Symbol
|
|
96
|
+
memo[key] = value
|
|
97
|
+
else
|
|
98
|
+
next unless key.respond_to?(:to_sym)
|
|
99
|
+
memo[key.to_sym] = value
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
super(severity, message, progname, **options, &block)
|
|
87
106
|
end
|
|
88
107
|
|
|
89
108
|
# Configure Rails to use the Console logger.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Released under the MIT License.
|
|
4
4
|
# Copyright, 2024, by Michael Adams.
|
|
5
|
-
# Copyright, 2024, by Samuel Williams.
|
|
5
|
+
# Copyright, 2024-2026, by Samuel Williams.
|
|
6
6
|
# Copyright, 2025, by Jun Jiang.
|
|
7
7
|
|
|
8
8
|
require "action_controller/log_subscriber"
|
|
@@ -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/license.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# MIT License
|
|
2
2
|
|
|
3
|
-
Copyright, 2023-
|
|
3
|
+
Copyright, 2023-2026, by Samuel Williams.
|
|
4
4
|
Copyright, 2023, by Joshua Young.
|
|
5
5
|
Copyright, 2024, by Michael Adams.
|
|
6
6
|
Copyright, 2025, by Jun Jiang.
|
|
7
|
+
Copyright, 2026, by Yasha Krasnou.
|
|
7
8
|
|
|
8
9
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
10
|
of this software and associated documentation files (the "Software"), to deal
|
data/readme.md
CHANGED
|
@@ -14,6 +14,10 @@ Please see the [project documentation](https://socketry.github.io/console-adapte
|
|
|
14
14
|
|
|
15
15
|
Please see the [project releases](https://socketry.github.io/console-adapter-rails/releases/index) for all releases.
|
|
16
16
|
|
|
17
|
+
### v0.6.0
|
|
18
|
+
|
|
19
|
+
- Add support for Rails tagged logging in the Rails logger adapter. This allows log messages with tags to be properly formatted and displayed.
|
|
20
|
+
|
|
17
21
|
### v0.5.0
|
|
18
22
|
|
|
19
23
|
- Improved compatibilty with Rails 8+.
|
|
@@ -22,11 +26,27 @@ Please see the [project releases](https://socketry.github.io/console-adapter-rai
|
|
|
22
26
|
|
|
23
27
|
We welcome contributions to this project.
|
|
24
28
|
|
|
25
|
-
1. Fork
|
|
29
|
+
1. Fork the repository.
|
|
26
30
|
2. Create your feature branch (`git checkout -b my-new-feature`).
|
|
27
|
-
3. Commit your changes (`git commit -am 'Add some feature'`).
|
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature.'`).
|
|
28
32
|
4. Push to the branch (`git push origin my-new-feature`).
|
|
29
|
-
5. Create new
|
|
33
|
+
5. Create a new pull request.
|
|
34
|
+
|
|
35
|
+
### Running Tests
|
|
36
|
+
|
|
37
|
+
To run the test suite:
|
|
38
|
+
|
|
39
|
+
``` bash
|
|
40
|
+
$ bundle exec sus
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Making Releases
|
|
44
|
+
|
|
45
|
+
To make a new release:
|
|
46
|
+
|
|
47
|
+
``` bash
|
|
48
|
+
$ bundle exec bake gem:release:patch # or minor or major
|
|
49
|
+
```
|
|
30
50
|
|
|
31
51
|
### Developer Certificate of Origin
|
|
32
52
|
|
data/releases.md
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
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
|
|
8
8
|
- Joshua Young
|
|
9
9
|
- Jun Jiang
|
|
10
10
|
- Michael Adams
|
|
11
|
+
- Yasha Krasnou
|
|
11
12
|
bindir: bin
|
|
12
13
|
cert_chain:
|
|
13
14
|
- |
|
|
@@ -47,14 +48,14 @@ dependencies:
|
|
|
47
48
|
requirements:
|
|
48
49
|
- - "~>"
|
|
49
50
|
- !ruby/object:Gem::Version
|
|
50
|
-
version: '1.
|
|
51
|
+
version: '1.34'
|
|
51
52
|
type: :runtime
|
|
52
53
|
prerelease: false
|
|
53
54
|
version_requirements: !ruby/object:Gem::Requirement
|
|
54
55
|
requirements:
|
|
55
56
|
- - "~>"
|
|
56
57
|
- !ruby/object:Gem::Version
|
|
57
|
-
version: '1.
|
|
58
|
+
version: '1.34'
|
|
58
59
|
- !ruby/object:Gem::Dependency
|
|
59
60
|
name: fiber-storage
|
|
60
61
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -102,6 +103,8 @@ homepage: https://github.com/socketry/console-adapter-rails
|
|
|
102
103
|
licenses:
|
|
103
104
|
- MIT
|
|
104
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
|
|
105
108
|
documentation_uri: https://socketry.github.io/console-adapter-rails/
|
|
106
109
|
source_code_uri: https://github.com/socketry/console-adapter-rails.git
|
|
107
110
|
rdoc_options: []
|
|
@@ -111,14 +114,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
111
114
|
requirements:
|
|
112
115
|
- - ">="
|
|
113
116
|
- !ruby/object:Gem::Version
|
|
114
|
-
version: '3.
|
|
117
|
+
version: '3.3'
|
|
115
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
119
|
requirements:
|
|
117
120
|
- - ">="
|
|
118
121
|
- !ruby/object:Gem::Version
|
|
119
122
|
version: '0'
|
|
120
123
|
requirements: []
|
|
121
|
-
rubygems_version:
|
|
124
|
+
rubygems_version: 4.0.10
|
|
122
125
|
specification_version: 4
|
|
123
126
|
summary: Adapt Rails logs and events to the console gem.
|
|
124
127
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|