class VcoWorkflows::WorkflowExecutionLog

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

Attributes

messages[R]

Log messages @return [String Array of log message lines

Public Class Methods

new(log_json) click to toggle source

Create an execution log object @param [String] log_json JSON document as string @return [VcoWorkflows::WorkflowExecutionLog]

# 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

Public Instance Methods

to_s() click to toggle source

Stringify the log @return [String]

# File lib/vcoworkflows/workflowexecutionlog.rb, line 27
def to_s
  message = ''
  @messages.keys.sort.each do |timestamp|
    message << Time.at(timestamp / 1000).to_s
    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