console-adapter-rails 0.3.4 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/console/adapter/rails/action_controller.rb +2 -1
- data/lib/console/adapter/rails/active_record.rb +3 -2
- data/lib/console/adapter/rails/logger.rb +15 -7
- data/lib/console/adapter/rails/railtie.rb +41 -0
- data/lib/console/adapter/rails/version.rb +2 -2
- data/lib/console/adapter/rails.rb +3 -26
- data/license.md +3 -1
- data/readme.md +6 -10
- data.tar.gz.sig +0 -0
- metadata +20 -15
- 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: a4e48e85afc72be9449b0da7dcc6ea25c3333daaafe092062429ea8944fcca98
|
4
|
+
data.tar.gz: 3c325105475e32b6099d9eb35c7fe6ec2ec6990ef920c2b07cb03e4c4d211206
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0265cf56ce46b5fac25cc1c3efccc071951b84d57e46d8e572ea5f16a8a70cacc2ea2645d9696acf4ccf5bfcaa1233d7dbd360da9b6738d483c534ca85eb785
|
7
|
+
data.tar.gz: 3f7377560820af3bd579778be6d85f15a0a83846eff9c1eca3e25a0957df0996010d8fcdfbb31f7a6f156d585cb42223c1bb1094d1b1e2c0ef8ad5591f6cd3fa
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -1,10 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2023, by Samuel Williams.
|
4
|
+
# Copyright, 2023-2024, by Samuel Williams.
|
5
5
|
|
6
6
|
require 'console'
|
7
7
|
|
8
|
+
require 'active_support/log_subscriber'
|
8
9
|
require 'action_controller/log_subscriber'
|
9
10
|
|
10
11
|
module Console
|
@@ -1,10 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2023, by Samuel Williams.
|
4
|
+
# Copyright, 2023-2024, by Samuel Williams.
|
5
5
|
|
6
6
|
require 'console'
|
7
7
|
|
8
|
+
require 'active_support/log_subscriber'
|
8
9
|
require 'active_record/log_subscriber'
|
9
10
|
|
10
11
|
module Console
|
@@ -67,4 +68,4 @@ module Console
|
|
67
68
|
end
|
68
69
|
end
|
69
70
|
end
|
70
|
-
end
|
71
|
+
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2023, by Samuel Williams.
|
4
|
+
# Copyright, 2023-2024, by Samuel Williams.
|
5
|
+
# Copyright, 2024, by Michael Adams.
|
5
6
|
|
6
7
|
require 'console/compatible/logger'
|
7
8
|
|
@@ -12,9 +13,11 @@ require 'active_support/logger_silence'
|
|
12
13
|
|
13
14
|
if ActiveSupport::Logger.respond_to?(:logger_outputs_to?)
|
14
15
|
# https://github.com/rails/rails/issues/44800
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
module ActiveSupport
|
17
|
+
class Logger
|
18
|
+
def self.logger_outputs_to?(*)
|
19
|
+
true
|
20
|
+
end
|
18
21
|
end
|
19
22
|
end
|
20
23
|
end
|
@@ -30,6 +33,14 @@ module Console
|
|
30
33
|
@silence_key = :"#{self.class}.silence.#{object_id}"
|
31
34
|
end
|
32
35
|
|
36
|
+
def local_level= severity
|
37
|
+
Fiber[@silence_key] = severity
|
38
|
+
end
|
39
|
+
|
40
|
+
def local_level
|
41
|
+
Fiber[@silence_key]
|
42
|
+
end
|
43
|
+
|
33
44
|
# Silences the logger for the duration of the block.
|
34
45
|
def silence(severity = Logger::ERROR)
|
35
46
|
current = Fiber[@silence_key]
|
@@ -56,9 +67,6 @@ module Console
|
|
56
67
|
configuration.logger = ActiveSupport::TaggedLogging.new(
|
57
68
|
Logger.new(::Rails)
|
58
69
|
)
|
59
|
-
|
60
|
-
# Delete `Rails::Rack::Logger` as it also doubles up on request logs:
|
61
|
-
configuration.middleware.delete ::Rails::Rack::Logger
|
62
70
|
end
|
63
71
|
end
|
64
72
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2024, by Michael Adams.
|
5
|
+
# Copyright, 2024, by Samuel Williams.
|
6
|
+
|
7
|
+
require 'action_controller/log_subscriber'
|
8
|
+
require 'action_view/log_subscriber'
|
9
|
+
|
10
|
+
module Console
|
11
|
+
module Adapter
|
12
|
+
module Rails
|
13
|
+
# Hook into Rails startup process and replace Rails.logger with our custom hooks
|
14
|
+
class Railtie < ::Rails::Railtie
|
15
|
+
initializer 'console.adapter.rails', before: :initialize_logger do |app|
|
16
|
+
# 1. Set up Console to be used as the Rails logger
|
17
|
+
Logger.apply!(configuration: app.config)
|
18
|
+
|
19
|
+
# 2. Remove the Rails::Rack::Logger middleware as it also doubles up on request logs
|
20
|
+
app.middleware.delete ::Rails::Rack::Logger
|
21
|
+
end
|
22
|
+
|
23
|
+
# 3. Remove existing log subscribers for ActionController and ActionView
|
24
|
+
config.after_initialize do
|
25
|
+
::ActionController::LogSubscriber.detach_from :action_controller
|
26
|
+
|
27
|
+
# Silence the default action view logs, e.g. "Rendering text template" etc
|
28
|
+
::ActionView::LogSubscriber.detach_from :action_view
|
29
|
+
end
|
30
|
+
|
31
|
+
config.after_initialize do
|
32
|
+
# 4. Add a new log subscriber for ActionController
|
33
|
+
ActionController.apply!
|
34
|
+
|
35
|
+
# 5. (optionally) Add a new log subscriber for ActiveRecord
|
36
|
+
# ActiveRecord.apply!
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2023, by Samuel Williams.
|
4
|
+
# Copyright, 2023-2024, by Samuel Williams.
|
5
5
|
|
6
6
|
module Console
|
7
7
|
module Adapter
|
8
8
|
module Rails
|
9
|
-
VERSION = "0.
|
9
|
+
VERSION = "0.4.1"
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -1,33 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2023, by Samuel Williams.
|
4
|
+
# Copyright, 2023-2024, by Samuel Williams.
|
5
|
+
# Copyright, 2024, by Michael Adams.
|
5
6
|
|
6
7
|
require_relative 'rails/logger'
|
7
8
|
require_relative 'rails/action_controller'
|
8
9
|
require_relative 'rails/active_record'
|
9
|
-
|
10
|
-
module Console
|
11
|
-
module Adapter
|
12
|
-
# A Rails adapter for the console logger.
|
13
|
-
module Rails
|
14
|
-
# Apply the Rails adapter to the current process and Rails application.
|
15
|
-
# @parameter notifications [ActiveSupport::Notifications] The notifications object to use.
|
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
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
10
|
+
require_relative "rails/railtie" if defined?(Rails::Railtie)
|
data/license.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# MIT License
|
2
2
|
|
3
|
-
Copyright, 2023, by Samuel Williams.
|
3
|
+
Copyright, 2023-2024, by Samuel Williams.
|
4
|
+
Copyright, 2023, by Joshua Young.
|
5
|
+
Copyright, 2024, by Michael Adams.
|
4
6
|
|
5
7
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
8
|
of this software and associated documentation files (the "Software"), to deal
|
data/readme.md
CHANGED
@@ -2,15 +2,13 @@
|
|
2
2
|
|
3
3
|
Adapt Rails event logs for `console`.
|
4
4
|
|
5
|
-
[![Development
|
6
|
-
Status](https://github.com/socketry/console-adapter-rails/workflows/Test/badge.svg)](https://github.com/socketry/console-adapter-rails/actions?workflow=Test)
|
5
|
+
[![Development Status](https://github.com/socketry/console-adapter-rails/workflows/Test/badge.svg)](https://github.com/socketry/console-adapter-rails/actions?workflow=Test)
|
7
6
|
|
8
7
|
## Usage
|
9
8
|
|
10
|
-
Please see the [project documentation](https://socketry.github.io/console-adapter-rails) for more details.
|
9
|
+
Please see the [project documentation](https://socketry.github.io/console-adapter-rails/) for more details.
|
11
10
|
|
12
|
-
- [Getting Started](https://github.
|
13
|
-
explains how to integrate the `console-adapter-rails` gem into your Rails application.
|
11
|
+
- [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
12
|
|
15
13
|
## Contributing
|
16
14
|
|
@@ -24,10 +22,8 @@ We welcome contributions to this project.
|
|
24
22
|
|
25
23
|
### Developer Certificate of Origin
|
26
24
|
|
27
|
-
|
28
|
-
project must agree to this document to have their contributions accepted.
|
25
|
+
In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
|
29
26
|
|
30
|
-
###
|
27
|
+
### Community Guidelines
|
31
28
|
|
32
|
-
This project is
|
33
|
-
participants agree to abide by its terms.
|
29
|
+
This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,10 +1,12 @@
|
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
|
+
- Joshua Young
|
9
|
+
- Michael Adams
|
8
10
|
autorequire:
|
9
11
|
bindir: bin
|
10
12
|
cert_chain:
|
@@ -37,7 +39,7 @@ cert_chain:
|
|
37
39
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
38
40
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
39
41
|
-----END CERTIFICATE-----
|
40
|
-
date:
|
42
|
+
date: 2024-08-09 00:00:00.000000000 Z
|
41
43
|
dependencies:
|
42
44
|
- !ruby/object:Gem::Dependency
|
43
45
|
name: console
|
@@ -54,33 +56,33 @@ dependencies:
|
|
54
56
|
- !ruby/object:Gem::Version
|
55
57
|
version: '1.21'
|
56
58
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
59
|
+
name: fiber-storage
|
58
60
|
requirement: !ruby/object:Gem::Requirement
|
59
61
|
requirements:
|
60
|
-
- - "
|
62
|
+
- - "~>"
|
61
63
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
64
|
+
version: '1.0'
|
63
65
|
type: :runtime
|
64
66
|
prerelease: false
|
65
67
|
version_requirements: !ruby/object:Gem::Requirement
|
66
68
|
requirements:
|
67
|
-
- - "
|
69
|
+
- - "~>"
|
68
70
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
71
|
+
version: '1.0'
|
70
72
|
- !ruby/object:Gem::Dependency
|
71
|
-
name:
|
73
|
+
name: rails
|
72
74
|
requirement: !ruby/object:Gem::Requirement
|
73
75
|
requirements:
|
74
|
-
- - "
|
76
|
+
- - ">="
|
75
77
|
- !ruby/object:Gem::Version
|
76
|
-
version: '
|
78
|
+
version: '6.1'
|
77
79
|
type: :runtime
|
78
80
|
prerelease: false
|
79
81
|
version_requirements: !ruby/object:Gem::Requirement
|
80
82
|
requirements:
|
81
|
-
- - "
|
83
|
+
- - ">="
|
82
84
|
- !ruby/object:Gem::Version
|
83
|
-
version: '
|
85
|
+
version: '6.1'
|
84
86
|
description:
|
85
87
|
email:
|
86
88
|
executables: []
|
@@ -91,13 +93,16 @@ files:
|
|
91
93
|
- lib/console/adapter/rails/action_controller.rb
|
92
94
|
- lib/console/adapter/rails/active_record.rb
|
93
95
|
- lib/console/adapter/rails/logger.rb
|
96
|
+
- lib/console/adapter/rails/railtie.rb
|
94
97
|
- lib/console/adapter/rails/version.rb
|
95
98
|
- license.md
|
96
99
|
- readme.md
|
97
100
|
homepage: https://github.com/socketry/console-adapter-rails
|
98
101
|
licenses:
|
99
102
|
- MIT
|
100
|
-
metadata:
|
103
|
+
metadata:
|
104
|
+
documentation_uri: https://socketry.github.io/console-adapter-rails/
|
105
|
+
source_code_uri: https://github.com/socketry/console-adapter-rails.git
|
101
106
|
post_install_message:
|
102
107
|
rdoc_options: []
|
103
108
|
require_paths:
|
@@ -106,14 +111,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
111
|
requirements:
|
107
112
|
- - ">="
|
108
113
|
- !ruby/object:Gem::Version
|
109
|
-
version: '3.
|
114
|
+
version: '3.1'
|
110
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
116
|
requirements:
|
112
117
|
- - ">="
|
113
118
|
- !ruby/object:Gem::Version
|
114
119
|
version: '0'
|
115
120
|
requirements: []
|
116
|
-
rubygems_version: 3.
|
121
|
+
rubygems_version: 3.5.11
|
117
122
|
signing_key:
|
118
123
|
specification_version: 4
|
119
124
|
summary: Adapt Rails logs and events to the console gem.
|
metadata.gz.sig
CHANGED
Binary file
|