docstr: Redirects all registered std logging handlers to a loguru sink.
  Call init_logger() on fastapi startup.
docstr_tok: ["Redirects","all","registered","std","logging","handlers","to","a","loguru","sink",".","Call","init_logger","(",")","on","fastapi","startup","."]
code: def init_logger(self) -> None:
      """
      Redirects all registered std logging handlers to a loguru sink.
      Call init_logger() on fastapi startup.
      """
      intercept_handler = InterceptHandler()
  
      # Generalizes log level for all root loggers, including third party
      logging.root.setLevel(self.config.LOGURU_LEVEL)
      logging.root.handlers = [intercept_handler]
  
      for log in logging.root.manager.loggerDict.keys():
          log_instance = logging.getLogger(log)
          log_instance.handlers = []
          log_instance.propagate = True
  
      logger.configure(
          handlers=[
              {
                  "sink": sys.stdout,
                  "level": self.config.LOGURU_LEVEL,
                  "serialize": self.config.LOGURU_SERIALIZE,
                  "format": self.format_record,
              }
          ],
      )
  
      try:
          if (
              self.config.LOGURU_SINK
              is not ("sys.stdout" or "sys.stderr")
              and self.config.LOGURU_SINK is not None
          ):
              logger.add(
                  self.config.LOGURU_SINK,
                  retention=self.config.LOGURU_RETENTION,
                  rotation=self.config.LOGURU_ROTATION,
                  compression=self.config.LOGURU_COMPRESSION,
              )
              logger.debug(f"Logging to {self.config.LOGURU_SINK}")
  
      except Exception as err:
          logger.debug(
              f"Failed creating a new sink. Check your log config. error: {err}"
          )
  
file_path: PySyft/packages/grid/backend/grid/logger/handler.py
imports: from __future__ import annotations
  from functools import lru_cache
  import logging
  from pprint import pformat
  import sys
  import loguru
  from loguru import logger
  from .config import get_log_config
label_desc: Use image node_id 3 for calling the LogHandler obj's underlying member method code with example usage: obj.init_logger() without return types