Method: OpenC3.write_exception_file
- Defined in:
- lib/openc3/top_level.rb
.write_exception_file(exception, filename = 'exception', log_dir = nil) ⇒ String|nil
Writes a log file with information about the current configuration including the Ruby version, OpenC3 version, whether you are on Windows, the OpenC3 path, and the Ruby path along with the exception that is passed in.
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
# File 'lib/openc3/top_level.rb', line 286 def self.write_exception_file(exception, filename = 'exception', log_dir = nil) log_file = create_log_file(filename, log_dir) do |file| file.puts "Exception:" if exception file.puts exception.formatted file.puts else file.puts "No Exception Given" file.puts caller.join("\n") file.puts end file.puts "Caller Backtrace:" file.puts caller().join("\n") file.puts file.puts "Ruby Version: ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE} patchlevel #{RUBY_PATCHLEVEL}) [#{RUBY_PLATFORM}]" file.puts "Rubygems Version: #{Gem::VERSION}" file.puts "OpenC3 Version: #{OpenC3::VERSION}" file.puts "OpenC3::PATH: #{OpenC3::PATH}" file.puts "" file.puts "Environment:" file.puts "RUBYOPT: #{ENV['RUBYOPT']}" file.puts "RUBYLIB: #{ENV['RUBYLIB']}" file.puts "GEM_PATH: #{ENV['GEM_PATH']}" file.puts "GEMRC: #{ENV['GEMRC']}" file.puts "RI_DEVKIT: #{ENV['RI_DEVKIT']}" file.puts "GEM_HOME: #{ENV['GEM_HOME']}" file.puts "PATH: #{ENV['PATH']}" file.puts "" file.puts "Ruby Path:\n #{$:.join("\n ")}\n\n" file.puts "Gems:" Gem.loaded_specs.values.map { |x| file.puts "#{x.name} #{x.version} #{x.platform}" } file.puts "" file.puts "All Threads Backtraces:" Thread.list.each do |thread| file.puts thread.backtrace.join("\n") file.puts end file.puts "" file.puts "" ensure file.close end return log_file end |