module Shrine::Plugins::Logging::ClassMethods

  1. lib/shrine/plugins/logging.rb

Methods

Public Instance

  1. logger
  2. logger=
  3. pretty_formatter

Public Instance methods

logger ()

Initializes a new logger if it hasn't been initialized.

[show source]
# File lib/shrine/plugins/logging.rb, line 63
def logger
  @logger ||= opts[:logging_logger] || (
    logger = Logger.new(opts[:logging_stream])
    logger.level = Logger::INFO
    logger.level = Logger::WARN if ENV["RACK_ENV"] == "test"
    logger.formatter = pretty_formatter
    logger
  )
end
logger= (logger)
[show source]
# File lib/shrine/plugins/logging.rb, line 58
def logger=(logger)
  @logger = logger || Logger.new(nil)
end
pretty_formatter ()

It makes logging preamble simpler than the default logger. Also, it doesn't output timestamps if on Heroku.

[show source]
# File lib/shrine/plugins/logging.rb, line 75
def pretty_formatter
  proc do |severity, time, program_name, message|
    output = "#{Process.pid}: #{message}\n"
    output.prepend "#{time.utc.iso8601(3)} " unless ENV["DYNO"]
    output
  end
end