Exemple #1
0
def LogsBuffer(stream=None, stderr=False, force_var_log=False):

    if features.IsEnabled('LogsFileBuffer') or force_var_log:
        return _LogsFileBuffer()
    elif stream or stderr or not features.IsEnabled('LogsDequeBuffer'):
        return _LogsStreamBuffer(stream, stderr)
    else:
        return _LogsDequeBuffer()
  def emit(self, record):
    """Emit a record.

    This implementation is based on the implementation of
    StreamHandler.emit().

    Args:
      record: A Python logging.LogRecord object.
    """
    try:
      if features.IsEnabled("LogServiceWriteRecord"):
        logservice.write_record(self._AppLogsLevel(record.levelno),
                                record.created,
                                self.format(record),
                                self._AppLogsLocation(record))
      else:
        message = self._AppLogsMessage(record)
        if isinstance(message, unicode):
          message = message.encode("UTF-8")


        logservice.write(message)
    except (KeyboardInterrupt, SystemExit, runtime.DeadlineExceededError):
      raise
    except:
      self.handleError(record)
Exemple #3
0
def LogsBuffer(stream=None, stderr=False):


  if stream or stderr or not features.IsEnabled('LogsDequeBuffer'):
    return _LogsStreamBuffer(stream, stderr)
  else:
    return _LogsDequeBuffer()
Exemple #4
0
    def _AppLogsLocation(self, record):
        """Find the source location responsible for calling the logging API."""
        if not features.IsEnabled("LogsWriteSourceLocation"):
            return None

        return (getattr(record, "pathname",
                        None), getattr(record, "lineno",
                                       None), getattr(record, "funcName",
                                                      None))
Exemple #5
0
  def _AppLogsLocation(self):
    """Find the source location responsible for calling the logging API."""
    if not features.IsEnabled("LogsWriteSourceLocation"):
      return None

    def IsLogging(f):
      return f.f_code.co_filename.endswith("/logging/__init__.py")

    f = inspect.currentframe()
    while f and not IsLogging(f):
      f = f.f_back
    while f and IsLogging(f):
      f = f.f_back
    return inspect.getframeinfo(f)[:3] if f else None
Exemple #6
0
    def emit(self, record):
        """Emit a record.

    This implementation is based on the implementation of
    StreamHandler.emit()."""
        try:
            if features.IsEnabled("LogServiceWriteRecord"):
                logservice.write_record(self._AppLogsLevel(record.levelno),
                                        record.created, self.format(record))
            else:
                message = self._AppLogsMessage(record)
                logservice.write(message)
        except (KeyboardInterrupt, SystemExit, runtime.DeadlineExceededError):
            raise
        except:
            self.handleError(record)
Exemple #7
0
from google.appengine.runtime import apiproxy_errors
from google.appengine.runtime import features





ENTITY_ACTIONS = {
    'Copy to Another App': copy_handler.ConfirmCopyHandler.Render,
    'Delete Entities': delete_handler.ConfirmDeleteHandler.Render,
    'Backup Entities': backup_handler.ConfirmBackupHandler.Render,
}



if features.IsEnabled('DisableDatastoreAdminCopyToAnotherApp'):
  del ENTITY_ACTIONS['Copy to Another App']


BACKUP_ACTIONS = {
    'Delete': backup_handler.ConfirmDeleteBackupHandler.Render,
    'Restore': backup_handler.ConfirmRestoreFromBackupHandler.Render,
    'Info': backup_handler.BackupInformationHandler.Render,
}

PENDING_BACKUP_ACTIONS = {
    'Abort': backup_handler.ConfirmAbortBackupHandler.Render,
    'Info': backup_handler.BackupInformationHandler.Render,
}

GET_ACTIONS = ENTITY_ACTIONS.copy()