Skip to content

Commit 012a78c

Browse files
authored
refactor: use slog style (#213)
1 parent 3f42aa1 commit 012a78c

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

lib/miteru/crawler.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ class Crawler < Service
99
#
1010
def call(website)
1111
Try[OpenSSL::SSL::SSLError, ::HTTP::Error, Addressable::URI::InvalidURIError] do
12-
info = "Website:#{website.info}."
13-
info = info.colorize(:red) if website.kits?
14-
logger.info(info)
12+
log_message = "Website:#{website.defanged_truncated_url}"
13+
log_message.colorize(:red) if website.kits?
14+
logger.info(log_message, kits: website.kits.length, source: website.source)
1515

1616
website.kits.each do |kit|
1717
downloader = Downloader.new(kit)
1818
result = downloader.result
1919
unless result.success?
20-
logger.warn("Kit:#{kit.truncated_url} failed to download - #{result.failure}.")
20+
logger.warn("Kit:#{kit.truncated_url} failed to download.", failure: result.failure)
2121
next
2222
end
2323
destination = result.value!
24-
logger.info("Kit:#{kit.truncated_url} downloaded as #{destination}.")
24+
logger.info("Kit:#{kit.truncated_url} downloaded.", dest: destination)
2525
# Remove downloaded file if auto_download is not allowed
2626
FileUtils.rm(destination, force: true) unless auto_download?
2727
# Notify the kit
@@ -44,7 +44,7 @@ def notify(kit)
4444
if result.success?
4545
logger.info("Notifier:#{notifier.name} succeeded.")
4646
else
47-
logger.warn("Notifier:#{notifier.name} failed - #{result.failure}.")
47+
logger.warn("Notifier:#{notifier.name} failed.", failure: result.failure)
4848
end
4949
end
5050
end

lib/miteru/orchestrator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ def websites
1717
result = feed.result
1818
if result.success?
1919
websites = result.value!
20-
logger.info("Feed:#{feed.source} has #{websites.length} websites.") if verbose?
20+
logger.info("Feed:#{feed.source} downloaded.", websites: websites.length) if verbose?
2121
out << websites
2222
else
23-
logger.warn("Feed:#{feed.source} failed - #{result.failure}")
23+
logger.warn("Feed:#{feed.source} failed.", failure: result.failure)
2424
end
2525
end
2626
end.flatten.uniq(&:url)

lib/miteru/sidekiq/jobs.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def perform(url, source)
2222
if result.success?
2323
Miteru.logger.info("Crawler:#{website.truncated_url} succeeded.")
2424
else
25-
Miteru.logger.info("Crawler:#{website.truncated_url} failed - #{result.failure}.")
25+
Miteru.logger.info("Crawler:#{website.truncated_url} failed", failure: result.failure)
2626
end
2727
end
2828
end

0 commit comments

Comments
 (0)