Module: LoggingAspect
- Included in:
- ServerBase
- Defined in:
- lib/macaw_framework/aspects/logging_aspect.rb
Overview
This Aspect is responsible for logging the input and output of every endpoint called in the framework.
Instance Method Summary collapse
Instance Method Details
#call_endpoint(logger, *args, **kwargs) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/macaw_framework/aspects/logging_aspect.rb', line 11 def call_endpoint(logger, *args, **kwargs) return super(*args, **kwargs) if logger.nil? endpoint_name = args[1] client_data = args[2] logger.info("Calling endpoint: #{endpoint_name} | " \ "params: #{LogDataFilter.sanitize_for_logging(client_data[:params].to_s)} | " \ "body: #{LogDataFilter.sanitize_for_logging(client_data[:body])}") begin response = super(*args, **kwargs) rescue StandardError => e logger.error("#{e.message}\n#{e.backtrace.join("\n")}") raise e end logger.info("Response from endpoint: #{endpoint_name} | status: #{response&.dig(1)}") response end |