Module: CarrotRpc::ServerRunner::Logger

Defined in:
lib/carrot_rpc/server_runner/logger.rb

Overview

Constructs a logger based on the CarrotRpc.configuration and Rails environment

Class Method Summary collapse

Class Method Details

.configuredLogger

A ‘Logger` configured based on `CarrotRpc.configuration.logfile` and `CarrotRpc.configuration.loglevel`

Fallbacks:

  • ‘Rails.logger` if `Rails` is loaded

  • ‘Logger` to `STDOUT` if `Rails` is not loaded

Returns:



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/carrot_rpc/server_runner/logger.rb', line 10

def self.configured
  logger = from_file

  if logger.nil?
    logger = if defined?(::Rails)
               CarrotRpc::TaggedLog.new(logger: Rails.logger, tags: ["Carrot RPC"])
             else
               Logger.new(STDOUT)
             end
  end

  logger.level = CarrotRpc.configuration.loglevel

  logger
end

.from_fileObject



26
27
28
29
30
# File 'lib/carrot_rpc/server_runner/logger.rb', line 26

def self.from_file
  return nil unless CarrotRpc.configuration.logfile

  ::Logger.new(CarrotRpc.configuration.logfile)
end