Class: Fog::Logger

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

Class Method Summary collapse

Class Method Details

.[](channel) ⇒ Object



8
9
10
# File 'lib/fog/core/logger.rb', line 8

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

.[]=(channel, value) ⇒ Object



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

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

.debug(message) ⇒ Object



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

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

.warning(message) ⇒ Object



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

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

.write(key, value) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/core/logger.rb', line 24

def self.write(key, value)
  if channel = @channels[key]
    value.gsub(Formatador::INDENT_REGEX, '')
    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