Module: Mongoid::EncryptedFields::Logging

Included in:
Mongoid::EncryptedFields
Defined in:
lib/mongoid-encrypted-fields/logging.rb

Overview

Contains behavior for logging.

Instance Method Summary collapse

Instance Method Details

#default_loggerLogger

Get the default logger.

Examples:

Get the default logger.

Logging.default_logger

Returns:

  • (Logger)

    The default logger.

Since:

  • 1.0.0



41
42
43
44
45
# File 'lib/mongoid-encrypted-fields/logging.rb', line 41

def default_logger
  logger = Logger.new(STDOUT)
  logger.level = Logger::INFO
  logger
end

#loggerLogger

Get the logger.

Examples:

Get the logger.

Logging.logger

Returns:

  • (Logger)

    The logger.

Since:

  • 1.0.0



16
17
18
19
# File 'lib/mongoid-encrypted-fields/logging.rb', line 16

def logger
  return @logger if defined?(@logger)
  @logger = rails_logger || default_logger
end

#logger=(logger) ⇒ Logger

Set the logger.

Examples:

Set the logger.

Logging.logger = logger

Returns:

  • (Logger)

    The logger.

Since:

  • 1.0.0



55
56
57
# File 'lib/mongoid-encrypted-fields/logging.rb', line 55

def logger=(logger)
  @logger = logger
end

#rails_loggerLogger

Get the rails logger.

Examples:

Get the rails logger.

Logging.rails_logger

Returns:

  • (Logger)

    The Rails logger.

Since:

  • 1.0.0



29
30
31
# File 'lib/mongoid-encrypted-fields/logging.rb', line 29

def rails_logger
  defined?(Rails) && Rails.respond_to?(:logger) && Rails.logger
end