Skip to content

Commit

Permalink
DIST-10392 Moved method creation in muffinman module
Browse files Browse the repository at this point in the history
  • Loading branch information
harishpatankar committed Sep 5, 2023
1 parent 90e6e98 commit 92170cb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
14 changes: 12 additions & 2 deletions lib/muffin_man.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
require "muffin_man/feeds/v20210630"
require "muffin_man/notifications/v1"
require "muffin_man/merchant_fulfillment/v0"
require "muffin_man/muffin_logger"
require "logger"

module MuffinMan
class Error < StandardError; end
Expand All @@ -35,14 +35,24 @@ def initialize(auth_response)
end

class << self
attr_accessor :configuration, :logger
attr_accessor :configuration, :log
end

def self.configure
self.configuration ||= Configuration.new
yield(configuration)
end

def self.logger
self.log ||= Logger.new($stdout)
end

%i[debug info warn error fatal].each do |level|
define_method(level) do |message|
MuffinLogger.log.send(level, message)
end
end

class Configuration
attr_accessor :save_access_token, :get_access_token
end
Expand Down
2 changes: 1 addition & 1 deletion lib/muffin_man/enable_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def log_request_and_response(level, res)
response_headers=#{res.headers}\n\n
response_body=#{res.body}\n\n
"
MuffinLogger.logger.send(level, log_info)
MuffinMan.logger.send(level, log_info)
end
end
end
16 changes: 8 additions & 8 deletions lib/muffin_man/muffin_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
require "logger"
module MuffinMan
class MuffinLogger
def self.logger
defined?(Rails) ? Rails.logger : Logger.new($stdout)
end
# def self.logger
# defined?(Rails) ? Rails.logger : Logger.new($stdout)
# end

%i[debug info warn error fatal].each do |level|
define_method(level) do |message|
MuffinLogger.logger.send(level, message)
end
end
# %i[debug info warn error fatal].each do |level|
# define_method(level) do |message|
# MuffinLogger.logger.send(level, message)
# end
# end
end
end

0 comments on commit 92170cb

Please sign in to comment.