Class: OpenC3::StreamLogPair

Inherits:
Object
  • Object
show all
Defined in:
lib/openc3/logs/stream_log_pair.rb

Overview

Holds a read/write pair of stream logs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, params = []) ⇒ StreamLogPair

Returns a new instance of StreamLogPair.

Parameters:

  • name (String)

    name to be added to log filenames

  • params (Array) (defaults to: [])

    stream log writer parameters or empty array



31
32
33
34
# File 'lib/openc3/logs/stream_log_pair.rb', line 31

def initialize(name, params = [])
  @read_log = StreamLog.new(name, :READ, *params)
  @write_log = StreamLog.new(name, :WRITE, *params)
end

Instance Attribute Details

#read_logStreamLog

Returns The read log.

Returns:



25
26
27
# File 'lib/openc3/logs/stream_log_pair.rb', line 25

def read_log
  @read_log
end

#write_logStreamLog

Returns The write log.

Returns:



27
28
29
# File 'lib/openc3/logs/stream_log_pair.rb', line 27

def write_log
  @write_log
end

Instance Method Details

#cloneObject

Clone the stream log pair



61
62
63
64
65
66
67
68
# File 'lib/openc3/logs/stream_log_pair.rb', line 61

def clone
  stream_log_pair = super()
  stream_log_pair.read_log = @read_log.clone
  stream_log_pair.write_log = @write_log.clone
  stream_log_pair.read_log.start if @read_log.logging_enabled
  stream_log_pair.write_log.start if @write_log.logging_enabled
  stream_log_pair
end

#name=(name) ⇒ Object

Change the stream log name

Parameters:



38
39
40
41
# File 'lib/openc3/logs/stream_log_pair.rb', line 38

def name=(name)
  @read_log.name = name
  @write_log.name = name
end

#shutdownObject



55
56
57
58
# File 'lib/openc3/logs/stream_log_pair.rb', line 55

def shutdown
  @read_log.shutdown
  @write_log.shutdown
end

#startObject

Start stream logs



44
45
46
47
# File 'lib/openc3/logs/stream_log_pair.rb', line 44

def start
  @read_log.start
  @write_log.start
end

#stopObject

Close any open stream log files



50
51
52
53
# File 'lib/openc3/logs/stream_log_pair.rb', line 50

def stop
  @read_log.stop
  @write_log.stop
end