Sha256: 68259019a7aa25e064da535b744a826fd4c04439bed41b02ac9b6d2b3a3c70f8

Contents?: true

Size: 894 Bytes

Versions: 1

Compression:

Stored size: 894 Bytes

Contents

# frozen_string_literal: true

module Capistrano
  module ASG
    module Rolling
      # Logging support.
      class Logger
        def initialize(verbose: false)
          @verbose = verbose
        end

        def info(text)
          $stdout.puts format_text(text)
        end

        def error(text)
          $stderr.puts color(format_text(text), :red) # rubocop:disable Style/StderrPuts
        end

        def verbose(text)
          info(text) if @verbose
        end

        def bold(text, color = :light_white)
          color(text, color, :bold)
        end

        def color(text, color, mode = nil)
          _color.colorize(text, color, mode)
        end

        private

        def format_text(text)
          text.gsub(/\*\*(.+?)\*\*/, bold('\\1'))
        end

        def _color
          @_color ||= SSHKit::Color.new($stdout)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capistrano-asg-rolling-0.1.0 lib/capistrano/asg/rolling/logger.rb