Module: CommandTower::Execution::ContextAccess

Included in:
ServiceBase, Workflows::ApplicationWorkflow
Defined in:
lib/command_tower/execution.rb

Instance Method Summary collapse

Instance Method Details

#audit(name, subject: nil, affected_user: nil, changes: {}, metadata: {}, attribution_mode: nil, subject_label: nil, scope_class: :global, host_context: nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/command_tower/execution.rb', line 16

def audit(name, subject: nil, affected_user: nil, changes: {}, metadata: {}, attribution_mode: nil, subject_label: nil, scope_class: :global, host_context: nil)
  CommandTower::Audit::Emit.call(
    name:,
    subject:,
    affected_user:,
    changes:,
    metadata:,
    attribution_mode:,
    subject_label:,
    scope_class:,
    host_context:
  )
end

#execution_contextObject



8
9
10
# File 'lib/command_tower/execution.rb', line 8

def execution_context
  CommandTower::Current
end

#log_debug(msg) ⇒ Object



30
31
32
# File 'lib/command_tower/execution.rb', line 30

def log_debug(msg)
  publish_event(category: :log, name: :debug, payload: { message: msg.to_s })
end

#log_error(msg) ⇒ Object



42
43
44
# File 'lib/command_tower/execution.rb', line 42

def log_error(msg)
  publish_event(category: :log, name: :error, payload: { message: msg.to_s })
end

#log_info(msg) ⇒ Object



34
35
36
# File 'lib/command_tower/execution.rb', line 34

def log_info(msg)
  publish_event(category: :log, name: :info, payload: { message: msg.to_s })
end

#log_warn(msg) ⇒ Object



38
39
40
# File 'lib/command_tower/execution.rb', line 38

def log_warn(msg)
  publish_event(category: :log, name: :warn, payload: { message: msg.to_s })
end

#publish_event(category:, name:, payload: {}) ⇒ Object



12
13
14
# File 'lib/command_tower/execution.rb', line 12

def publish_event(category:, name:, payload: {})
  CommandTower::Events.publish(category:, name:, payload:, subject: self.class.name)
end