Module: Pundit::Logger::Configuration
- Included in:
- Pundit::Logger
- Defined in:
- lib/pundit_logger/configuration.rb
Instance Attribute Summary collapse
- #base_controller ⇒ Object
-
#log_controller_policy_summary ⇒ Object
writeonly
Enable logging a summary of all policies and scopes used in a controller request, after the action completes.
- #log_level ⇒ Object
-
#log_scope_instantiation ⇒ Object
writeonly
Enable logging when a Scope is instantiated.
-
#log_unauthorized_policies ⇒ Object
writeonly
Enable logging when a policy returns unauthorized (a Pundit::NotAuthorizedError), and that error is unhandled, bubbling up to the controller).
- #logger ⇒ Object
- #logger_tag ⇒ Object
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
Used to configure Pundit:Logger in your application.
- #log_controller_policy_summary? ⇒ Boolean
- #log_scope_instantiation? ⇒ Boolean
- #log_unauthorized_policies? ⇒ Boolean
Instance Attribute Details
#base_controller ⇒ Object
19 20 21 22 23 |
# File 'lib/pundit_logger/configuration.rb', line 19 def base_controller ( @base_controller || 'ActionController::Base' ).constantize end |
#log_controller_policy_summary=(value) ⇒ Object (writeonly)
Enable logging a summary of all policies and scopes used in a controller request, after the action completes.
Note that policies invoked by serializers are not logged at this time.
100 101 102 |
# File 'lib/pundit_logger/configuration.rb', line 100 def log_controller_policy_summary=(value) @log_controller_policy_summary = value end |
#log_level ⇒ Object
30 31 32 |
# File 'lib/pundit_logger/configuration.rb', line 30 def log_level @log_level ||= :debug end |
#log_scope_instantiation=(value) ⇒ Object (writeonly)
Enable logging when a Scope is instantiated. This can help identify the source of SQL queries following in the logs.
65 66 67 |
# File 'lib/pundit_logger/configuration.rb', line 65 def log_scope_instantiation=(value) @log_scope_instantiation = value end |
#log_unauthorized_policies=(value) ⇒ Object (writeonly)
Enable logging when a policy returns unauthorized (a Pundit::NotAuthorizedError), and that error is unhandled, bubbling up to the controller).
This logging includes the policy and the arguments, to help debug why the action was unauthorized.
83 84 85 |
# File 'lib/pundit_logger/configuration.rb', line 83 def (value) @log_unauthorized_policies = value end |
#logger ⇒ Object
43 44 45 |
# File 'lib/pundit_logger/configuration.rb', line 43 def logger @logger ||= Rails.logger end |
#logger_tag ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/pundit_logger/configuration.rb', line 52 def logger_tag if instance_variable_defined?(:@logger_tag) @logger_tag else 'PUNDIT' end end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
Used to configure Pundit:Logger in your application.
12 13 14 |
# File 'lib/pundit_logger/configuration.rb', line 12 def configure yield self if block_given? end |
#log_controller_policy_summary? ⇒ Boolean
101 102 103 104 105 106 107 |
# File 'lib/pundit_logger/configuration.rb', line 101 def log_controller_policy_summary? if instance_variable_defined?(:@log_controller_policy_summary) @log_controller_policy_summary else true end end |
#log_scope_instantiation? ⇒ Boolean
66 67 68 69 70 71 72 |
# File 'lib/pundit_logger/configuration.rb', line 66 def log_scope_instantiation? if instance_variable_defined?(:@log_scope_instantiation) @log_scope_instantiation else true end end |
#log_unauthorized_policies? ⇒ Boolean
84 85 86 87 88 89 90 |
# File 'lib/pundit_logger/configuration.rb', line 84 def if instance_variable_defined?(:@log_unauthorized_policies) @log_unauthorized_policies else true end end |