mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Add missing Events class
This commit is contained in:
parent
b64798808d
commit
ad0594e108
1 changed files with 36 additions and 0 deletions
36
lib/puma/events.rb
Normal file
36
lib/puma/events.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
require 'puma/const'
|
||||
require 'stringio'
|
||||
|
||||
module Puma
|
||||
class Events
|
||||
|
||||
include Const
|
||||
|
||||
def initialize(stdout, stderr)
|
||||
@stdout = stdout
|
||||
@stderr = stderr
|
||||
end
|
||||
|
||||
attr_reader :stdout, :stderr
|
||||
|
||||
def parse_error(server, env, error)
|
||||
@stderr.puts "#{Time.now}: HTTP parse error, malformed request (#{env[HTTP_X_FORWARDED_FOR] || env[REMOTE_ADDR]}): #{error.inspect}"
|
||||
@stderr.puts "#{Time.now}: ENV: #{env.inspect}\n---\n"
|
||||
end
|
||||
|
||||
def unknown_error(server, env, error, kind="Unknown")
|
||||
if error.respond_to? :render
|
||||
error.render "#{Time.now}: #{kind} error", @stderr
|
||||
else
|
||||
@stderr.puts "#{Time.now}: #{kind} error: #{error.inspect}"
|
||||
@stderr.puts error.backtrace.join("\n")
|
||||
end
|
||||
end
|
||||
|
||||
DEFAULT = new(STDOUT, STDERR)
|
||||
|
||||
def self.strings
|
||||
Events.new StringIO.new, StringIO.new
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue