Class: GrayLogger::Configuration

Inherits:
Object
  • Object
show all
Includes:
Support
Defined in:
lib/gray_logger/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Support

included

Constructor Details

#initialize(configuration_hash) ⇒ Configuration

Returns a new instance of Configuration.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/gray_logger/configuration.rb', line 6

def initialize(configuration_hash)
  unless configuration_hash.nil?
    configuration = configuration_hash.dup
    defaults = {
      :size => "WAN",
      :facility => "facility-not-defined"
    }

    config = symbolize_keys(configuration)
    config = defaults.merge(config)

    [:host, :port, :size, :automatic_logging, :logger_level].each do |method|
      send("#{method}=", config.delete(method))
    end
    self.options = config
  end
end

Instance Attribute Details

#automatic_loggingObject

Returns the value of attribute automatic_logging.



5
6
7
# File 'lib/gray_logger/configuration.rb', line 5

def automatic_logging
  @automatic_logging
end

#hostObject

Returns the value of attribute host.



5
6
7
# File 'lib/gray_logger/configuration.rb', line 5

def host
  @host
end

#logger_levelObject

Returns the value of attribute logger_level.



5
6
7
# File 'lib/gray_logger/configuration.rb', line 5

def logger_level
  @logger_level
end

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/gray_logger/configuration.rb', line 5

def options
  @options
end

#portObject

Returns the value of attribute port.



5
6
7
# File 'lib/gray_logger/configuration.rb', line 5

def port
  @port
end

#sizeObject

Returns the value of attribute size.



5
6
7
# File 'lib/gray_logger/configuration.rb', line 5

def size
  @size
end

Instance Method Details

#automatic_logging?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/gray_logger/configuration.rb', line 31

def automatic_logging?
  @automatic_logging.nil? ? true : !!@automatic_logging
end

#valid?Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
# File 'lib/gray_logger/configuration.rb', line 24

def valid?
  invalid_host = self.host.nil?
  invalid_port = self.port.nil?
  invalid_size = self.size.nil?
  !(invalid_host || invalid_port || invalid_size)
end