Class: InstanceAgent::Plugins::CodeDeployPlugin::ScriptLog

Inherits:
Object
  • Object
show all
Defined in:
lib/instance_agent/plugins/codedeploy/hook_executor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#logObject (readonly)

Returns the value of attribute log.



10
11
12
# File 'lib/instance_agent/plugins/codedeploy/hook_executor.rb', line 10

def log
  @log
end

Instance Method Details

#append_to_log(log_entry) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/instance_agent/plugins/codedeploy/hook_executor.rb', line 11

def append_to_log(log_entry)
  log_entry ||= ""
  @log ||= []
  @log.push(log_entry)

  index = @log.size
  remaining_buffer = 2048

  while (index > 0 && (remaining_buffer - @log[index-1].length) > 0)
    index = index - 1
    remaining_buffer = remaining_buffer - @log[index-1].length
  end

  if index > 0
    @log = @log.drop(index)
  end
end

#concat_log(log_entries) ⇒ Object



29
30
31
32
33
34
# File 'lib/instance_agent/plugins/codedeploy/hook_executor.rb', line 29

def concat_log(log_entries)
  log_entries ||= []
  log_entries.each do |log_entry|
    append_to_log(log_entry)
  end
end