From 5a7426cfbd04bccf276a964e7c9ac5a6032cde8b Mon Sep 17 00:00:00 2001 From: Eduardo Candanedo Date: Fri, 16 Feb 2024 15:16:41 -0600 Subject: [PATCH] Logger configuration --- lib/use_paragon/base.rb | 7 ++++--- lib/use_paragon/configuration.rb | 6 +++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/use_paragon/base.rb b/lib/use_paragon/base.rb index de36d17..ae0168c 100644 --- a/lib/use_paragon/base.rb +++ b/lib/use_paragon/base.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -require "jwt" require "faraday" -require "use_paragon/configuration" +require "jwt" module UseParagon # Basic logic for interacting with UseParagon platform @@ -40,7 +39,9 @@ def connection conn.request :authorization, "Bearer", generate_token conn.request :json - conn.response :logger, Rails.logger, { errors: true, bodies: true } if config.logger_enabled + if config.logger_enabled + conn.response :logger, config.logger, { errors: true, bodies: true } + end conn.response :json, content_type: "application/json" conn.response :raise_error diff --git a/lib/use_paragon/configuration.rb b/lib/use_paragon/configuration.rb index 8f50ef3..6616870 100644 --- a/lib/use_paragon/configuration.rb +++ b/lib/use_paragon/configuration.rb @@ -1,12 +1,16 @@ # frozen_string_literal: true +require "logger" + module UseParagon # Allows configuration using an initializer class Configuration - attr_accessor :private_key, :project_id, :base_url, :logger_enabled + attr_accessor :private_key, :project_id, :base_url, :logger, :logger_enabled def initialize @base_url = "https://zeus.useparagon.com" + @logger = Logger.new(STDOUT) + @logger_enabled = true end end end