Sha256: 6f6127f43ebc449d1d006c39eb030a5d4f37f973bf7478b8c889ce1bc05e6b6f

Contents?: true

Size: 907 Bytes

Versions: 7

Compression:

Stored size: 907 Bytes

Contents

module Percheron
  module Actions
    class Logs
      include Base

      def initialize(unit, follow: false)
        @unit = unit
        @follow = follow
      end

      def execute!
        $logger.debug "Showing logs on '#{unit.name}' unit"
        display_logs!
      end

      private

        attr_reader :unit, :follow
        alias_method :follow?, :follow

        def options
          {
            stdout:     true,
            stderr:     true,
            timestamps: true,
            tail:       100
          }
        end

        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
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
percheron-0.7.13 lib/percheron/actions/logs.rb
percheron-0.7.12 lib/percheron/actions/logs.rb
percheron-0.7.11 lib/percheron/actions/logs.rb
percheron-0.7.10 lib/percheron/actions/logs.rb
percheron-0.7.9 lib/percheron/actions/logs.rb
percheron-0.7.8 lib/percheron/actions/logs.rb
percheron-0.7.7 lib/percheron/actions/logs.rb