Skip to content

Commit

Permalink
ensure path to logger exists
Browse files Browse the repository at this point in the history
This should fix specs that are failing in CI
  • Loading branch information
bkiahstroud committed Apr 23, 2024
1 parent b620521 commit 71683a0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/services/ams/asset_destroyer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class AssetDestroyer
def initialize(asset_ids: [], user_email: nil)
@asset_ids = Array(asset_ids)
@user_email = user_email
@logger = Logger.new(Rails.root.join('tmp', 'imports', 'asset_destroyer.log'))
@logger = setup_logger
end

def destroy(asset_ids)
Expand Down Expand Up @@ -117,5 +117,12 @@ def error_rescue(error, object_type, id)
msg += ": #{error.message}" unless error.message.empty?
logger.error "Error destroying '#{object_type}' for '#{id}'. #{msg}"
end

def setup_logger
logger_path = Rails.root.join('tmp', 'imports', 'asset_destroyer.log')
FileUtils.mkdir_p(logger_path.dirname)

Logger.new(logger_path)
end
end
end

0 comments on commit 71683a0

Please sign in to comment.