Class: Fog::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/core/logger.rb

Class Method Summary collapse

Class Method Details

.[](channel) ⇒ Object



11
12
13
# File 'lib/fog/core/logger.rb', line 11

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

.[]=(channel, value) ⇒ Object



15
16
17
# File 'lib/fog/core/logger.rb', line 15

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

.debug(message) ⇒ Object



19
20
21
# File 'lib/fog/core/logger.rb', line 19

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

.deprecation(message) ⇒ Object



23
24
25
# File 'lib/fog/core/logger.rb', line 23

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

.warning(message) ⇒ Object



27
28
29
# File 'lib/fog/core/logger.rb', line 27

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

.write(key, value) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fog/core/logger.rb', line 31

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