Skip to content

Commit

Permalink
Improved logging for transfer method in Journal class.
Browse files Browse the repository at this point in the history
- Improved formatting of debug message using array.join.
- Improved indenting of comment
  • Loading branch information
flori committed Oct 28, 2024
1 parent 118104c commit c601f5f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lib/acts_as_account/journal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,21 @@ def transfer(amount, from_account, to_account, reference = nil, valuta = Time.no
amount, from_account, to_account = -amount, to_account, from_account
end

logger.debug { "ActsAsAccount::Journal.transfer amount: #{amount} from:#{from_account.id} to:#{to_account.id} reference:#{reference.class.name}(#{reference.id}) valuta:#{valuta}" } if logger
if logger
logger.debug(
[
"ActsAsAccount::Journal.transfer",
"amount: #{amount}",
"from: #{from_account.id}",
"to: #{to_account.id}",
"reference: #{reference.class.name}(#{reference.id})",
"valuta: #{valuta}",
].join(' ')
)
end

# To avoid possible deadlocks we need to ensure that the locking order is always
# the same therfore the sort by id.
# To avoid possible deadlocks we need to ensure that the locking order
# is always the same therfore the sort by id.
if ActsAsAccount.configuration.persist_attributes_on_account
[from_account, to_account].sort_by(&:id).each(&:lock!)
end
Expand Down

0 comments on commit c601f5f

Please sign in to comment.