Method: OpenC3::TextLogMicroservice#initialize

Defined in:
lib/openc3/microservices/text_log_microservice.rb

#initialize(name) ⇒ TextLogMicroservice

Returns a new instance of TextLogMicroservice.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/openc3/microservices/text_log_microservice.rb', line 28

def initialize(name)
  super(name)
  @config['options'].each do |option|
    case option[0].upcase
    when 'CYCLE_TIME' # Maximum time between log files
      @cycle_time = option[1].to_i
    when 'CYCLE_SIZE' # Maximum size of a log file
      @cycle_size = option[1].to_i
    else
      @logger.error("Unknown option passed to microservice #{@name}: #{option}")
    end
  end

  # These settings limit the log file to 10 minutes or 50MB of data, whichever comes first
  @cycle_time = 600 unless @cycle_time # 10 minutes
  @cycle_size = 50_000_000 unless @cycle_size # ~50 MB

  @error_count = 0
  @metric.set(name: 'text_log_total', value: @count, type: 'counter')
  @metric.set(name: 'text_error_total', value: @error_count, type: 'counter')
end