11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/sinatra/silent.rb', line 11
def set(option, value = (not_set = true), ignore_setter = false, &block)
return if option == {}
case option
when :silent_all
set :silent_sinatra, true
set :silent_webrick, true
set :silent_access_log, true
when :silent_access_log
new_server_settings = if value == true
existing_server_settings.merge(AccessLog: [])
else
existing_server_settings.tap { |hash| hash.delete(:AccessLog) }
end
super :server_settings, new_server_settings
when :silent_sinatra
case value
when true
self.define_singleton_method :suppress_messages? do
return true
end
when false
self.define_singleton_method :suppress_messages? do
handler_name =~ /cgi/i || quiet
end
end
when :silent_webrick
new_server_settings = if value == true
existing_server_settings.merge(Logger: SilentLogger.new)
else
existing_server_settings.tap { |hash| hash.delete(:Logger) }
end
super :server_settings, new_server_settings
else
super option, value, ignore_setter, &block
end
end
|