code: def get_logger(self, logfilename=None):
          
          if self._logger is None:
              self._logger = logging.getLogger('invenio_upgrader')
              self._logger.setLevel(logging.INFO)
  
              if logfilename:
                  fh = logging.FileHandler(logfilename)
                  fh.setLevel(logging.INFO)
                  fh.setFormatter(self._logger_file_fmtter)
                  self._logger.addHandler(fh)
  
              ch = logging.StreamHandler(sys.stdout)
              ch.setLevel(logging.INFO)
              ch.setFormatter(self._logger_console_fmtter)
  
              self._logger.addHandler(ch)
  
              # Replace show warnings (documented in Python manual)
              def showwarning(message, dummy_category, dummy_filename,
                              dummy_lineno, *dummy_args):
                  self.warning_occured += 1
                  logger = self.get_logger()
                  logger.warning(message)
              warnings.showwarning = showwarning
  
              self._teardown_log_prefix()
  
          return self._logger
docs: Setup logger.
  
          Allow outputting to both a log file and console at the
          same time.