Module: QAT::Cucumber::Logger
- Included in:
- QAT::Cucumber
- Defined in:
- lib/qat/cucumber/logger.rb
Overview
Helper methods for logger configuration
Instance Method Summary collapse
-
#config_logger(configuration) ⇒ Object
Configures Logger with a given configuration.
-
#load_logger_config(to_load) ⇒ Object
Loads the logger configuration.
-
#validate_logger_config(configuration) ⇒ Object
Validates that a valid logger configuration exists in the QAT environment variable.
-
#validate_logger_yaml_config(configuration) ⇒ Object
Validates that a valid logger configuration exists in a YAML file.
Instance Method Details
#config_logger(configuration) ⇒ Object
Configures Logger with a given configuration
8 9 10 11 12 |
# File 'lib/qat/cucumber/logger.rb', line 8 def config_logger(configuration) config = validate_logger_config(configuration) load_logger_config(config) if config end |
#load_logger_config(to_load) ⇒ Object
Loads the logger configuration
42 43 44 45 46 |
# File 'lib/qat/cucumber/logger.rb', line 42 def load_logger_config(to_load) Log4r::YamlConfigurator.load_yaml_file(to_load) log.info { "Loaded logger configuration from file '#{to_load}'" } end |
#validate_logger_config(configuration) ⇒ Object
Validates that a valid logger configuration exists in the QAT environment variable
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/qat/cucumber/logger.rb', line 16 def validate_logger_config(configuration) logger_env_config = ENV['QAT_LOGGER_CONFIG'] if logger_env_config raise InvalidConfiguration.new "Configuration file for logger does not exist: '#{logger_env_config}'" unless File.exists?(logger_env_config.to_s) logger_env_config else validate_logger_yaml_config(configuration) end end |
#validate_logger_yaml_config(configuration) ⇒ Object
Validates that a valid logger configuration exists in a YAML file
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/qat/cucumber/logger.rb', line 29 def validate_logger_yaml_config(configuration) configuration_directory = configuration.directory files = [File.join(configuration_directory, configuration.environment, 'logger.yml'), File.join(configuration_directory, 'common', 'logger.yml')] config = files.select { |file| File.exist?(file) } config.first end |