Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ActiveSupport::BroadcastLogger #1089

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.bundle/
log/*.log
log/
pkg/
vendor/bundle
spec/test_app/log/*.log
Expand Down
16 changes: 9 additions & 7 deletions lib/good_job/log_subscriber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,15 @@ def loggers
# each of the loggers in {LogSubscriber.loggers}.
# @return [Logger]
def logger
@_logger ||= begin
logger = Logger.new(StringIO.new)
loggers.each do |each_logger|
logger.extend(ActiveSupport::Logger.broadcast(each_logger))
end
logger
end
@_logger ||= if defined?(ActiveSupport::BroadcastLogger)
ActiveSupport::BroadcastLogger.new(*loggers)
else
logger = Logger.new(StringIO.new)
loggers.each do |each_logger|
logger.extend(ActiveSupport::Logger.broadcast(each_logger))
end
logger
end
end

# Reset {LogSubscriber.logger} and force it to rebuild a new shortcut to
Expand Down
3 changes: 1 addition & 2 deletions sorbet/rbi/todo.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ module ::LATCH; end
module ::MemoryProfiler; end
module ::PERFORMED; end
module ::POLL_COUNT; end
module ::RECEIVED_MESSAGE; end
module ::REFRESH_IF_STALE_CALLED; end
module ::RESULTS; end
module ::RUN_JOBS; end
module ::RecursiveJob; end
Expand All @@ -29,6 +27,7 @@ module ::THREAD_JOBS; end
module ::TestError; end
module ::TestJob; end
module ::TestJob::ExpectedError; end
module ActiveSupport::BroadcastLogger; end
module GoodJob::Job::ERROR_EVENT_INTERRUPTED; end
module GoodJob::Job::ERROR_EVENT_RETRIED; end
module RSpec::Core::Example; end
Expand Down
4 changes: 2 additions & 2 deletions spec/support/database_cleaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
config.use_transactional_fixtures = false

config.before(:suite) do
ApplicationRecord.clear_active_connections!
ApplicationRecord.connection_handler.clear_active_connections!
ApplicationRecord.connection_pool.disconnect
ApplicationRecord.connection_pool.with_connection do |connection|
connection.truncate_tables(*connection.tables)
Expand All @@ -16,7 +16,7 @@
config.around do |example|
example.run

ApplicationRecord.clear_active_connections!
ApplicationRecord.connection_handler.clear_active_connections!
ApplicationRecord.connection_pool.disconnect
ApplicationRecord.connection_pool.with_connection do |connection|
connection.truncate_tables(*connection.tables)
Expand Down