Module: Dynamoid::Config

Extended by:
Config, Options
Includes:
ActiveModel::Observing
Included in:
Config
Defined in:
lib/dynamoid/config.rb,
lib/dynamoid/config/options.rb

Overview

:nodoc

Defined Under Namespace

Modules: Options

Instance Method Summary collapse

Methods included from Options

defaults, option, reset, settings

Instance Method Details

#default_loggerObject

The default logger for Dynamoid: either the Rails logger or just stdout.

Since:

  • 0.2.0



33
34
35
# File 'lib/dynamoid/config.rb', line 33

def default_logger
  defined?(Rails) && Rails.respond_to?(:logger) ? Rails.logger : ::Logger.new($stdout)
end

#loggerObject

Returns the assigned logger instance.

Since:

  • 0.2.0



40
41
42
# File 'lib/dynamoid/config.rb', line 40

def logger
  @logger ||= default_logger
end

#logger=(logger) ⇒ Object

If you want to, set the logger manually to any output you’d like. Or pass false or nil to disable logging entirely.

Since:

  • 0.2.0



47
48
49
50
51
52
53
54
# File 'lib/dynamoid/config.rb', line 47

def logger=(logger)
  case logger
  when false, nil then @logger = nil
  when true then @logger = default_logger
  else
    @logger = logger if logger.respond_to?(:info)
  end
end