Method: OpenC3::StreamLog#initialize

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

#initialize(log_name, log_type, cycle_time = 600, cycle_size = 50_000_000, cycle_hour = nil, cycle_minute = nil) ⇒ StreamLog

Returns a new instance of StreamLog.

Parameters:

  • log_name (String)

    The name of the stream log. Typically matches the name of the corresponding interface

  • log_type (Symbol)

    The type of log to create. Must be :READ or :WRITE.

  • cycle_time (Integer) (defaults to: 600)

    The amount of time in seconds before creating a new log file. This can be combined with cycle_size.

  • cycle_size (Integer) (defaults to: 50_000_000)

    The size in bytes before creating a new log file. This can be combined with cycle_time.

  • cycle_hour (Integer) (defaults to: nil)

    The time at which to cycle the log. Combined with cycle_minute to cycle the log daily at the specified time. If nil, the log will be cycled hourly at the specified cycle_minute.

  • cycle_minute (Integer) (defaults to: nil)

    The time at which to cycle the log. See cycle_hour for more information.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/openc3/logs/stream_log.rb', line 44

def initialize(
  log_name,
  log_type,
  cycle_time = 600, # 10 minutes, matches time in target_model
  cycle_size = 50_000_000, # 50MB, matches size in target_model
  cycle_hour = nil,
  cycle_minute = nil
)
  raise "log_type must be :READ or :WRITE" unless LOG_TYPES.include? log_type

  super(
    "#{ENV['OPENC3_SCOPE']}/stream_logs/",
    true, # Start with logging enabled
    cycle_time,
    cycle_size,
    cycle_hour,
    cycle_minute
  )

  @log_type = log_type
  self.name = log_name
end