Sha256: 365eddd277ce7dfb3483b9117bef1a35b2253322d73e4e5946c11447ae7e0cd6

Contents?: true

Size: 620 Bytes

Versions: 7

Compression:

Stored size: 620 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("Request received for [#{endpoint_name}] from [#{args[-1]}]")

    begin
      response = super(*args)
    rescue StandardError => e
      logger.error("#{e.message}\n#{e.backtrace.join("\n")}")
      raise e
    end

    response
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
macaw_framework-1.3.0 lib/macaw_framework/aspects/logging_aspect.rb
macaw_framework-1.2.6 lib/macaw_framework/aspects/logging_aspect.rb
macaw_framework-1.2.5 lib/macaw_framework/aspects/logging_aspect.rb
macaw_framework-1.2.4 lib/macaw_framework/aspects/logging_aspect.rb
macaw_framework-1.2.3 lib/macaw_framework/aspects/logging_aspect.rb
macaw_framework-1.2.2 lib/macaw_framework/aspects/logging_aspect.rb
macaw_framework-1.2.1 lib/macaw_framework/aspects/logging_aspect.rb