Class: RuntimeLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/hypertube-ruby-sdk/utils/runtime_logger.rb

Class Method Summary collapse

Class Method Details

.get_runtime_info(get_loaded_modules) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/hypertube-ruby-sdk/utils/runtime_logger.rb', line 6

def self.get_runtime_info(get_loaded_modules)
  pieces = []
  pieces << to_utf8("Ruby Managed Runtime Info:\n")
  pieces << to_utf8("Ruby Version: #{RUBY_VERSION}\n")
  pieces << to_utf8("Ruby Implementation: #{RUBY_ENGINE}\n")
  pieces << to_utf8("Ruby Platform: #{RUBY_PLATFORM}\n")
  pieces << to_utf8("Ruby Engine: #{RUBY_ENGINE}\n")
  pieces << to_utf8("Ruby Engine Version: #{RUBY_ENGINE_VERSION}\n")
  pieces << to_utf8("Current Directory: #{Dir.pwd}\n")
  paths = $LOAD_PATH.map { |p| to_utf8(p.to_s) }.join(', ')
  pieces << to_utf8('Ruby search path: ') + paths + to_utf8("\n")

  if get_loaded_modules
    loaded = $LOADED_FEATURES.map(&:to_s).reject { |feature| feature.include?('Binaries/Ruby') }.join(', ')
    pieces << to_utf8('Ruby loaded modules (excluding RuntimeBridge classes): ' + loaded + "\n")
  end

  pieces.join
rescue StandardError => e
  to_utf8('Ruby Managed Runtime Info: Error while fetching runtime info')
end


28
29
30
31
32
33
# File 'lib/hypertube-ruby-sdk/utils/runtime_logger.rb', line 28

def self.print_runtime_info(get_loaded_modules = true)
  return unless @not_logged_yet

  puts get_runtime_info(get_loaded_modules)
  @not_logged_yet = false
end