Class: Moleculer::Support::LogProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/moleculer/support/log_proxy.rb

Overview

LogProxy acts as a bridge between multiple logger types.

Instance Method Summary collapse

Constructor Details

#initialize(logger, prefix = "") ⇒ LogProxy

Returns a new instance of LogProxy.



9
10
11
12
# File 'lib/moleculer/support/log_proxy.rb', line 9

def initialize(logger, prefix = "")
  @logger = logger
  @prefix = prefix
end

Instance Method Details

#debug(*args) ⇒ Object



36
37
38
# File 'lib/moleculer/support/log_proxy.rb', line 36

def debug(*args)
  @logger.debug(parse_args(args.unshift(@prefix))) if @logger
end

#error(*args) ⇒ Object



24
25
26
# File 'lib/moleculer/support/log_proxy.rb', line 24

def error(*args)
  @logger.error(parse_args(args.unshift(@prefix))) if @logger
end

#fatal(*args) ⇒ Object



20
21
22
# File 'lib/moleculer/support/log_proxy.rb', line 20

def fatal(*args)
  @logger.fatal(parse_args(args.unshift(@prefix))) if @logger
end

#get_child(prefix) ⇒ Moleculer::LogProxy

Returns a prefixed child of the log proxy.

Returns:

  • (Moleculer::LogProxy)

    a prefixed child of the log proxy



16
17
18
# File 'lib/moleculer/support/log_proxy.rb', line 16

def get_child(prefix)
  self.class.new(@logger, prefix)
end

#info(*args) ⇒ Object



32
33
34
# File 'lib/moleculer/support/log_proxy.rb', line 32

def info(*args)
  @logger.info(parse_args(args.unshift(@prefix))) if @logger
end

#levelObject



48
49
50
# File 'lib/moleculer/support/log_proxy.rb', line 48

def level
  @logger.level
end

#trace(*args) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/moleculer/support/log_proxy.rb', line 40

def trace(*args)
  return unless @logger

  return @logger.trace(parse_args(args.unshift(@prefix))) if @logger.respond_to?(:trace)

  @logger.debug(parse_args(args.unshift(@prefix)))
end

#warn(*args) ⇒ Object



28
29
30
# File 'lib/moleculer/support/log_proxy.rb', line 28

def warn(*args)
  @logger.warn(parse_args(args.unshift(@prefix))) if @logger
end