code: def setup_main_logger(
      file_logging=True,
      console=True,
      path: Optional[str] = None,
      level=logging.INFO,
      console_level=None,
  ):
      """
      Configures logging for the main application.
  
      :param file_logging: Whether to log to a file.
      :param console: Whether to log to the console.
      :param path: Optional path to write logfile to.
      :param level: Log level. Default: INFO.
      :param console_level: Optionally specify a separate log level for the console.
      """
      if file_logging and console:
          log_config = LOGGING_CONFIGS["file_console"]  # type: ignore
      elif file_logging:
          log_config = LOGGING_CONFIGS["file_only"]
      elif console:
          log_config = LOGGING_CONFIGS["console_only"]
      else:
          log_config = LOGGING_CONFIGS["none"]
  
      if file_logging:
          assert path is not None, "Must provide a logfile path"
          log_config["handlers"]["rotating"]["filename"] = path  # type: ignore
  
      for _, handler_config in log_config["handlers"].items():  # type: ignore
          handler_config["level"] = level
  
      if "console" in log_config["handlers"] and console_level is not None:  # type: ignore
          log_config["handlers"]["console"]["level"] = console_level  # type: ignore
  
      logging.config.dictConfig(log_config)  # type: ignore
  
      def exception_hook(exc_type, exc_value, exc_traceback):
          logging.exception(
              "Uncaught exception",
              exc_info=(exc_type, exc_value, exc_traceback),
          )
  
      sys.excepthook = exception_hook
  
imports: import logging
  import logging.config
  import sys
  from typing import Optional
label_desc: Use image node_id 1 for calling a global function with example usage: setup_main_logger(file_logging, console, path, level, console_level) without return types