Module: Config::Factory

Defined in:
lib/config/factory.rb,
lib/config/factory/log.rb,
lib/config/factory/environment.rb,
lib/config/factory/module_info.rb,
lib/config/factory/environments.rb,
lib/config/factory/abstract_factory.rb

Defined Under Namespace

Modules: AbstractFactory, Environments Classes: Environment

Constant Summary collapse

NAME =

The name of this gem

'config-factory'
VERSION =

The version of this gem

'0.0.2'
'Copyright (c) 2015 The Regents of the University of California'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.logLogger

Gets the logger for the module. Default logger logs to ‘$stdout`.

Returns:

  • (Logger)

    the logger



12
13
14
15
# File 'lib/config/factory/log.rb', line 12

def self.log
  self.log_device = $stdout unless @log
  @log
end

Class Method Details

.included(base) ⇒ Object



3
4
5
# File 'lib/config/factory/abstract_factory.rb', line 3

def self.included(base)
  base.extend(AbstractFactory)
end

.log_device=(value) ⇒ Object

Sets the log device. Defaults to ‘$stdout`

Parameters:

  • value (IO)

    the log device



19
20
21
# File 'lib/config/factory/log.rb', line 19

def self.log_device=(value)
  @log = new_logger(logdev: value)
end

.new_logger(logdev:, level: Logger::DEBUG, shift_age: 10, shift_size: 1024 * 1024) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/config/factory/log.rb', line 25

def self.new_logger(logdev:, level: Logger::DEBUG, shift_age: 10, shift_size: 1024 * 1024)
  logger = Logger.new(logdev, shift_age, shift_size)
  logger.level = level
  logger.formatter = proc do |severity, datetime, progname, msg|
    "#{datetime.to_time.utc} #{severity} -#{progname}- #{msg}\n"
  end
  logger
end