Skip to content

Commit

Permalink
Use tagged logging
Browse files Browse the repository at this point in the history
  • Loading branch information
vladyio committed Sep 26, 2024
1 parent 5600801 commit aa68f87
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/jobs/download_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def perform(link)

ActionCable.server.broadcast "download_#{jid}", { status: :complete, message: file_path }
rescue YoutubeDownload::DownloadError, StandardError => e
Rails.logger.error "[YoutubeDownload (#{link})] #{e.message}"
Rails.logger.tagged(self.class.name, link).error(e.message)

ActionCable.server.broadcast "download_#{jid}", { status: :error, message: e.message }
end
Expand Down
8 changes: 5 additions & 3 deletions lib/dl_cleanup.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
require 'fileutils'
# frozen_string_literal: true

require "fileutils"

class DlCleanup
def self.call
dl_dir = Rails.root.join('public', 'dl')
dl_dir = Rails.root.join("public", "dl")
FileUtils.rm_rf(dl_dir)

Rails.logger.info "[#{__FILE__}] Removed all files from #{dl_dir}"
Rails.logger.tagged("Cleaner").info "[#{__FILE__}] Removed all files from #{dl_dir}"
end
end

0 comments on commit aa68f87

Please sign in to comment.