Sha256: 67be92529a7d985c9d4716208575d22b23e7739fb326ffc6308b31fae36aa4d0

Contents?: true

Size: 825 Bytes

Versions: 10

Compression:

Stored size: 825 Bytes

Contents

module SimpleDeploy
  class SimpleDeployLogger

    require 'forwardable'

    extend Forwardable

    def_delegators :@logger, :debug, :error, :info, :warn

    # For capistrano output
    # Only output Cap commands in debug mode
    def puts(msg, line_prefix=nil)
      @logger.debug msg.chomp
    end

    def initialize(args = {})
      @log_level = args[:log_level] ||= 'info'
      @logger    = args[:logger] ||= new_logger(args)
    end

    def logger_level
      Logger.const_get @log_level.upcase
    end

    private

    def new_logger(args)
      Logger.new(STDOUT).tap do |l|
        l.datetime_format = '%Y-%m-%dT%H:%M:%S%z'
        l.formatter = proc do |severity, datetime, progname, msg|
          "#{datetime} #{severity} : #{msg}\n"
        end
        l.level = logger_level
      end
    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
simple_deploy-0.5.6 lib/simple_deploy/logger.rb
simple_deploy-0.5.5 lib/simple_deploy/logger.rb
simple_deploy-0.5.4 lib/simple_deploy/logger.rb
simple_deploy-0.5.3 lib/simple_deploy/logger.rb
simple_deploy-0.5.2 lib/simple_deploy/logger.rb
simple_deploy-0.5.1 lib/simple_deploy/logger.rb
simple_deploy-0.5.0 lib/simple_deploy/logger.rb
simple_deploy-0.4.8 lib/simple_deploy/logger.rb
simple_deploy-0.4.7 lib/simple_deploy/logger.rb
simple_deploy-0.4.6 lib/simple_deploy/logger.rb