code: def emit(self, record):
          
          try:
              # Check logging.LogRecord properties for lots of other goodies
              # like line number etc. you can get from the log message.
              QgsMessageLog.logMessage(record.getMessage(), 'InaSAFE', 0)
          except MemoryError:
              message = tr(
                  'Due to memory limitations on this machine, InaSAFE can not '
                  'handle the full log')
              print(message)
              QgsMessageLog.logMessage(message, 'InaSAFE', 0)
docs: Try to log the message to QGIS if available, otherwise do nothing.
  
          :param record: logging record containing whatever info needs to be
                  logged.