Module: TerraformWrapper::Shared::Logging

Class Method Summary collapse

Class Method Details

.configure_logger_for(classname) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/terraform-wrapper/shared/logging.rb', line 43

def configure_logger_for(classname)
  colour = ENV["TERRAFORM_WRAPPER_LOG_COLOUR"] || "true"
  level  = ENV["TERRAFORM_WRAPPER_LOG_LEVEL"]  || "INFO"

  logger = ::TerraformWrapper::Shared::Logger.new(STDOUT)

  logger.colour   = colour.downcase == "true"
  logger.level    = level.upcase
  logger.progname = classname

  logger.formatter = proc do |severity, datetime, progname, msg|
    sevId = severity.chars.first.upcase
    "[#{sevId}] [#{progname}] #{msg}\n"
  end

  logger
end

.logger_for(classname) ⇒ Object



37
38
39
# File 'lib/terraform-wrapper/shared/logging.rb', line 37

def logger_for(classname)
  @loggers[classname] ||= configure_logger_for(classname)
end