Module: Dumpcar::Util

Defined in:
lib/dumpcar/util/broadcast_logger.rb,
lib/dumpcar/util.rb

Overview

this is a backport of the Active Support BroadcastLogger from Rails 8. It's needed because we support versions prior to rails 7.1 when it was added

Defined Under Namespace

Classes: BroadcastLogger

Class Method Summary collapse

Class Method Details

.get_connection_db_configObject



2
3
4
# File 'lib/dumpcar/util.rb', line 2

def self.get_connection_db_config
  (Rails.version < "6.1") ? ActiveRecord::Base.connection_config : ActiveRecord::Base.connection_db_config.configuration_hash
end

.loggerObject



16
17
18
# File 'lib/dumpcar/util.rb', line 16

def self.logger
  logger_class.new(Rails.logger, Logger.new($stdout))
end

.logger_classObject



6
7
8
9
10
11
12
13
14
# File 'lib/dumpcar/util.rb', line 6

def self.logger_class
  if Rails.version < "7.1"
    # We only load this if we need it
    require "dumpcar/util/broadcast_logger"
    Dumpcar::Util::BroadcastLogger
  else
    ActiveSupport::BroadcastLogger
  end
end