Class: RuntimeLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/javonet-ruby-sdk/utils/runtime_logger.rb,
lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/utils/runtime_logger.rb,
lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/utils/runtime_logger.rb,
lib/javonet-ruby-sdk/Binaries/Ruby/Windows/X64/utils/runtime_logger.rb

Class Method Summary collapse

Class Method Details

.get_runtime_info(get_loaded_modules) ⇒ Object



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

def self.get_runtime_info(get_loaded_modules)
  begin
    runtime_info = "Ruby Managed Runtime Info:\n".force_encoding('UTF-8') +
      "Ruby Version: #{RUBY_VERSION}\n".force_encoding('UTF-8') +
      "Ruby Implementation: #{RUBY_ENGINE}\n".force_encoding('UTF-8') +
      "Ruby Platform: #{RUBY_PLATFORM}\n".force_encoding('UTF-8') +
      "Ruby Engine: #{RUBY_ENGINE}\n".force_encoding('UTF-8') +
      "Ruby Engine Version: #{RUBY_ENGINE_VERSION}\n".force_encoding('UTF-8') +
      "Current Directory: #{Dir.pwd}\n".force_encoding('UTF-8') +
      "Ruby search path: " + $LOAD_PATH.join(", ").force_encoding('UTF-8') + "\n"
    if get_loaded_modules
      runtime_info += "Ruby loaded modules (excluding Javonet classes): " + $LOADED_FEATURES.reject { |feature| feature.include?("Binaries/Ruby") }.join(", ").force_encoding('UTF-8') + "\n"
    end
      return runtime_info
  rescue => e
    "Ruby Managed Runtime Info: Error while fetching runtime info".force_encoding('UTF-8')
  end
end


24
25
26
27
28
29
# File 'lib/javonet-ruby-sdk/utils/runtime_logger.rb', line 24

def self.print_runtime_info(get_loaded_modules = true)
  if @not_logged_yet
    puts get_runtime_info(get_loaded_modules)
    @not_logged_yet = false
  end
end