class_docstr: Allowed patching a stream into the logger.
  Used for capturing and logging stdin and stderr when running in development mode pseudo worker.
class_docstr_tok: ["Allowed","patching","a","stream","into","the","logger",".","Used","for","capturing","and","logging","stdin","and","stderr","when","running","in","development","mode","pseudo","worker","."]
code: def connect(self, logger):
      # refresh if needed
      if PrintPatchLogger.cr_flush_period is None:
          PrintPatchLogger.cr_flush_period = config.get(
              "development.worker.console_cr_flush_period", 0
          )
  
      # if we had a previous log object, call flush before switching
      if self._log and hasattr(self._log, "_flush_into_logger"):
          # since we are not sure how flush should be called, we protect it
          # noinspection PyBroadException
          try:
              # noinspection PyProtectedMember
              self._log._flush_into_logger(a_future_func=logger)
          except Exception:
              pass
  
      self._cur_line = ""
      self._log = logger
  
imports: import logging
  import sys
  from time import time
  from ..binding.frameworks import _patched_call
  from ..config import running_remotely, config, DEBUG_SIMULATE_REMOTE_TASK
  from ..utilities.process.mp import ForkSafeRLock
label_desc: Use image node_id 3 for calling the PrintPatchLogger obj's underlying member method code with example usage: obj.connect(logger) without return types