Module: JustimmoClient::Logging Private

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Logging support

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.loggerLogger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Use the Rails or default logger if none is set.

Returns:

  • (Logger)


14
15
16
# File 'lib/justimmo_client/core/logging.rb', line 14

def logger
  @logger ||= rails_logger || default_logger
end

Class Method Details

.default_loggerObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



20
21
22
23
24
25
26
27
28
29
# File 'lib/justimmo_client/core/logging.rb', line 20

def default_logger
  logger = Logger.new($stdout)
  logger.level = JustimmoClient::Config.debug ? Logger::DEBUG : Logger::INFO
  logger.datetime_format = "%Y-%m-%d %H:%M:%S"
  logger.progname = "JustimmoClient"
  logger.formatter = proc do |severity, datetime, progname, message|
    "[#{format("%-5s", severity)}]  #{datetime}  #{progname}  #{message}\n"
  end
  logger
end

.rails_loggerLogger?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The Ruby on Rails logger

Returns:

  • (Logger, nil)

    The logger object



33
34
35
36
37
# File 'lib/justimmo_client/core/logging.rb', line 33

def rails_logger
  if ("true" == ENV.fetch("JUSTIMMO_USE_RAILS_LOGGER", "true")) && defined?(::Rails)
    ::Rails&.logger
  end
end

Instance Method Details

#loggerObject Also known as: log

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



40
41
42
# File 'lib/justimmo_client/core/logging.rb', line 40

def logger
  Logging.logger
end