module Shrine::Plugins::Logging::ClassMethods

  1. lib/shrine/plugins/logging.rb

Methods

Public Instance

  1. create_logger
  2. logger
  3. logger=
  4. pretty_formatter

Public Instance methods

create_logger ()
[show source]
# File lib/shrine/plugins/logging.rb, line 69
def create_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 ()
[show source]
# File lib/shrine/plugins/logging.rb, line 65
def logger
  @logger ||= opts[:logging_logger]
end
logger= (logger)
[show source]
# File lib/shrine/plugins/logging.rb, line 61
def logger=(logger)
  @logger = logger
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 79
def pretty_formatter
  proc do |severity, time, program_name, message|
    output = "#{Process.pid}: #{message}\n".dup
    output.prepend "#{time.utc.iso8601(3)} " unless ENV["DYNO"]
    output
  end
end