1
0
Fork 0
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:
Evan Phoenix 2011-09-30 10:29:37 -05:00
parent b64798808d
commit ad0594e108

36
lib/puma/events.rb Normal file
View 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