rails_semantic_logger 4.2.1 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/README.md +3 -6
 - data/Rakefile +2 -2
 - data/lib/rails_semantic_logger.rb +35 -0
 - data/lib/rails_semantic_logger/action_controller/log_subscriber.rb +108 -0
 - data/lib/rails_semantic_logger/action_view/log_subscriber.rb +108 -0
 - data/lib/rails_semantic_logger/active_record/log_subscriber.rb +186 -0
 - data/lib/rails_semantic_logger/delayed_job/plugin.rb +11 -0
 - data/lib/rails_semantic_logger/engine.rb +80 -70
 - data/lib/rails_semantic_logger/extensions/action_controller/live.rb +5 -3
 - data/lib/rails_semantic_logger/extensions/action_dispatch/debug_exceptions.rb +8 -6
 - data/lib/rails_semantic_logger/extensions/action_view/streaming_template_renderer.rb +8 -5
 - data/lib/rails_semantic_logger/extensions/active_job/logging.rb +8 -5
 - data/lib/rails_semantic_logger/extensions/active_model_serializers/logging.rb +11 -8
 - data/lib/rails_semantic_logger/extensions/rails/server.rb +2 -2
 - data/lib/rails_semantic_logger/rack/logger.rb +103 -0
 - data/lib/rails_semantic_logger/version.rb +2 -2
 - metadata +13 -14
 - data/lib/rails_semantic_logger/extensions/action_controller/log_subscriber.rb +0 -111
 - data/lib/rails_semantic_logger/extensions/action_controller/log_subscriber_processing.rb +0 -28
 - data/lib/rails_semantic_logger/extensions/action_view/log_subscriber.rb +0 -12
 - data/lib/rails_semantic_logger/extensions/active_record/log_subscriber.rb +0 -102
 - data/lib/rails_semantic_logger/extensions/rails/rack/logger.rb +0 -63
 - data/lib/rails_semantic_logger/extensions/rails/rack/logger_info_as_debug.rb +0 -30
 
| 
         @@ -1,3 +1,3 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module RailsSemanticLogger 
     | 
| 
       2 
     | 
    
         
            -
              VERSION = '4. 
     | 
| 
      
 1 
     | 
    
         
            +
            module RailsSemanticLogger
         
     | 
| 
      
 2 
     | 
    
         
            +
              VERSION = '4.3.0'.freeze
         
     | 
| 
       3 
3 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: rails_semantic_logger
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 4. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 4.3.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Reid Morrison
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2018- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2018-05-07 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rails
         
     | 
| 
         @@ -30,15 +30,15 @@ dependencies: 
     | 
|
| 
       30 
30 
     | 
    
         
             
                requirements:
         
     | 
| 
       31 
31 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       32 
32 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       33 
     | 
    
         
            -
                    version: '4. 
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '4.3'
         
     | 
| 
       34 
34 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       35 
35 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       36 
36 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       37 
37 
     | 
    
         
             
                requirements:
         
     | 
| 
       38 
38 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       39 
39 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       40 
     | 
    
         
            -
                    version: '4. 
     | 
| 
       41 
     | 
    
         
            -
            description:  
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '4.3'
         
     | 
| 
      
 41 
     | 
    
         
            +
            description: 
         
     | 
| 
       42 
42 
     | 
    
         
             
            email:
         
     | 
| 
       43 
43 
     | 
    
         
             
            - reidmo@gmail.com
         
     | 
| 
       44 
44 
     | 
    
         
             
            executables: []
         
     | 
| 
         @@ -49,20 +49,19 @@ files: 
     | 
|
| 
       49 
49 
     | 
    
         
             
            - README.md
         
     | 
| 
       50 
50 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       51 
51 
     | 
    
         
             
            - lib/rails_semantic_logger.rb
         
     | 
| 
      
 52 
     | 
    
         
            +
            - lib/rails_semantic_logger/action_controller/log_subscriber.rb
         
     | 
| 
      
 53 
     | 
    
         
            +
            - lib/rails_semantic_logger/action_view/log_subscriber.rb
         
     | 
| 
      
 54 
     | 
    
         
            +
            - lib/rails_semantic_logger/active_record/log_subscriber.rb
         
     | 
| 
      
 55 
     | 
    
         
            +
            - lib/rails_semantic_logger/delayed_job/plugin.rb
         
     | 
| 
       52 
56 
     | 
    
         
             
            - lib/rails_semantic_logger/engine.rb
         
     | 
| 
       53 
57 
     | 
    
         
             
            - lib/rails_semantic_logger/extensions/action_cable/tagged_logger_proxy.rb
         
     | 
| 
       54 
58 
     | 
    
         
             
            - lib/rails_semantic_logger/extensions/action_controller/live.rb
         
     | 
| 
       55 
     | 
    
         
            -
            - lib/rails_semantic_logger/extensions/action_controller/log_subscriber.rb
         
     | 
| 
       56 
     | 
    
         
            -
            - lib/rails_semantic_logger/extensions/action_controller/log_subscriber_processing.rb
         
     | 
| 
       57 
59 
     | 
    
         
             
            - lib/rails_semantic_logger/extensions/action_dispatch/debug_exceptions.rb
         
     | 
| 
       58 
     | 
    
         
            -
            - lib/rails_semantic_logger/extensions/action_view/log_subscriber.rb
         
     | 
| 
       59 
60 
     | 
    
         
             
            - lib/rails_semantic_logger/extensions/action_view/streaming_template_renderer.rb
         
     | 
| 
       60 
61 
     | 
    
         
             
            - lib/rails_semantic_logger/extensions/active_job/logging.rb
         
     | 
| 
       61 
62 
     | 
    
         
             
            - lib/rails_semantic_logger/extensions/active_model_serializers/logging.rb
         
     | 
| 
       62 
     | 
    
         
            -
            - lib/rails_semantic_logger/extensions/active_record/log_subscriber.rb
         
     | 
| 
       63 
     | 
    
         
            -
            - lib/rails_semantic_logger/extensions/rails/rack/logger.rb
         
     | 
| 
       64 
     | 
    
         
            -
            - lib/rails_semantic_logger/extensions/rails/rack/logger_info_as_debug.rb
         
     | 
| 
       65 
63 
     | 
    
         
             
            - lib/rails_semantic_logger/extensions/rails/server.rb
         
     | 
| 
      
 64 
     | 
    
         
            +
            - lib/rails_semantic_logger/rack/logger.rb
         
     | 
| 
       66 
65 
     | 
    
         
             
            - lib/rails_semantic_logger/version.rb
         
     | 
| 
       67 
66 
     | 
    
         
             
            homepage: https://github.com/rocketjob/rails_semantic_logger
         
     | 
| 
       68 
67 
     | 
    
         
             
            licenses:
         
     | 
| 
         @@ -76,7 +75,7 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       76 
75 
     | 
    
         
             
              requirements:
         
     | 
| 
       77 
76 
     | 
    
         
             
              - - ">="
         
     | 
| 
       78 
77 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       79 
     | 
    
         
            -
                  version: '2. 
     | 
| 
      
 78 
     | 
    
         
            +
                  version: '2.3'
         
     | 
| 
       80 
79 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       81 
80 
     | 
    
         
             
              requirements:
         
     | 
| 
       82 
81 
     | 
    
         
             
              - - ">="
         
     | 
| 
         @@ -84,8 +83,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       84 
83 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       85 
84 
     | 
    
         
             
            requirements: []
         
     | 
| 
       86 
85 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       87 
     | 
    
         
            -
            rubygems_version: 2.7. 
     | 
| 
      
 86 
     | 
    
         
            +
            rubygems_version: 2.7.6
         
     | 
| 
       88 
87 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       89 
88 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       90 
     | 
    
         
            -
            summary:  
     | 
| 
      
 89 
     | 
    
         
            +
            summary: Feature rich logging framework that replaces the Rails logger.
         
     | 
| 
       91 
90 
     | 
    
         
             
            test_files: []
         
     | 
| 
         @@ -1,111 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'action_controller/log_subscriber'
         
     | 
| 
       2 
     | 
    
         
            -
            ActionController::LogSubscriber
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            module ActionController
         
     | 
| 
       5 
     | 
    
         
            -
              class LogSubscriber
         
     | 
| 
       6 
     | 
    
         
            -
                # Log as debug to hide Processing messages in production
         
     | 
| 
       7 
     | 
    
         
            -
                def start_processing(event)
         
     | 
| 
       8 
     | 
    
         
            -
                  controller_logger(event).debug { "Processing ##{event.payload[:action]}" }
         
     | 
| 
       9 
     | 
    
         
            -
                end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
                def process_action(event)
         
     | 
| 
       12 
     | 
    
         
            -
                  controller_logger(event).info do
         
     | 
| 
       13 
     | 
    
         
            -
                    payload = event.payload.dup
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
                    # Unused, but needed for Devise 401 status code patch to still work.
         
     | 
| 
       16 
     | 
    
         
            -
                    ActionController::Base.log_process_action(payload)
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
                    # According to PR https://github.com/rocketjob/rails_semantic_logger/pull/37/files
         
     | 
| 
       19 
     | 
    
         
            -
                    # payload[:params] is not always a Hash.
         
     | 
| 
       20 
     | 
    
         
            -
                    payload[:params] = payload[:params].to_unsafe_h unless payload[:params].is_a?(Hash)
         
     | 
| 
       21 
     | 
    
         
            -
                    payload[:params].except!(*INTERNAL_PARAMS)
         
     | 
| 
       22 
     | 
    
         
            -
                    payload.delete(:params) if payload[:params].empty?
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
                    format           = payload[:format]
         
     | 
| 
       25 
     | 
    
         
            -
                    payload[:format] = format.to_s.upcase if format.is_a?(Symbol)
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
                    payload[:path]   = extract_path(payload[:path]) if payload.has_key?(:path)
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
                    exception = payload.delete(:exception)
         
     | 
| 
       30 
     | 
    
         
            -
                    if payload[:status].nil? && exception.present?
         
     | 
| 
       31 
     | 
    
         
            -
                      exception_class_name = exception.first
         
     | 
| 
       32 
     | 
    
         
            -
                      payload[:status]     = ActionDispatch::ExceptionWrapper.status_code_for_exception(exception_class_name)
         
     | 
| 
       33 
     | 
    
         
            -
                    end
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
                    # Rounds off the runtimes. For example, :view_runtime, :mongo_runtime, etc.
         
     | 
| 
       36 
     | 
    
         
            -
                    payload.keys.each do |key|
         
     | 
| 
       37 
     | 
    
         
            -
                      payload[key] = payload[key].to_f.round(2) if key.to_s.match(/(.*)_runtime/)
         
     | 
| 
       38 
     | 
    
         
            -
                    end
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
                    payload[:status_message] = Rack::Utils::HTTP_STATUS_CODES[payload[:status]] if payload[:status].present?
         
     | 
| 
       41 
     | 
    
         
            -
                    # Causes excessive log output with Rails 5 RC1
         
     | 
| 
       42 
     | 
    
         
            -
                    payload.delete(:headers)
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
                    {
         
     | 
| 
       45 
     | 
    
         
            -
                      message:  "Completed ##{payload[:action]}",
         
     | 
| 
       46 
     | 
    
         
            -
                      duration: event.duration,
         
     | 
| 
       47 
     | 
    
         
            -
                      payload:  payload
         
     | 
| 
       48 
     | 
    
         
            -
                    }
         
     | 
| 
       49 
     | 
    
         
            -
                  end
         
     | 
| 
       50 
     | 
    
         
            -
                end
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
                def halted_callback(event)
         
     | 
| 
       53 
     | 
    
         
            -
                  controller_logger(event).info { "Filter chain halted as #{event.payload[:filter].inspect} rendered or redirected" }
         
     | 
| 
       54 
     | 
    
         
            -
                end
         
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
                def send_file(event)
         
     | 
| 
       57 
     | 
    
         
            -
                  controller_logger(event).info('Sent file') { {path: event.payload[:path], duration: event.duration} }
         
     | 
| 
       58 
     | 
    
         
            -
                end
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
                def redirect_to(event)
         
     | 
| 
       61 
     | 
    
         
            -
                  controller_logger(event).info('Redirected to') { {location: event.payload[:location]} }
         
     | 
| 
       62 
     | 
    
         
            -
                end
         
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
                def send_data(event)
         
     | 
| 
       65 
     | 
    
         
            -
                  controller_logger(event).info('Sent data') { {file_name: event.payload[:filename], duration: event.duration} }
         
     | 
| 
       66 
     | 
    
         
            -
                end
         
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
                def unpermitted_parameters(event)
         
     | 
| 
       69 
     | 
    
         
            -
                  controller_logger(event).debug do
         
     | 
| 
       70 
     | 
    
         
            -
                    unpermitted_keys = event.payload[:keys]
         
     | 
| 
       71 
     | 
    
         
            -
                    "Unpermitted parameter#{'s' if unpermitted_keys.size > 1}: #{unpermitted_keys.join(", ")}"
         
     | 
| 
       72 
     | 
    
         
            -
                  end
         
     | 
| 
       73 
     | 
    
         
            -
                end
         
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
                %w(write_fragment read_fragment exist_fragment?
         
     | 
| 
       76 
     | 
    
         
            -
                   expire_fragment expire_page write_page).each do |method|
         
     | 
| 
       77 
     | 
    
         
            -
                  class_eval <<-METHOD, __FILE__, __LINE__ + 1
         
     | 
| 
       78 
     | 
    
         
            -
                    def #{method}(event)
         
     | 
| 
       79 
     | 
    
         
            -
                      # enable_fragment_cache_logging as of Rails 5
         
     | 
| 
       80 
     | 
    
         
            -
                      return if ActionController::Base.respond_to?(:enable_fragment_cache_logging) && !ActionController::Base.enable_fragment_cache_logging
         
     | 
| 
       81 
     | 
    
         
            -
                      controller_logger(event).info do
         
     | 
| 
       82 
     | 
    
         
            -
                        key_or_path = event.payload[:key] || event.payload[:path]
         
     | 
| 
       83 
     | 
    
         
            -
                        {message: "#{method.to_s.humanize} \#{key_or_path}", duration: event.duration}
         
     | 
| 
       84 
     | 
    
         
            -
                      end
         
     | 
| 
       85 
     | 
    
         
            -
                    end
         
     | 
| 
       86 
     | 
    
         
            -
                  METHOD
         
     | 
| 
       87 
     | 
    
         
            -
                end
         
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
                private
         
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
                # Returns the logger for the supplied event.
         
     | 
| 
       92 
     | 
    
         
            -
                # Returns ActionController::Base.logger if no controller is present
         
     | 
| 
       93 
     | 
    
         
            -
                def controller_logger(event)
         
     | 
| 
       94 
     | 
    
         
            -
                  if controller = event.payload[:controller]
         
     | 
| 
       95 
     | 
    
         
            -
                    begin
         
     | 
| 
       96 
     | 
    
         
            -
                      controller.constantize.logger || ActionController::Base.logger
         
     | 
| 
       97 
     | 
    
         
            -
                    rescue NameError
         
     | 
| 
       98 
     | 
    
         
            -
                      ActionController::Base.logger
         
     | 
| 
       99 
     | 
    
         
            -
                    end
         
     | 
| 
       100 
     | 
    
         
            -
                  else
         
     | 
| 
       101 
     | 
    
         
            -
                    ActionController::Base.logger
         
     | 
| 
       102 
     | 
    
         
            -
                  end
         
     | 
| 
       103 
     | 
    
         
            -
                end
         
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
                def extract_path(path)
         
     | 
| 
       106 
     | 
    
         
            -
                  index = path.index('?')
         
     | 
| 
       107 
     | 
    
         
            -
                  index ? path[0, index] : path
         
     | 
| 
       108 
     | 
    
         
            -
                end
         
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
              end
         
     | 
| 
       111 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,28 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'action_controller/log_subscriber'
         
     | 
| 
       2 
     | 
    
         
            -
            ActionController::LogSubscriber
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            module ActionController
         
     | 
| 
       5 
     | 
    
         
            -
              class LogSubscriber
         
     | 
| 
       6 
     | 
    
         
            -
                # Log as info to show Processing messages in production
         
     | 
| 
       7 
     | 
    
         
            -
                def start_processing(event)
         
     | 
| 
       8 
     | 
    
         
            -
                  controller_logger(event).info { "Processing ##{event.payload[:action]}" }
         
     | 
| 
       9 
     | 
    
         
            -
                end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
                private
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
                # Returns the logger for the supplied event.
         
     | 
| 
       14 
     | 
    
         
            -
                # Returns ActionController::Base.logger if no controller is present
         
     | 
| 
       15 
     | 
    
         
            -
                def controller_logger(event)
         
     | 
| 
       16 
     | 
    
         
            -
                  if controller = event.payload[:controller]
         
     | 
| 
       17 
     | 
    
         
            -
                    begin
         
     | 
| 
       18 
     | 
    
         
            -
                      controller.constantize.logger || ActionController::Base.logger
         
     | 
| 
       19 
     | 
    
         
            -
                    rescue NameError
         
     | 
| 
       20 
     | 
    
         
            -
                      ActionController::Base.logger
         
     | 
| 
       21 
     | 
    
         
            -
                    end
         
     | 
| 
       22 
     | 
    
         
            -
                  else
         
     | 
| 
       23 
     | 
    
         
            -
                    ActionController::Base.logger
         
     | 
| 
       24 
     | 
    
         
            -
                  end
         
     | 
| 
       25 
     | 
    
         
            -
                end
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
              end
         
     | 
| 
       28 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,102 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            ActiveRecord::LogSubscriber
         
     | 
| 
       2 
     | 
    
         
            -
            module ActiveRecord
         
     | 
| 
       3 
     | 
    
         
            -
              class LogSubscriber
         
     | 
| 
       4 
     | 
    
         
            -
                # Support Rails 3.2
         
     | 
| 
       5 
     | 
    
         
            -
                IGNORE_PAYLOAD_NAMES = ['SCHEMA', 'EXPLAIN'] unless defined?(IGNORE_PAYLOAD_NAMES)
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
                def sql(event)
         
     | 
| 
       8 
     | 
    
         
            -
                  self.class.runtime += event.duration
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
                  return unless logger.debug?
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
                  payload = event.payload
         
     | 
| 
       13 
     | 
    
         
            -
                  name    = payload[:name]
         
     | 
| 
       14 
     | 
    
         
            -
                  return if IGNORE_PAYLOAD_NAMES.include?(name)
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
                  log_payload = {
         
     | 
| 
       17 
     | 
    
         
            -
                    sql: payload[:sql],
         
     | 
| 
       18 
     | 
    
         
            -
                  }
         
     | 
| 
       19 
     | 
    
         
            -
                  log         = {
         
     | 
| 
       20 
     | 
    
         
            -
                    message:  name,
         
     | 
| 
       21 
     | 
    
         
            -
                    payload:  log_payload,
         
     | 
| 
       22 
     | 
    
         
            -
                    duration: event.duration
         
     | 
| 
       23 
     | 
    
         
            -
                  }
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
                  unless (payload[:binds] || []).empty?
         
     | 
| 
       26 
     | 
    
         
            -
                    log_payload[:binds] =
         
     | 
| 
       27 
     | 
    
         
            -
                      if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR == 0 && Rails::VERSION::TINY <= 2 # 5.0.0 - 5.0.2
         
     | 
| 
       28 
     | 
    
         
            -
                        bind_values_v5_0_0(payload)
         
     | 
| 
       29 
     | 
    
         
            -
                      elsif Rails::VERSION::MAJOR >= 5 && Rails::VERSION::MINOR <= 1 && (Rails::VERSION::MINOR == 0 || Rails::VERSION::TINY <= 4) # 5.0.3 - 5.1.4
         
     | 
| 
       30 
     | 
    
         
            -
                        bind_values_v5_0_3(payload)
         
     | 
| 
       31 
     | 
    
         
            -
                      elsif Rails::VERSION::MAJOR >= 5 # >= 5.1.5
         
     | 
| 
       32 
     | 
    
         
            -
                        bind_values_v5_1_5(payload)
         
     | 
| 
       33 
     | 
    
         
            -
                      elsif Rails.version.to_i >= 4 # 4.x
         
     | 
| 
       34 
     | 
    
         
            -
                        bind_values_v4(payload)
         
     | 
| 
       35 
     | 
    
         
            -
                      else # 3.x
         
     | 
| 
       36 
     | 
    
         
            -
                        bind_values_v3(payload)
         
     | 
| 
       37 
     | 
    
         
            -
                      end
         
     | 
| 
       38 
     | 
    
         
            -
                  end
         
     | 
| 
       39 
     | 
    
         
            -
                  debug(log)
         
     | 
| 
       40 
     | 
    
         
            -
                end
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
                private
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
                def bind_values_v3(payload)
         
     | 
| 
       45 
     | 
    
         
            -
                  binds = {}
         
     | 
| 
       46 
     | 
    
         
            -
                  payload[:binds].each do |col, v|
         
     | 
| 
       47 
     | 
    
         
            -
                    if col
         
     | 
| 
       48 
     | 
    
         
            -
                      add_bind_value(binds, col.name, v)
         
     | 
| 
       49 
     | 
    
         
            -
                    else
         
     | 
| 
       50 
     | 
    
         
            -
                      binds[nil] = v
         
     | 
| 
       51 
     | 
    
         
            -
                    end
         
     | 
| 
       52 
     | 
    
         
            -
                  end
         
     | 
| 
       53 
     | 
    
         
            -
                  binds
         
     | 
| 
       54 
     | 
    
         
            -
                end
         
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
                def bind_values_v4(payload)
         
     | 
| 
       57 
     | 
    
         
            -
                  binds = {}
         
     | 
| 
       58 
     | 
    
         
            -
                  payload[:binds].each do |col, v|
         
     | 
| 
       59 
     | 
    
         
            -
                    attr_name, value = render_bind(col, v)
         
     | 
| 
       60 
     | 
    
         
            -
                    add_bind_value(binds, attr_name, value)
         
     | 
| 
       61 
     | 
    
         
            -
                  end
         
     | 
| 
       62 
     | 
    
         
            -
                  binds
         
     | 
| 
       63 
     | 
    
         
            -
                end
         
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
                def bind_values_v5_0_0(payload)
         
     | 
| 
       66 
     | 
    
         
            -
                  binds = {}
         
     | 
| 
       67 
     | 
    
         
            -
                  payload[:binds].each do |attr|
         
     | 
| 
       68 
     | 
    
         
            -
                    attr_name, value = render_bind(attr)
         
     | 
| 
       69 
     | 
    
         
            -
                    add_bind_value(binds, attr_name, value)
         
     | 
| 
       70 
     | 
    
         
            -
                  end
         
     | 
| 
       71 
     | 
    
         
            -
                  binds
         
     | 
| 
       72 
     | 
    
         
            -
                end
         
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
                def bind_values_v5_0_3(payload)
         
     | 
| 
       75 
     | 
    
         
            -
                  binds         = {}
         
     | 
| 
       76 
     | 
    
         
            -
                  casted_params = type_casted_binds(payload[:binds], payload[:type_casted_binds])
         
     | 
| 
       77 
     | 
    
         
            -
                  payload[:binds].zip(casted_params).map do |attr, value|
         
     | 
| 
       78 
     | 
    
         
            -
                    attr_name, value = render_bind(attr, value)
         
     | 
| 
       79 
     | 
    
         
            -
                    add_bind_value(binds, attr_name, value)
         
     | 
| 
       80 
     | 
    
         
            -
                  end
         
     | 
| 
       81 
     | 
    
         
            -
                  binds
         
     | 
| 
       82 
     | 
    
         
            -
                end
         
     | 
| 
       83 
     | 
    
         
            -
             
     | 
| 
       84 
     | 
    
         
            -
                def bind_values_v5_1_5(payload)
         
     | 
| 
       85 
     | 
    
         
            -
                  binds         = {}
         
     | 
| 
       86 
     | 
    
         
            -
                  casted_params = type_casted_binds(payload[:type_casted_binds])
         
     | 
| 
       87 
     | 
    
         
            -
                  payload[:binds].zip(casted_params).map do |attr, value|
         
     | 
| 
       88 
     | 
    
         
            -
                    attr_name, value = render_bind(attr, value)
         
     | 
| 
       89 
     | 
    
         
            -
                    add_bind_value(binds, attr_name, value)
         
     | 
| 
       90 
     | 
    
         
            -
                  end
         
     | 
| 
       91 
     | 
    
         
            -
                  binds
         
     | 
| 
       92 
     | 
    
         
            -
                end
         
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
                # When multiple values are received for a single bound field, it is converted into an array
         
     | 
| 
       95 
     | 
    
         
            -
                def add_bind_value(binds, key, value)
         
     | 
| 
       96 
     | 
    
         
            -
                  key        = key.downcase.to_sym
         
     | 
| 
       97 
     | 
    
         
            -
                  value      = (Array(binds[key]) << value) if binds.key?(key)
         
     | 
| 
       98 
     | 
    
         
            -
                  binds[key] = value
         
     | 
| 
       99 
     | 
    
         
            -
                end
         
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
     | 
    
         
            -
              end
         
     | 
| 
       102 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,63 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            Rails::Rack::Logger
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            # Replace rack started message with a semantic equivalent
         
     | 
| 
       4 
     | 
    
         
            -
            module Rails
         
     | 
| 
       5 
     | 
    
         
            -
              module Rack
         
     | 
| 
       6 
     | 
    
         
            -
                class Logger
         
     | 
| 
       7 
     | 
    
         
            -
                  @logger = SemanticLogger['Rack']
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
                  def self.logger
         
     | 
| 
       10 
     | 
    
         
            -
                    @logger
         
     | 
| 
       11 
     | 
    
         
            -
                  end
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
                  def call(env)
         
     | 
| 
       14 
     | 
    
         
            -
                    request = ActionDispatch::Request.new(env)
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
                    # Check for named tags (Hash)
         
     | 
| 
       17 
     | 
    
         
            -
                    if @taggers && !@taggers.empty?
         
     | 
| 
       18 
     | 
    
         
            -
                      tags = @taggers.is_a?(Hash) ? compute_named_tags(request) : compute_tags(request)
         
     | 
| 
       19 
     | 
    
         
            -
                      logger.tagged(tags) { call_app(request, env) }
         
     | 
| 
       20 
     | 
    
         
            -
                    else
         
     | 
| 
       21 
     | 
    
         
            -
                      call_app(request, env)
         
     | 
| 
       22 
     | 
    
         
            -
                    end
         
     | 
| 
       23 
     | 
    
         
            -
                  end
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
                  def started_request_message(request)
         
     | 
| 
       26 
     | 
    
         
            -
                    {
         
     | 
| 
       27 
     | 
    
         
            -
                      message: 'Started',
         
     | 
| 
       28 
     | 
    
         
            -
                      payload: {
         
     | 
| 
       29 
     | 
    
         
            -
                        method: request.request_method,
         
     | 
| 
       30 
     | 
    
         
            -
                        path:   request.filtered_path,
         
     | 
| 
       31 
     | 
    
         
            -
                        ip:     request.ip
         
     | 
| 
       32 
     | 
    
         
            -
                      }
         
     | 
| 
       33 
     | 
    
         
            -
                    }
         
     | 
| 
       34 
     | 
    
         
            -
                  end
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
                  private
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
                  def logger
         
     | 
| 
       39 
     | 
    
         
            -
                    self.class.logger
         
     | 
| 
       40 
     | 
    
         
            -
                  end
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
                  # Leave out any named tags with a nil value
         
     | 
| 
       43 
     | 
    
         
            -
                  def compute_named_tags(request) # :doc:
         
     | 
| 
       44 
     | 
    
         
            -
                    tagged = {}
         
     | 
| 
       45 
     | 
    
         
            -
                    @taggers.each_pair do |tag, value|
         
     | 
| 
       46 
     | 
    
         
            -
                      resolved    =
         
     | 
| 
       47 
     | 
    
         
            -
                        case value
         
     | 
| 
       48 
     | 
    
         
            -
                        when Proc
         
     | 
| 
       49 
     | 
    
         
            -
                          value.call(request)
         
     | 
| 
       50 
     | 
    
         
            -
                        when Symbol
         
     | 
| 
       51 
     | 
    
         
            -
                          request.send(value)
         
     | 
| 
       52 
     | 
    
         
            -
                        else
         
     | 
| 
       53 
     | 
    
         
            -
                          value
         
     | 
| 
       54 
     | 
    
         
            -
                        end
         
     | 
| 
       55 
     | 
    
         
            -
                      tagged[tag] = resolved unless resolved.nil?
         
     | 
| 
       56 
     | 
    
         
            -
                    end
         
     | 
| 
       57 
     | 
    
         
            -
                    tagged
         
     | 
| 
       58 
     | 
    
         
            -
                  end
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
                end
         
     | 
| 
       61 
     | 
    
         
            -
              end
         
     | 
| 
       62 
     | 
    
         
            -
            end
         
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
         @@ -1,30 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            Rails::Rack::Logger
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            # Drop rack Started message to debug level message
         
     | 
| 
       4 
     | 
    
         
            -
            module Rails
         
     | 
| 
       5 
     | 
    
         
            -
              module Rack
         
     | 
| 
       6 
     | 
    
         
            -
                class Logger
         
     | 
| 
       7 
     | 
    
         
            -
                  def self.logger
         
     | 
| 
       8 
     | 
    
         
            -
                    @logger
         
     | 
| 
       9 
     | 
    
         
            -
                  end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
                  private
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
                  module LogInfoAsDebug
         
     | 
| 
       14 
     | 
    
         
            -
                    def info(*args, &block)
         
     | 
| 
       15 
     | 
    
         
            -
                      debug(*args, &block)
         
     | 
| 
       16 
     | 
    
         
            -
                    end
         
     | 
| 
       17 
     | 
    
         
            -
                    def info?
         
     | 
| 
       18 
     | 
    
         
            -
                      debug?
         
     | 
| 
       19 
     | 
    
         
            -
                    end
         
     | 
| 
       20 
     | 
    
         
            -
                  end
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
                  def logger
         
     | 
| 
       23 
     | 
    
         
            -
                    self.class.logger
         
     | 
| 
       24 
     | 
    
         
            -
                  end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
                  @logger = SemanticLogger['Rack']
         
     | 
| 
       27 
     | 
    
         
            -
                  @logger.extend(LogInfoAsDebug)
         
     | 
| 
       28 
     | 
    
         
            -
                end
         
     | 
| 
       29 
     | 
    
         
            -
              end
         
     | 
| 
       30 
     | 
    
         
            -
            end
         
     |