code: def _log_function(log, now, pids):
      # Tricky function that decides whether to log as info or debug.
      # Uses lazily assigned log state to determine whether pids have
      # changed or LOG_HEARTBEAT seconds have ellapsed since the last
      # info msg.
      try:
          last_pids = sorted(log.last_pids)
      except AttributeError:
          last_pids = []
      if last_pids != pids:
          log.last_pids = pids
          log.last_log = now
          return log.info
      try:
          last_log = log.last_log
      except AttributeError:
          log.last_log = last_log = now
      if now >= last_log + LOG_HEARTBEAT:
          log.last_log = now
          return log.info
      return log.debug
  
file_path: guildai/guild/commands/shutdown_timer_impl.py
imports: import subprocess
  import time
  import psutil
  from .None import service_impl_support
label_desc: Use image node_id 7 for calling a global function with example usage: _log_function(log, now, pids) and returns: log, log, log