Sha256: e56a0670f6b8e12be64bc35421b6f6b0fc3a0311d7ddbaecdb6563c67110b4bf

Contents?: true

Size: 635 Bytes

Versions: 3

Compression:

Stored size: 635 Bytes

Contents

# frozen_string_literal: true

require "logger"

##
# This Aspect is responsible for logging
# the input and output of every endpoint called
# in the framework.
module LoggingAspect
  def call_endpoint(logger, *args)
    endpoint_name = args[1].split(".")[1..].join("/")
    logger.info("Request received for #{endpoint_name} with arguments: #{args[2..]}")

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

    response
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
macaw_framework-1.0.2 lib/macaw_framework/aspects/logging_aspect.rb
macaw_framework-1.0.1 lib/macaw_framework/aspects/logging_aspect.rb
macaw_framework-1.0.0 lib/macaw_framework/aspects/logging_aspect.rb