Refactor logging across controllers and jobs to use a centralized log method; improve consistency and readability of log messages

This commit is contained in:
2026-02-27 22:32:07 -05:00
parent f32b48296d
commit 9c0f153518
10 changed files with 107 additions and 31 deletions

View File

@@ -27,7 +27,7 @@ class Estimate < ActiveRecord::Base
# sync only one estimate
def self.sync_by_id(id)
logger.info "Syncing estimate #{id}"
log "Syncing estimate #{id}"
qbo = Qbo.first
qbo.perform_authenticated_request do |access_token|
service = Quickbooks::Service::Estimate.new(company_id: qbo.realm_id, access_token: access_token)
@@ -37,7 +37,7 @@ class Estimate < ActiveRecord::Base
# sync only one estimate
def self.sync_by_doc_number(number)
logger.info "Syncing estimate by doc number #{number}"
log "Syncing estimate by doc number #{number}"
qbo = Qbo.first
qbo.perform_authenticated_request do |access_token|
service = Quickbooks::Service::Estimate.new(company_id: qbo.realm_id, access_token: access_token)
@@ -63,7 +63,7 @@ class Estimate < ActiveRecord::Base
# process an estimate into the database
def self.process_estimate(qbo_estimate)
logger.info "Processing estimate #{qbo_estimate.id}"
log "Processing estimate #{qbo_estimate.id}"
estimate = find_or_create_by(id: qbo_estimate.id)
estimate.doc_number = qbo_estimate.doc_number
estimate.customer_id = qbo_estimate.customer_ref.value
@@ -115,5 +115,9 @@ class Estimate < ActiveRecord::Base
@details = Quickbooks::Model::Estimate.new
end
end
def log(msg)
Rails.logger.info "[Estimate] #{msg}"
end
end