Class: Griffin::Logger

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

Class Method Summary collapse

Class Method Details

.create(config) ⇒ Object



20
21
22
# File 'lib/griffin/logger.rb', line 20

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

.logdev_from_config(config) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/griffin/logger.rb', line 24

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

.setup(config) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/griffin/logger.rb', line 6

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