Method: OpenC3.write_unexpected_file

Defined in:
lib/openc3/top_level.rb

.write_unexpected_file(text, filename = 'unexpected', log_dir = nil) ⇒ String|nil

Writes a log file with information about unexpected output

Parameters:

  • text (String)

    The unexpected output text

  • filename (String) (defaults to: 'unexpected')

    String to append to the exception log filename. The filename will start with a date/time stamp.

  • log_dir (String) (defaults to: nil)

    By default this method will write to the OpenC3 default log directory. By setting this parameter you can override the directory the log will be written to.

Returns:

  • (String|nil)

    The fully pathed log filename or nil if there was an error creating the log file.



342
343
344
345
346
347
348
349
350
# File 'lib/openc3/top_level.rb', line 342

def self.write_unexpected_file(text, filename = 'unexpected', log_dir = nil)
  log_file = create_log_file(filename, log_dir) do |file|
    file.puts "Unexpected Output:\n\n"
    file.puts text
  ensure
    file.close
  end
  return log_file
end