Class: Kiev::Config
Constant Summary collapse
- DEFAULT_LOG_REQUEST_CONDITION =
proc do |request, _response| !DEFAULT_LOG_REQUEST_REGEXP.match(request.path) end
- DEFAULT_LOG_REQUEST_ERROR_CONDITION =
proc do |_request, response| response.status != 404 end
- DEFAULT_LOG_RESPONSE_BODY_CONDITION =
proc do |_request, response| !!(response.status >= 400 && response.status < 500 && response.content_type =~ DEFAULT_LOG_RESPONSE_BODY_REGEXP) end
- DEFAULT_LOG_REQUEST_BODY_CONDITION =
proc do |request, _response| !!(request.content_type =~ /(application|text)\/xml/) end
- DEFAULT_IGNORED_RACK_EXCEPTIONS =
%w( ActiveRecord::RecordNotFound Mongoid::Errors::DocumentNotFound Sequel::RecordNotFound ).freeze
- FILTERED_PARAMS =
%w( client_secret token password password_confirmation old_password credit_card_number credit_card_cvv credit_card_holder credit_card_expiry_month credit_card_expiry_year CardNumber CardCVV CardExpires ).freeze
- IGNORED_PARAMS =
(%w( controller action format authenticity_token utf8 tempfile ) << :tempfile).freeze
- DEFAULT_HTTP_PROPAGATED_FIELDS =
{ tracking_id: "X-Tracking-Id", request_id: "X-Request-Id", request_depth: "X-Request-Depth", tree_path: "X-Tree-Path" }.freeze
- DEFAULT_PRE_RACK_HOOK =
proc do |env| Config.instance.http_propagated_fields.each do |key, http_key| Kiev[key] = Util.sanitize(env[Util.to_http(http_key)]) end end
Instance Attribute Summary collapse
-
#all_http_propagated_fields ⇒ Object
readonly
Returns the value of attribute all_http_propagated_fields.
-
#all_jobs_propagated_fields ⇒ Object
readonly
Returns the value of attribute all_jobs_propagated_fields.
-
#app ⇒ Object
Returns the value of attribute app.
-
#development_mode ⇒ Object
Returns the value of attribute development_mode.
-
#disable_default_logger ⇒ Object
Returns the value of attribute disable_default_logger.
-
#disable_filter_for_log_levels ⇒ Object
Returns the value of attribute disable_filter_for_log_levels.
-
#filtered_params ⇒ Object
Returns the value of attribute filtered_params.
-
#http_propagated_fields ⇒ Object
Returns the value of attribute http_propagated_fields.
-
#ignored_params ⇒ Object
Returns the value of attribute ignored_params.
-
#ignored_rack_exceptions ⇒ Object
Returns the value of attribute ignored_rack_exceptions.
-
#jobs_propagated_fields ⇒ Object
Returns the value of attribute jobs_propagated_fields.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#log_request_body_condition ⇒ Object
Returns the value of attribute log_request_body_condition.
-
#log_request_condition ⇒ Object
Returns the value of attribute log_request_condition.
-
#log_request_error_condition ⇒ Object
Returns the value of attribute log_request_error_condition.
-
#log_response_body_condition ⇒ Object
Returns the value of attribute log_response_body_condition.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#persistent_log_fields ⇒ Object
Returns the value of attribute persistent_log_fields.
-
#pre_rack_hook ⇒ Object
Returns the value of attribute pre_rack_hook.
Instance Method Summary collapse
- #filter_enabled? ⇒ Boolean
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #log_path=(value) ⇒ Object
-
#propagated_fields=(value) ⇒ Object
shortcut.
- #supported_log_levels ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/kiev/config.rb', line 109 def initialize @log_request_condition = DEFAULT_LOG_REQUEST_CONDITION @log_request_error_condition = DEFAULT_LOG_REQUEST_ERROR_CONDITION @log_response_body_condition = DEFAULT_LOG_RESPONSE_BODY_CONDITION @log_request_body_condition = DEFAULT_LOG_REQUEST_BODY_CONDITION @filtered_params = FILTERED_PARAMS @ignored_params = IGNORED_PARAMS @disable_default_logger = true @development_mode = false @ignored_rack_exceptions = DEFAULT_IGNORED_RACK_EXCEPTIONS.dup @logger = Kiev::Logger.new(STDOUT) @log_level = default_log_level @persistent_log_fields = [] @pre_rack_hook = DEFAULT_PRE_RACK_HOOK @disable_filter_for_log_levels = [] self.propagated_fields = {} update_logger_settings end |
Instance Attribute Details
#all_http_propagated_fields ⇒ Object (readonly)
Returns the value of attribute all_http_propagated_fields.
100 101 102 |
# File 'lib/kiev/config.rb', line 100 def all_http_propagated_fields @all_http_propagated_fields end |
#all_jobs_propagated_fields ⇒ Object (readonly)
Returns the value of attribute all_jobs_propagated_fields.
100 101 102 |
# File 'lib/kiev/config.rb', line 100 def all_jobs_propagated_fields @all_jobs_propagated_fields end |
#app ⇒ Object
Returns the value of attribute app.
88 89 90 |
# File 'lib/kiev/config.rb', line 88 def app @app end |
#development_mode ⇒ Object
Returns the value of attribute development_mode.
100 101 102 |
# File 'lib/kiev/config.rb', line 100 def development_mode @development_mode end |
#disable_default_logger ⇒ Object
Returns the value of attribute disable_default_logger.
88 89 90 |
# File 'lib/kiev/config.rb', line 88 def disable_default_logger @disable_default_logger end |
#disable_filter_for_log_levels ⇒ Object
Returns the value of attribute disable_filter_for_log_levels.
100 101 102 |
# File 'lib/kiev/config.rb', line 100 def disable_filter_for_log_levels @disable_filter_for_log_levels end |
#filtered_params ⇒ Object
Returns the value of attribute filtered_params.
88 89 90 |
# File 'lib/kiev/config.rb', line 88 def filtered_params @filtered_params end |
#http_propagated_fields ⇒ Object
Returns the value of attribute http_propagated_fields.
100 101 102 |
# File 'lib/kiev/config.rb', line 100 def http_propagated_fields @http_propagated_fields end |
#ignored_params ⇒ Object
Returns the value of attribute ignored_params.
88 89 90 |
# File 'lib/kiev/config.rb', line 88 def ignored_params @ignored_params end |
#ignored_rack_exceptions ⇒ Object
Returns the value of attribute ignored_rack_exceptions.
88 89 90 |
# File 'lib/kiev/config.rb', line 88 def ignored_rack_exceptions @ignored_rack_exceptions end |
#jobs_propagated_fields ⇒ Object
Returns the value of attribute jobs_propagated_fields.
100 101 102 |
# File 'lib/kiev/config.rb', line 100 def jobs_propagated_fields @jobs_propagated_fields end |
#log_level ⇒ Object
Returns the value of attribute log_level.
100 101 102 |
# File 'lib/kiev/config.rb', line 100 def log_level @log_level end |
#log_request_body_condition ⇒ Object
Returns the value of attribute log_request_body_condition.
88 89 90 |
# File 'lib/kiev/config.rb', line 88 def log_request_body_condition @log_request_body_condition end |
#log_request_condition ⇒ Object
Returns the value of attribute log_request_condition.
88 89 90 |
# File 'lib/kiev/config.rb', line 88 def log_request_condition @log_request_condition end |
#log_request_error_condition ⇒ Object
Returns the value of attribute log_request_error_condition.
88 89 90 |
# File 'lib/kiev/config.rb', line 88 def log_request_error_condition @log_request_error_condition end |
#log_response_body_condition ⇒ Object
Returns the value of attribute log_response_body_condition.
88 89 90 |
# File 'lib/kiev/config.rb', line 88 def log_response_body_condition @log_response_body_condition end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
100 101 102 |
# File 'lib/kiev/config.rb', line 100 def logger @logger end |
#persistent_log_fields ⇒ Object
Returns the value of attribute persistent_log_fields.
88 89 90 |
# File 'lib/kiev/config.rb', line 88 def persistent_log_fields @persistent_log_fields end |
#pre_rack_hook ⇒ Object
Returns the value of attribute pre_rack_hook.
88 89 90 |
# File 'lib/kiev/config.rb', line 88 def pre_rack_hook @pre_rack_hook end |
Instance Method Details
#filter_enabled? ⇒ Boolean
175 176 177 |
# File 'lib/kiev/config.rb', line 175 def filter_enabled? !disable_filter_for_log_levels.include?(log_level) end |
#log_path=(value) ⇒ Object
148 149 150 151 |
# File 'lib/kiev/config.rb', line 148 def log_path=(value) logger.path = value update_logger_settings end |
#propagated_fields=(value) ⇒ Object
shortcut
143 144 145 146 |
# File 'lib/kiev/config.rb', line 143 def propagated_fields=(value) self.http_propagated_fields = value self.jobs_propagated_fields = value.keys end |
#supported_log_levels ⇒ Object
171 172 173 |
# File 'lib/kiev/config.rb', line 171 def supported_log_levels SUPPORTED_LOG_LEVELS end |