code: def setup_logger(log_level, log_file=None):
      
      level = getattr(logging, log_level.upper(), None)
      if not level:
          color_print("Invalid log level: %s" % log_level, "RED")
          sys.exit(1)
  
      # hide traceback when log level is INFO/WARNING/ERROR/CRITICAL
      if level >= logging.INFO:
          sys.tracebacklimit = 0
  
      formatter = ColoredFormatter(
          u"%(log_color)s%(bg_white)s%(levelname)-8s%(reset)s %(message)s",
          datefmt=None,
          reset=True,
          log_colors=log_colors_config
      )
  
      if log_file:
          handler = logging.FileHandler(log_file, encoding="utf-8")
      else:
          handler = logging.StreamHandler()
  
      handler.setFormatter(formatter)
      logger.addHandler(handler)
      logger.setLevel(level)
docs: setup root logger with ColoredFormatter.