Class: Instana::XLogger
- Inherits:
-
Logger
- Object
- Logger
- Instana::XLogger
- Defined in:
- lib/instana/logger.rb
Constant Summary collapse
- LEVELS =
[:agent, :agent_comm, :trace, :agent_response, :tracing].freeze
- STAMP =
"Instana: ".freeze
Instance Method Summary collapse
- #agent(msg) ⇒ Object
- #agent_comm(msg) ⇒ Object
- #agent_response(msg) ⇒ Object
- #debug(msg) ⇒ Object
-
#debug_level=(levels) ⇒ Object
Sets the debug level for this logger.
- #error(msg) ⇒ Object
- #info(msg) ⇒ Object
-
#initialize(*args) ⇒ XLogger
constructor
A new instance of XLogger.
- #trace(msg) ⇒ Object
- #tracing(msg) ⇒ Object
- #unkown(msg) ⇒ Object
- #warn(msg) ⇒ Object
Constructor Details
#initialize(*args) ⇒ XLogger
Returns a new instance of XLogger.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/instana/logger.rb', line 8 def initialize(*args) super(*args) if ENV.key?('INSTANA_GEM_TEST') self.level = Logger::DEBUG elsif ENV.key?('INSTANA_GEM_DEV') self.level = Logger::DEBUG self.debug_level = nil else self.level = Logger::WARN end end |
Instance Method Details
#agent(msg) ⇒ Object
46 47 48 49 |
# File 'lib/instana/logger.rb', line 46 def agent(msg) return unless @level_agent self.debug(msg) end |
#agent_comm(msg) ⇒ Object
51 52 53 54 |
# File 'lib/instana/logger.rb', line 51 def agent_comm(msg) return unless @level_agent_comm self.debug(msg) end |
#agent_response(msg) ⇒ Object
56 57 58 59 |
# File 'lib/instana/logger.rb', line 56 def agent_response(msg) return unless @level_agent_response self.debug(msg) end |
#debug(msg) ⇒ Object
83 84 85 |
# File 'lib/instana/logger.rb', line 83 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:
:agent - All agent related messages such as state & announcements :agent_comm - Output all payload comm sent between this Ruby gem and the host agent :agent_response - Outputs messages related to handling requests received by the host agent :trace - Output all traces reported to the host agent :tracing - Output messages related to tracing components, spans and management
To use: ::Instana.logger.debug_level = [:agent_comm, :trace]
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/instana/logger.rb', line 32 def debug_level=(levels) return unless 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
71 72 73 |
# File 'lib/instana/logger.rb', line 71 def error(msg) super(STAMP + msg) end |
#info(msg) ⇒ Object
79 80 81 |
# File 'lib/instana/logger.rb', line 79 def info(msg) super(STAMP + msg) end |
#trace(msg) ⇒ Object
61 62 63 64 |
# File 'lib/instana/logger.rb', line 61 def trace(msg) return unless @level_trace self.debug(msg) end |
#tracing(msg) ⇒ Object
66 67 68 69 |
# File 'lib/instana/logger.rb', line 66 def tracing(msg) return unless @level_tracing self.debug(msg) end |
#unkown(msg) ⇒ Object
87 88 89 |
# File 'lib/instana/logger.rb', line 87 def unkown(msg) super(STAMP + msg) end |
#warn(msg) ⇒ Object
75 76 77 |
# File 'lib/instana/logger.rb', line 75 def warn(msg) super(STAMP + msg) end |