Class: RailsGrpc::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_grpc/logger.rb

Class Method Summary collapse

Class Method Details

.logger(original_logger) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rails_grpc/logger.rb', line 8

def logger(original_logger)
  return @logger if @logger.present?

  if Rails.env.development? || Rails.env.test?
    std_logger = ActiveSupport::Logger.new(STDOUT)
    std_logger.formatter = ActiveSupport::Logger::Formatter.new
    multiple_loggers = ActiveSupport::Logger.broadcast(std_logger)
    original_logger.extend(multiple_loggers)
  end

  @logger = original_logger
  @logger
end