Class: Instana::XLogger

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

Constant Summary collapse

LEVELS =
[:agent, :agent_comm, :trace].freeze
STAMP =
"Instana: ".freeze

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ XLogger

Returns a new instance of XLogger.



8
9
10
11
12
13
# File 'lib/instana/logger.rb', line 8

def initialize(*args)
  if ENV['INSTANA_GEM_DEV']
    self.debug_level=:agent
  end
  super(*args)
end

Instance Method Details

#agent(msg) ⇒ Object



33
34
35
36
# File 'lib/instana/logger.rb', line 33

def agent(msg)
  return unless @level_agent
  self.debug(msg)
end

#agent_comm(msg) ⇒ Object



38
39
40
41
# File 'lib/instana/logger.rb', line 38

def agent_comm(msg)
  return unless @level_agent_comm
  self.debug(msg)
end

#debug(msg) ⇒ Object



60
61
62
# File 'lib/instana/logger.rb', line 60

def debug(msg)
  super(STAMP + msg)
end

#debug_level=(levels) ⇒ Object

Sets the debug level for this logger. The debug level is broken up into various sub-levels as defined in LEVELS.

To use: ::Instana.logger.debug_level = [:agent_comm, :trace]



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/instana/logger.rb', line 21

def debug_level=(levels)
  LEVELS.each do |l|
    instance_variable_set("@level_#{l}", false)
  end

  levels = [ levels ] unless levels.is_a?(Array)
  levels.each do |l|
    next unless LEVELS.include?(l)
    instance_variable_set("@level_#{l}", true)
  end
end

#error(msg) ⇒ Object



48
49
50
# File 'lib/instana/logger.rb', line 48

def error(msg)
  super(STAMP + msg)
end

#info(msg) ⇒ Object



56
57
58
# File 'lib/instana/logger.rb', line 56

def info(msg)
  super(STAMP + msg)
end

#trace(msg) ⇒ Object



43
44
45
46
# File 'lib/instana/logger.rb', line 43

def trace(msg)
  return unless @level_trace
  self.debug(msg)
end

#unkown(msg) ⇒ Object



64
65
66
# File 'lib/instana/logger.rb', line 64

def unkown(msg)
  super(STAMP + msg)
end

#warn(msg) ⇒ Object



52
53
54
# File 'lib/instana/logger.rb', line 52

def warn(msg)
  super(STAMP + msg)
end