Class: Contrast::Agent::Reporting::Settings::Reaction

Inherits:
Object
  • Object
show all
Defined in:
lib/contrast/agent/reporting/settings/reaction.rb

Overview

Reaction the agent should take based on a state in TS.

Constant Summary collapse

OPERATIONS =

used to check the parameters and also before reactions settings update

%w[NOOP DISABLE].cs__freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(level, operation, message) ⇒ Reaction

Reaction the agent should take based on a state in TS.

Parameters:

  • level (String)

    The level at which the agent should log this reaction[ERROR, WARN, INFO, DEBUG, TRACE]

  • message (String)

    A message to log when receiving this reaction.

  • operation (String)

    What to do in response to this reaction.[NOOP, DISABLE]



22
23
24
25
26
# File 'lib/contrast/agent/reporting/settings/reaction.rb', line 22

def initialize level, operation, message
  @level = level if Contrast::Agent::Reporting::Settings::LogEnhancer::LOG_LEVELS.include?(level)
  @operation = operation if OPERATIONS.include?(operation)
  @message = message if message.is_a?(String)
end

Instance Attribute Details

#levelObject

Returns the value of attribute level.



12
13
14
# File 'lib/contrast/agent/reporting/settings/reaction.rb', line 12

def level
  @level
end

#messageObject

Returns the value of attribute message.



12
13
14
# File 'lib/contrast/agent/reporting/settings/reaction.rb', line 12

def message
  @message
end

#operationObject

Returns the value of attribute operation.



12
13
14
# File 'lib/contrast/agent/reporting/settings/reaction.rb', line 12

def operation
  @operation
end

Instance Method Details

#to_controlled_hashObject



28
29
30
31
32
33
34
# File 'lib/contrast/agent/reporting/settings/reaction.rb', line 28

def to_controlled_hash
  {
      message: message,
      level: level,
      operation: operation
  }
end