class Percheron::Actions::Logs

Attributes

follow[R]
follow?[R]
unit[R]

Public Class Methods

new(unit, follow: false) click to toggle source
# File lib/percheron/actions/logs.rb, line 6
def initialize(unit, follow: false)
  @unit = unit
  @follow = follow
end

Public Instance Methods

execute!() click to toggle source
# File lib/percheron/actions/logs.rb, line 11
def execute!
  $logger.debug "Showing logs on '#{unit.display_name}' unit"
  display_logs!
end

Private Instance Methods

display_logs!() click to toggle source
# File lib/percheron/actions/logs.rb, line 30
def display_logs!
  if follow?
    opts = options.merge(follow: true)
    unit.container.streaming_logs(opts) do |stream, chunk|
      puts "#{stream}: #{chunk}"
    end
  else
    puts unit.container.logs(options)
  end
rescue Interrupt
  nil
end
options() click to toggle source
# File lib/percheron/actions/logs.rb, line 21
def options
  {
    stdout:     true,
    stderr:     true,
    timestamps: true,
    tail:       100
  }
end