code: def get_logger(
          name, file_name=None, stream=None, template=None, propagate=False):
      
  
      logger = logging.getLogger(name)
  
      if propagate is not None:
          logger.propagate = propagate
  
      for handler in logger.handlers:
          logger.removeHandler(handler)
  
      if not template:
          template = "%(name)s %(process)s %(levelname)s %(message)s"
  
      formatter = logging.Formatter(template)
  
      if not file_name and not stream:
          stream = sys.stdout
  
      handlers = []
  
      if stream is not None:
  
          handlers.append(logging.StreamHandler(stream=stream))
  
      if file_name is not None:
  
          if os.path.isdir(os.path.dirname(file_name)):
              handlers.append(logging.FileHandler(file_name))
          else:
              print("ERROR: Can't open log file {}".format(file_name))
  
      for ch in handlers:
          ch.setFormatter(formatter)
          logger.addHandler(ch)
  
      logger.setLevel(logging.INFO)
  
      return logger
docs: Get a logger by name
  
      if file_name is specified, and the dirname() of the file_name exists, it will
      write to that file. If the dirname dies not exist, it will silently ignre it.