Improve logging

This commit is contained in:
Karl Erik Õunapuu 2020-09-03 16:42:04 +03:00
parent 11fc484270
commit bbbb3d5367
No known key found for this signature in database
GPG key ID: C9DD647298A34764
5 changed files with 8 additions and 17 deletions

View file

@ -12,7 +12,7 @@ module Concerns
def archivable?(post: false)
inactive = inactive?
log("Found archivable contact id(#{id}), code (#{code})") if inactive && !post
puts "Found archivable contact id(#{id}), code (#{code})" if inactive && !post
inactive
end
@ -38,11 +38,6 @@ module Concerns
def inactivity_period
Setting.orphans_contacts_in_months.months
end
def log(msg)
@logger ||= Logger.new(STDOUT)
@logger.info(msg)
end
end
end
end

View file

@ -7,15 +7,9 @@ class InactiveContacts
def archive(verified: false)
contacts.each do |contact|
log("Archiving contact: id(#{contact.id}), code(#{contact.code})")
puts "Archiving contact: id(#{contact.id}), code(#{contact.code})"
contact.archive(verified: verified)
yield contact if block_given?
end
end
def log(msg)
@logger ||= Logger.new(STDOUT)
@logger.info(msg)
end
end