Sha256: a95653564424648e27df3e8d83ab6c260866967647cf24f486d06deb1df0b65b

Contents?: true

Size: 887 Bytes

Versions: 10

Compression:

Stored size: 887 Bytes

Contents

# frozen_string_literal: false

require "logger"
require_relative "../data_filters/log_data_filter"

##
# This Aspect is responsible for logging
# the input and output of every endpoint called
# in the framework.
module LoggingAspect
  def call_endpoint(logger, *args)
    return super(*args) if logger.nil?

    endpoint_name = args[1].split(".")[1..].join("/")
    logger.info(LogDataFilter.sanitize_for_logging(
                  "Request received for #{endpoint_name} with arguments: #{args[2..]}"
                ))

    begin
      response = super(*args)
      logger.info(LogDataFilter.sanitize_for_logging("Response for #{endpoint_name}: #{response}"))
    rescue StandardError => e
      logger.error(
        LogDataFilter.sanitize_for_logging("Error processing #{endpoint_name}: #{e.message}\n#{e.backtrace.join("\n")}")
      )
      raise e
    end

    response
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
macaw_framework-1.2.0 lib/macaw_framework/aspects/logging_aspect.rb
macaw_framework-1.1.8 lib/macaw_framework/aspects/logging_aspect.rb
macaw_framework-1.1.7 lib/macaw_framework/aspects/logging_aspect.rb
macaw_framework-1.1.6 lib/macaw_framework/aspects/logging_aspect.rb
macaw_framework-1.1.5 lib/macaw_framework/aspects/logging_aspect.rb
macaw_framework-1.1.4 lib/macaw_framework/aspects/logging_aspect.rb
macaw_framework-1.1.3 lib/macaw_framework/aspects/logging_aspect.rb
macaw_framework-1.1.2 lib/macaw_framework/aspects/logging_aspect.rb
macaw_framework-1.1.1 lib/macaw_framework/aspects/logging_aspect.rb
macaw_framework-1.1.0 lib/macaw_framework/aspects/logging_aspect.rb