Class: Vx::Lib::Instrumentation::Logger

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

Defined Under Namespace

Classes: Formatter

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(device) ⇒ Logger

Returns a new instance of Logger.



9
10
11
# File 'lib/vx/lib/instrumentation/logger.rb', line 9

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



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/vx/lib/instrumentation/logger.rb', line 13

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.message.inspect} [#{sym.inspect} #{args.inspect}]"
      $stderr.puts e.backtrace.map{|b| "\t#{b}" }.join("\n")
    end
  else
    super
  end
end

Class Attribute Details

.loggerObject

Returns the value of attribute logger.



31
32
33
# File 'lib/vx/lib/instrumentation/logger.rb', line 31

def logger
  @logger
end

Class Method Details

.setup(target) ⇒ Object



33
34
35
36
37
# File 'lib/vx/lib/instrumentation/logger.rb', line 33

def setup(target)
  log = ::Logger.new(target, 7, 50_000_000)
  log.formatter = Lib::Instrumentation::Logger::Formatter
  @logger = new(log)
end

Instance Method Details

#respond_to?(sym) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/vx/lib/instrumentation/logger.rb', line 26

def respond_to?(sym)
  @device.respond_to?(sym)
end