Sha256: 2ddf39b16312cd73c41d6d6be6d68492df31a58ec4ffe6f6d0f082e7094dc57f

Contents?: true

Size: 1.1 KB

Versions: 63

Compression:

Stored size: 1.1 KB

Contents

# require "eitil_wrapper/request_logger/controller_mixin"

require_relative "logger_job"

module EitilWrapper
  module RequestLogger
    module ControllerMixin

      private

      def log_request
        $request_logger_path ||= "#{Rails.root}/log/request_logger.log"
        EitilWrapper::RequestLogger::LoggerJob.perform_later(request_logger_object)
      end
      
      def request_logger_object
        
        log_request = {
          path:       request.env["REQUEST_PATH"],
          method:     request.env["REQUEST_METHOD"],
          query_str:  request.env["QUERY_STRING"], 
        }
       
        log_params = {
          params:     params.as_json
        }

        log_attributes = {
          time:       Time.now.strftime("%Y-%m-%d %H:%M:%S")
        }

        log = {
          request:    log_request,
          params:     log_params,
          attributes: log_attributes
        }

        log_time = log_attributes[:time]
        log_strf = log.deep_symbolize_keys.to_s   
        # log_strf may be hashed through eval(log_strf)

        return log_strf
      end    
   
    end
  end
end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
eitil-1.1.2 eitil_wrapper/lib/eitil_wrapper/request_logger/controller_mixin.rb
eitil-1.1.1 eitil_wrapper/lib/eitil_wrapper/request_logger/controller_mixin.rb
eitil-1.1.0 eitil_wrapper/lib/eitil_wrapper/request_logger/controller_mixin.rb