Sha256: 240ca342c9f193420f244492feab9c908c41e456514e37fcfd2cf621afdb6c35

Contents?: true

Size: 876 Bytes

Versions: 4

Compression:

Stored size: 876 Bytes

Contents

# frozen_string_literal: true

module Griffin
  class Logger
    class << self
      def setup(config)
        config[:logger] = Griffin::Logger.create(config)
        Griffin.logger = config[:logger]

        m = Module.new do
          def logger
            Griffin.logger
          end
        end
        # Not to set a logger to `Grpckit.logger` since `Grpckit.logger` prints many HTTP2 layer logs
        # If you want to print them, add environment variable `GRPC_KIT_LOGLEVEL=debug`
        GrpcKit::GRPC.extend(m)
      end

      def create(config)
        config[:logger] || ServerEngine::DaemonLogger.new(logdev_from_config(config), config)
      end

      def logdev_from_config(config)
        case c = config[:log]
        when nil  # default
          STDERR
        when '-'
          STDOUT
        else
          c
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
griffin-0.1.7 lib/griffin/logger.rb
griffin-0.1.6 lib/griffin/logger.rb
griffin-0.1.5 lib/griffin/logger.rb
griffin-0.1.4 lib/griffin/logger.rb