Logging In Loop (ARCH6164)
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Key ruby.logging.logging-in-loop · Severity info · Category logging
Log statements inside a loop body can flood log sinks with thousands of lines on large collections. This buries real signal in noise.
Incorrect
Section titled “Incorrect”orders.each do |order| Rails.logger.info("Processing order", order_id: order.id) process(order)endCorrect
Section titled “Correct”orders.each { |order| process(order) }Rails.logger.info("Processed orders", count: orders.size)Summarize log calls outside the loop, or log only failures inside it.