Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dist-10392 add logging functionality #55

Merged
merged 23 commits into from
Oct 13, 2023

Conversation

mukteshd
Copy link
Contributor

@mukteshd mukteshd commented Aug 8, 2023

Add logging in muffin gem. Use Rails logger if the gem is used in rails app or use default ruby logger
Allow enabling of error and info logging Amazon request and response

1) add request and response logging for finance API call
@@ -15,7 +16,10 @@ def list_financial_event_groups(max_results_per_page = nil, financial_event_grou
end
@query_params["NextToken"] = next_token unless next_token.nil?
@request_type = "GET"
call_api
res = call_api

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add this in call_api so that any api calls can use this and add enableLogging module wise?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

1) move log_request_and_response to enable_logger
module MuffinMan
class MuffinLogger
def self.logger
defined?(Rails) ? Rails.logger : Logger.new($stdout)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of making this gem aware of rails, we can add support for the application using the gem to set a logger. Like how Rails supports doing Rails.logger = Logger.new. To do this you can add :logger as an attr_accessor like we have done for :configuration on this line

  class << self
    attr_accessor :configuration, :logger
  end

Then we can use the logger set by the application if one is set with

MuffinMan.logger.info "a message for the logs"

If no logger is set, I wonder if we default to Logger.new("/dev/null") so that nothing actually gets logged but we can still write code assuming MuffinMan.logger is always set.

@harishpatankar harishpatankar force-pushed the DIST-10392_add_logging_functionality branch 2 times, most recently from 443aa70 to 6793d70 Compare September 5, 2023 06:18
@harishpatankar harishpatankar force-pushed the DIST-10392_add_logging_functionality branch from 6793d70 to 90e6e98 Compare September 5, 2023 08:16
@harishpatankar harishpatankar force-pushed the DIST-10392_add_logging_functionality branch from 28023f5 to 92170cb Compare September 5, 2023 11:15
@harishpatankar harishpatankar force-pushed the DIST-10392_add_logging_functionality branch 2 times, most recently from 28cbd29 to 7898564 Compare September 6, 2023 04:21
@harishpatankar harishpatankar force-pushed the DIST-10392_add_logging_functionality branch from 7898564 to 8aa2fb5 Compare September 6, 2023 04:25
@pp-surbhigupta pp-surbhigupta changed the title Dist 10392 add logging functionality Dist-10392 add logging functionality Oct 9, 2023
@harishpatankar harishpatankar merged commit 71f6529 into master Oct 13, 2023
5 checks passed
@harishpatankar harishpatankar deleted the DIST-10392_add_logging_functionality branch October 13, 2023 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants