Sha256: 00a58217f3eda03168ba811f60b2db04565236e0dd8eb8017e3069b73dcb815a
Contents?: true
Size: 1.19 KB
Versions: 3
Compression:
Stored size: 1.19 KB
Contents
module Fog class Logger @channels = { deprecation: ::STDERR, warning: ::STDERR } @channels[:debug] = ::STDERR if ENV["DEBUG"] # provide an env var with narrower scope in case of namespace conflicts @channels[:debug] = ::STDERR if ENV["FOG_DEBUG"] def self.[](channel) @channels[channel] end def self.[]=(channel, value) @channels[channel] = value end def self.debug(message) write(:debug, "[light_black][fog][DEBUG] #{message}[/]\n") end def self.deprecation(message) write(:deprecation, "[yellow][fog][DEPRECATION] #{message}[/]\n") end def self.warning(message) write(:warning, "[yellow][fog][WARNING] #{message}[/]\n") end def self.write(key, value) channel = @channels[key] if channel message = if channel.tty? value.gsub(Fog::Formatador::PARSE_REGEX) { "\e[#{Fog::Formatador::STYLES[$1.to_sym]}m" }.gsub(Fog::Formatador::INDENT_REGEX, "") else value.gsub(Fog::Formatador::PARSE_REGEX, "").gsub(Fog::Formatador::INDENT_REGEX, "") end channel.write(message) end nil end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
fog-core-2.6.0 | lib/fog/core/logger.rb |
fog-core-2.5.0 | lib/fog/core/logger.rb |
fog-core-2.4.0 | lib/fog/core/logger.rb |