module SAPNW::Config::SAPNW::Base

Attributes

config[RW]
config_location[RW]

Public Class Methods

load_config() click to toggle source
# File lib/sapnwrfc/config.rb, line 76
def load_config
                    file = self.config_location || './sap.yml'
                          SAP_LOGGER.fatal("[#{self.name}] Configuration file not found:  #{file}") unless FileTest.exists?(file)
  self.config = File.open(file) { |f| YAML::load(f) }
  SAP_LOGGER.debug("[#{self.name}] Configuration: " + self.config.inspect)

              if self.config.key? 'logfile'
                            if %rSTDOUT/.match(self.config['logfile'])
                                    SAP_LOGGER.set_logdev(STDOUT)
                                  else
                                    SAP_LOGGER.set_logdev(self.config['logfile'],
                                                          self.config['logfile_age'] || 0,
                                                                                                                      self.config['logfile_size'] || 1048576)
                                    SAP_LOGGER.datetime_format = "%Y-%m-%d %H:%M:%S"
                                  end
                          end
              if self.config.key? 'loglevel'
                            case self.config['loglevel'].upcase
                                    when 'FATAL'
                                SAP_LOGGER.level = Logger::FATAL
                                    when 'ERROR'
                                SAP_LOGGER.level = Logger::ERROR
                                    when 'WARN'
                                SAP_LOGGER.level = Logger::WARN
                                    when 'INFO'
                                SAP_LOGGER.level = Logger::INFO
                                    when 'DEBUG'
                                SAP_LOGGER.level = Logger::DEBUG
                                  end
                          else
                            # set default 
                                  SAP_LOGGER.level = Logger::WARN
                          end
  return self.config
end