code: def ConsoleLogHandler(loggerRef='', handler=None, level=logging.DEBUG, color=None):
      
      if isinstance(loggerRef, logging.Logger):
          pass
  
      elif isinstance(loggerRef, str):
          # check for root
          if not loggerRef:
              loggerRef = _log
  
          # check for a valid logger name
          elif loggerRef not in logging.Logger.manager.loggerDict:
              raise RuntimeError("not a valid logger name: %r" % (loggerRef,))
  
          # get the logger
          loggerRef = logging.getLogger(loggerRef)
  
      else:
          raise RuntimeError("not a valid logger reference: %r" % (loggerRef,))
  
      # see if this (or its parent) is a module level logger
      if hasattr(loggerRef, 'globs'):
          loggerRef.globs['_debug'] += 1
      elif hasattr(loggerRef.parent, 'globs'):
          loggerRef.parent.globs['_debug'] += 1
  
      # make a handler if one wasn't provided
      if not handler:
          handler = logging.StreamHandler()
          handler.setLevel(level)
  
      # use our formatter
      handler.setFormatter(LoggingFormatter(color))
  
      # add it to the logger
      loggerRef.addHandler(handler)
  
      # make sure the logger has at least this level
      loggerRef.setLevel(level)
docs: Add a handler to stderr with our custom formatter to a logger.