Class: Vx::Instrumentation::Logger
- Inherits:
-
Object
- Object
- Vx::Instrumentation::Logger
- Defined in:
- lib/vx/instrumentation/logger.rb
Defined Under Namespace
Classes: Formatter
Class Attribute Summary collapse
-
.logger ⇒ Object
Returns the value of attribute logger.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(device) ⇒ Logger
constructor
A new instance of Logger.
- #method_missing(sym, *args, &block) ⇒ Object
- #respond_to?(sym) ⇒ Boolean
Constructor Details
#initialize(device) ⇒ Logger
Returns a new instance of Logger.
11 12 13 |
# File 'lib/vx/instrumentation/logger.rb', line 11 def initialize(device) @device = device end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/vx/instrumentation/logger.rb', line 15 def method_missing(sym, *args, &block) if @device.respond_to?(sym) begin @device.send(sym, *args, &block) rescue Exception => e $stderr.puts "#{e.class.to_s}, #{e..inspect} [#{sym.inspect} #{args.inspect}]" $stderr.puts e.backtrace.map{|b| "\t#{b}" }.join("\n") end else super end end |
Class Attribute Details
.logger ⇒ Object
Returns the value of attribute logger.
33 34 35 |
# File 'lib/vx/instrumentation/logger.rb', line 33 def logger @logger end |
Class Method Details
.setup(target) ⇒ Object
35 36 37 38 39 |
# File 'lib/vx/instrumentation/logger.rb', line 35 def setup(target) log = ::Logger.new(target) log.formatter = Formatter @logger = new(log) end |
Instance Method Details
#respond_to?(sym) ⇒ Boolean
28 29 30 |
# File 'lib/vx/instrumentation/logger.rb', line 28 def respond_to?(sym) @device.respond_to?(sym) end |