Sha256: 7da37bd8c326f79c7686d02167cf49b98099cfc073d4e7aec6b38a4c7cde4f0a
Contents?: true
Size: 669 Bytes
Versions: 3
Compression:
Stored size: 669 Bytes
Contents
require 'logger' require 'benchmark' module Thumbs class Logger def initialize(app, logfile_path) @logger = ::Logger.new(logfile_path, 0) @logger.datetime_format = "%Y-%m-%d %H:%M:%S" @app = app end def call(env) env['thumbs.logger'] = [] env['thumbs.logger'] << "#{env['thumbs.remote_url']}@#{env['thumbs.size']}" response = [] realtime = Benchmark.realtime do response = @app.call(env) end status, headers, body = response env['thumbs.logger'] << sprintf('%.4f', realtime) @logger.info env['thumbs.logger'].join(" : ") return [status, headers, body] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
thumbs-0.0.5 | lib/thumbs/middleware/logger.rb |
thumbs-0.0.4 | lib/thumbs/middleware/logger.rb |
thumbs-0.0.3 | lib/thumbs/middleware/logger.rb |