Class: VcoWorkflows::WorkflowExecutionLog

Inherits:
Object
  • Object
show all
Defined in:
lib/vcoworkflows/workflowexecutionlog.rb

Overview

WorkflowExecutionLog is a simple object to contain the log for an execution of a workflow.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(log_json) ⇒ VcoWorkflows::WorkflowExecutionLog

Create an execution log object

Parameters:

  • JSON document as string



16
17
18
19
20
21
# File 'lib/vcoworkflows/workflowexecutionlog.rb', line 16

def initialize(log_json)
  @messages = {}
  JSON.parse(log_json)['logs'].each do |log_entry|
    messages[log_entry['entry']['time-stamp']] = log_entry['entry']
  end
end

Instance Attribute Details

#messagesString[] (readonly)

Log messages

Returns:

  • Array of log message lines



11
12
13
# File 'lib/vcoworkflows/workflowexecutionlog.rb', line 11

def messages
  @messages
end

Instance Method Details

#to_sString

Stringify the log

Returns:



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/vcoworkflows/workflowexecutionlog.rb', line 27

def to_s
  message = ''
  @messages.keys.sort.each do |timestamp|
    message << "#{Time.at(timestamp / 1000)}"
    message << " #{@messages[timestamp]['severity']}: #{@messages[timestamp]['user']}:"
    message << " #{@messages[timestamp]['short-description']}"
    unless @messages[timestamp]['short-description'].eql?(@messages[timestamp]['long-description'])
      message << "; #{@messages[timestamp]['long-description']}"
    end
    message << "\n"
  end
  message
end