Method: OpenC3::PacketLogWriter#write
- Defined in:
- lib/openc3/logs/packet_log_writer.rb
#write(entry_type, cmd_or_tlm, target_name, packet_name, time_nsec_since_epoch, stored, data, id = nil, redis_topic = nil, redis_offset = '0-0', take_mutex: true, allow_new_file: true, received_time_nsec_since_epoch: nil, extra: nil) ⇒ Object
Write a packet to the log file.
If no log file currently exists in the filesystem, a new file will be created.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/openc3/logs/packet_log_writer.rb', line 98 def write(entry_type, cmd_or_tlm, target_name, packet_name, time_nsec_since_epoch, stored, data, id = nil, redis_topic = nil, redis_offset = '0-0', take_mutex: true, allow_new_file: true, received_time_nsec_since_epoch: nil, extra: nil) return if !@logging_enabled @mutex.lock if take_mutex begin if entry_type == :RAW_PACKET or entry_type == :JSON_PACKET # Only care about the timestamps on the real packets being in order process_out_of_order = true else # Metadata timestamps don't matter process_out_of_order = false end prepare_write(time_nsec_since_epoch, data.length, redis_topic, redis_offset, allow_new_file: allow_new_file, process_out_of_order: process_out_of_order) write_entry(entry_type, cmd_or_tlm, target_name, packet_name, time_nsec_since_epoch, stored, data, id, received_time_nsec_since_epoch: received_time_nsec_since_epoch, extra: extra) if @file ensure @mutex.unlock if take_mutex end rescue => e Logger.instance.error "Error writing #{@filename} : #{e.formatted}" OpenC3.handle_critical_exception(e) end |