Module: Logging

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.colorsObject



5
6
7
8
9
10
11
12
# File 'lib/cfnguardian/log.rb', line 5

def colors
  @colors ||= {
    ERROR: 31, # red
    WARN: 33, # yellow
    INFO: 0,
    DEBUG: 32 # green
  }
end

.included(base) ⇒ Object

Addition



28
29
30
31
32
33
34
# File 'lib/cfnguardian/log.rb', line 28

def self.included(base)
  class << base
    def logger
      Logging.logger
    end
  end
end

.loggerObject



14
15
16
17
18
19
20
# File 'lib/cfnguardian/log.rb', line 14

def logger
  @logger ||= Logger.new($stdout)
  @logger.formatter = proc do |severity, datetime, progname, msg|
    "\e[#{colors[severity.to_sym]}m#{severity}: #{msg}\e[0m\n"
  end
  @logger
end

.logger=(logger) ⇒ Object



22
23
24
# File 'lib/cfnguardian/log.rb', line 22

def logger=(logger)
  @logger = logger
end

Instance Method Details

#loggerObject



36
37
38
# File 'lib/cfnguardian/log.rb', line 36

def logger
  Logging.logger
end