18183: Merge branch 'main' into 18183-revoke-tokens-when-user-is-disabled
[arvados.git] / services / api / lib / log_reuse_info.rb
index 1bf050a777f008d08d223263fab6a6263615beff..5c7efd7ded2e0e28ae0167aa357b0e37df810d5a 100644 (file)
@@ -1,12 +1,20 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
 module LogReuseInfo
   # log_reuse_info logs whatever the given block returns, if
   # log_reuse_decisions is enabled. It accepts a block instead of a
   # string because in some cases constructing the strings involves
-  # doing database queries, and we want to skip those queries when
-  # logging is disabled.
-  def log_reuse_info
-    if Rails.configuration.log_reuse_decisions
-      Rails.logger.info("find_reusable: " + yield)
+  # doing expensive things like database queries, and we want to skip
+  # those when logging is disabled.
+  def log_reuse_info(candidates=nil)
+    if Rails.configuration.Containers.LogReuseDecisions
+      msg = yield
+      if !candidates.nil?
+        msg = "have #{candidates.count} candidates " + msg
+      end
+      Rails.logger.info("find_reusable: " + msg)
     end
   end
 end