Module: Shrine::Plugins::Logging::ClassMethods
- Defined in:
- lib/shrine/plugins/logging.rb
Instance Method Summary collapse
- #create_logger ⇒ Object
- #logger ⇒ Object
- #logger=(logger) ⇒ Object
-
#pretty_formatter ⇒ Object
It makes logging preamble simpler than the default logger.
Instance Method Details
#create_logger ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/shrine/plugins/logging.rb', line 36 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 ⇒ Object
32 33 34 |
# File 'lib/shrine/plugins/logging.rb', line 32 def logger @logger ||= opts[:logging_logger] end |
#logger=(logger) ⇒ Object
28 29 30 |
# File 'lib/shrine/plugins/logging.rb', line 28 def logger=(logger) @logger = logger end |
#pretty_formatter ⇒ Object
It makes logging preamble simpler than the default logger. Also, it doesn’t output timestamps if on Heroku.
46 47 48 49 50 51 52 |
# File 'lib/shrine/plugins/logging.rb', line 46 def pretty_formatter proc do |severity, time, program_name, | output = "#{Process.pid}: #{}\n".dup output.prepend "#{time.utc.iso8601(3)} " unless ENV["DYNO"] output end end |