Sha256: c1b989eb67307d5d5493cb7b5365b7b9d5dcfccba5c0ca51a02efe774de14872

Contents?: true

Size: 1.01 KB

Versions: 33

Compression:

Stored size: 1.01 KB

Contents

module Fog
  class Logger

    @channels = {
      :deprecation  => ::STDOUT,
      :warning      => ::STDOUT
    }

    @channels[:debug] = ::STDOUT if ENV['DEBUG']

    def self.[](channel)
      @channels[channel]
    end

    def self.[]=(channel, value)
      @channels[channel] = value
    end

    def self.debug(message)
      self.write(:debug, "[light_black][fog][DEBUG] #{message}[/]\n")
    end

    def self.deprecation(message)
      self.write(:deprecation, "[yellow][fog][DEPRECATION] #{message}[/]\n")
    end

    def self.warning(message)
      self.write(:warning, "[yellow][fog][WARNING] #{message}[/]\n")
    end

    def self.write(key, value)
      if channel = @channels[key]
        message = if channel.tty?
          value.gsub(Formatador::PARSE_REGEX) { "\e[#{Formatador::STYLES[$1.to_sym]}m" }.gsub(Formatador::INDENT_REGEX, '')
        else
          value.gsub(Formatador::PARSE_REGEX, '').gsub(Formatador::INDENT_REGEX, '')
        end
        channel.write(message)
      end
      nil
    end

  end
end

Version data entries

33 entries across 33 versions & 2 rubygems

Version Path
fog-maestrodev-1.19.0.20140212012611 lib/fog/core/logger.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/core/logger.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/core/logger.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/core/logger.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/core/logger.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/core/logger.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/core/logger.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/core/logger.rb
fog-1.19.0 lib/fog/core/logger.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/core/logger.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/core/logger.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/core/logger.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/core/logger.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/core/logger.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/core/logger.rb
fog-maestrodev-1.18.0.20131209090811 lib/fog/core/logger.rb
fog-maestrodev-1.18.0.20131206115947 lib/fog/core/logger.rb
fog-maestrodev-1.18.0.20131205181604 lib/fog/core/logger.rb
fog-maestrodev-1.18.0.20131127194823 lib/fog/core/logger.rb
fog-maestrodev-1.18.0.20131126183714 lib/fog/core/logger.rb