Sha256: d2b30abe9221e1d5d287101e07a4d76f58788fe7986bbaa0501c3add9a35879f

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

module Contrast
  module Agent
    module Reporting
      module Settings
        # Reaction the agent should take based on a state in TS.
        class Reaction
          attr_accessor :level, :operation, :message

          # used to check the parameters and also before reactions settings update
          LEVELS = %w[ERROR WARN INFO DEBUG TRACE].cs__freeze
          OPERATIONS = %w[NOOP DISABLE].cs__freeze

          # Reaction the agent should take based on a state in TS.
          #
          # @param level [String] The level at which the agent should log this reaction[ERROR, WARN, INFO, DEBUG, TRACE]
          # @param message [String] A message to log when receiving this reaction.
          # @param operation [String] What to do in response to this reaction.[NOOP, DISABLE]
          def initialize level, operation, message
            @level = level if LEVELS.include?(level)
            @operation = operation if OPERATIONS.include?(operation)
            @message = message if message.is_a?(String)
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
contrast-agent-6.1.2 lib/contrast/agent/reporting/settings/reaction.rb
contrast-agent-6.1.1 lib/contrast/agent/reporting/settings/reaction.rb