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



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

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:



20
21
22
# File 'lib/openc3/logs/stream_log_pair.rb', line 20

def read_log
  @read_log
end

#write_logStreamLog

Returns The write log.

Returns:



22
23
24
# File 'lib/openc3/logs/stream_log_pair.rb', line 22

def write_log
  @write_log
end

Instance Method Details

#cleanupObject



57
58
59
60
# File 'lib/openc3/logs/stream_log_pair.rb', line 57

def cleanup
  @read_log.cleanup
  @write_log.cleanup
end

#cloneObject

Clone the stream log pair



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

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:



33
34
35
36
# File 'lib/openc3/logs/stream_log_pair.rb', line 33

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

#shutdownObject



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

def shutdown
  threads = @read_log.shutdown
  threads.concat(@write_log.shutdown)
  return threads
end

#startObject

Start stream logs



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

def start
  @read_log.start
  @write_log.start
end

#stopObject

Close any open stream log files



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

def stop
  threads = @read_log.stop
  threads.concat(@write_log.stop)
  return threads
end