Created
April 20, 2010 06:11
-
-
Save matsuda/372113 to your computer and use it in GitHub Desktop.
Extend exception_notification plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%# app/views/exception_notifier/_environment.rhtml %> | |
<% max = @request.env.keys.max { |a,b| a.length <=> b.length } -%> | |
<% @request.env.keys.select{|key| key =~ /^[A-Z|_]+$/ }.sort.each do |key| -%> | |
* <%= "%-*s: %s" % [max.length, key, filter_sensitive_post_data_from_env(key, @request.env[key].to_s.strip)] %> | |
<% end -%> | |
* Process: <%= $$ %> | |
* Server : <%= `hostname -s`.chomp %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%# app/views/exception_notifier/_session.rhtml %> | |
<%- unless @request.env['rack.session'].nil? || @request.env['rack.session'].empty? -%> | |
<%- @request.env['rack.session'].keys.map{|k|k.to_s}.sort.each do |key| -%> | |
* <%= key %>: <%= PP.pp(@request.env['rack.session'][key.to_sym],"").gsub(/\n/, "\n ").strip %> | |
<%- end -%> | |
<%- end -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/exception_notification_config.rb | |
# filter_parametersメソッドが protected method のため__send__で呼ぶ | |
module ExceptionNotifierHelper | |
def filter_sensitive_post_data_parameters(parameters) | |
# exclude_raw_post_parameters? ? @controller.filter_parameters(parameters) : parameters | |
exclude_raw_post_parameters? ? @controller.__send__(:filter_parameters, parameters) : parameters | |
end | |
def filter_sensitive_post_data_from_env(env_key, env_value) | |
return env_value unless exclude_raw_post_parameters? | |
return PARAM_FILTER_REPLACEMENT if (env_key =~ /RAW_POST_DATA/i) | |
# return @controller.filter_parameters({env_key => env_value}).values[0] | |
return @controller.__send__(:filter_parameters, {env_key => env_value}).values[0] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment