console-adapter-rails 0.1.5 → 0.2.1
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/lib/console/adapter/rails/logger.rb +27 -0
- data/lib/console/adapter/rails/version.rb +1 -1
- data/lib/console/adapter/rails.rb +6 -8
- data/readme.md +1 -1
- data.tar.gz.sig +0 -0
- metadata +3 -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: f0964f1321e9dbcf587a9d6a6ab1a8b313eeb28110cda8b0e73fa96a7b1efcb3
|
4
|
+
data.tar.gz: e7c124ea18335c487c986ffda35af7aa6bb5958b5f03e903f3cc4e11fd74c516
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5c28d4ad22f2547b9a44d728404f90effffb4dc82928bdf5030d61105c63132a33671ead487d71c601e24ac881a49af81bb65d22524f7d6837759d42c86f912
|
7
|
+
data.tar.gz: a75abdbe06bab6b33a45d0280eb1f58421a9fab370f29ef69fcf431faf67ac325f0aaafabf883305e3ba56184c3eec850a2deccd4fcb87b3f56414032cb819ab
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2023, by Samuel Williams.
|
5
|
+
|
6
|
+
require 'console/compatible/logger'
|
7
|
+
|
8
|
+
module Console
|
9
|
+
module Adapter
|
10
|
+
# A Rails adapter for the console logger.
|
11
|
+
module Rails
|
12
|
+
class Logger < ::Console::Compatible::Logger
|
13
|
+
include ::ActiveSupport::LoggerSilence
|
14
|
+
|
15
|
+
def self.apply!(configuration: ::Rails.configuration)
|
16
|
+
# Set the logger to a compatible logger to catch `Rails.logger` output:
|
17
|
+
configuration.logger = ActiveSupport::TaggedLogging.new(
|
18
|
+
Logger.new(::Rails)
|
19
|
+
)
|
20
|
+
|
21
|
+
# Delete `Rails::Rack::Logger` as it also doubles up on request logs:
|
22
|
+
configuration.middleware.delete ::Rails::Rack::Logger
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -4,7 +4,6 @@
|
|
4
4
|
# Copyright, 2023, by Samuel Williams.
|
5
5
|
|
6
6
|
require 'console'
|
7
|
-
require 'console/compatible/logger'
|
8
7
|
|
9
8
|
require 'active_support/log_subscriber'
|
10
9
|
require 'active_support/tagged_logging'
|
@@ -12,6 +11,7 @@ require 'action_controller/log_subscriber'
|
|
12
11
|
require 'action_view/log_subscriber'
|
13
12
|
require 'active_job/log_subscriber'
|
14
13
|
|
14
|
+
require_relative 'rails/logger'
|
15
15
|
require_relative 'rails/active_support'
|
16
16
|
|
17
17
|
module Console
|
@@ -46,6 +46,10 @@ module Console
|
|
46
46
|
request = payload.delete(:request)
|
47
47
|
response = payload.delete(:response)
|
48
48
|
|
49
|
+
if request and ip = request.remote_ip
|
50
|
+
payload[:source_address] = ip
|
51
|
+
end
|
52
|
+
|
49
53
|
if response and headers = response.headers
|
50
54
|
# Extract redirect location if any:
|
51
55
|
location = response.headers['Location'] || response.headers['location']
|
@@ -71,13 +75,7 @@ module Console
|
|
71
75
|
end
|
72
76
|
|
73
77
|
if configuration
|
74
|
-
|
75
|
-
configuration.logger = ActiveSupport::TaggedLogging.new(
|
76
|
-
Console::Compatible::Logger.new(::Rails)
|
77
|
-
)
|
78
|
-
|
79
|
-
# Delete `Rails::Rack::Logger` as it also doubles up on request logs:
|
80
|
-
configuration.middleware.delete ::Rails::Rack::Logger
|
78
|
+
Logger.apply!(configuration: configuration)
|
81
79
|
end
|
82
80
|
|
83
81
|
# Attach our log subscriber for action_controller events:
|
data/readme.md
CHANGED
@@ -7,7 +7,7 @@ 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://github.
|
10
|
+
Please see the [project documentation](https://socketry.github.io/console-adapter-rails) for more details.
|
11
11
|
|
12
12
|
- [Getting Started](https://github.com/socketry/console-adapter-railsguides/getting-started/index) - This guide
|
13
13
|
explains how to integrate the `console-adapter-rails` gem into your Rails application.
|
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.1
|
4
|
+
version: 0.2.1
|
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: 2023-08-
|
40
|
+
date: 2023-08-18 00:00:00.000000000 Z
|
41
41
|
dependencies:
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: console
|
@@ -75,6 +75,7 @@ extra_rdoc_files: []
|
|
75
75
|
files:
|
76
76
|
- lib/console/adapter/rails.rb
|
77
77
|
- lib/console/adapter/rails/active_support.rb
|
78
|
+
- lib/console/adapter/rails/logger.rb
|
78
79
|
- lib/console/adapter/rails/version.rb
|
79
80
|
- license.md
|
80
81
|
- readme.md
|
metadata.gz.sig
CHANGED
Binary file
|