Method: OpenC3::StreamLog#write

Defined in:
lib/openc3/logs/stream_log.rb

#write(data) ⇒ Object

Write to the log file.

If no log file currently exists in the filesystem, a new file will be created.

Parameters:

  • data (String)

    String of data



87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/openc3/logs/stream_log.rb', line 87

def write(data)
  return if !@logging_enabled
  return if !data or data.length <= 0

  @mutex.synchronize do
    time_nsec_since_epoch = Time.now.to_nsec_from_epoch
    prepare_write(time_nsec_since_epoch, data.length)
    write_entry(time_nsec_since_epoch, data) if @file
  end
rescue => err
  Logger.instance.error "Error writing #{@filename} : #{err.formatted}"
  OpenC3.handle_critical_exception(err)
end