Sha256: f9d8665a380b492b866974d090ab4844f572824b8beb8bebe4e4a8313bdf518b

Contents?: true

Size: 846 Bytes

Versions: 15

Compression:

Stored size: 846 Bytes

Contents

# Constructs a logger based on the {CarrotRpc.configuration} and Rails environment
module CarrotRpc::ServerRunner::Logger
  # 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
  #
  # @return [Logger]
  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

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

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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
carrot_rpc-1.2.1 lib/carrot_rpc/server_runner/logger.rb
carrot_rpc-1.2.0 lib/carrot_rpc/server_runner/logger.rb
carrot_rpc-1.1.0 lib/carrot_rpc/server_runner/logger.rb
carrot_rpc-1.0.0 lib/carrot_rpc/server_runner/logger.rb
carrot_rpc-0.8.0 lib/carrot_rpc/server_runner/logger.rb
carrot_rpc-0.7.1 lib/carrot_rpc/server_runner/logger.rb
carrot_rpc-0.7.0 lib/carrot_rpc/server_runner/logger.rb
carrot_rpc-0.6.0 lib/carrot_rpc/server_runner/logger.rb
carrot_rpc-0.5.1 lib/carrot_rpc/server_runner/logger.rb
carrot_rpc-0.5.0 lib/carrot_rpc/server_runner/logger.rb
carrot_rpc-0.4.1 lib/carrot_rpc/server_runner/logger.rb
carrot_rpc-0.4.0 lib/carrot_rpc/server_runner/logger.rb
carrot_rpc-0.3.0 lib/carrot_rpc/server_runner/logger.rb
carrot_rpc-0.2.3 lib/carrot_rpc/server_runner/logger.rb
carrot_rpc-0.2.3.pre lib/carrot_rpc/server_runner/logger.rb