public static function log($severity, $message) {
    if (!is_int($severity)) {
      throw new \InvalidArgumentException(
        'Parameter $severity must be integer but was ' .
        self::typeOrClass($severity));
    }

    if ($severity < self::LEVEL_DEBUG || $severity > self::LEVEL_CRITICAL) {
      throw new \InvalidArgumentException(
        'Invalid severity level ' . $severity);
    }

    if (!is_string($message)) {
      throw new \InvalidArgumentException(
        'Parameter $message must be string but was ' .
        self::typeOrClass($message));
    }

    if (!isset(self::$app_log_group)) {
      self::$app_log_group = new UserAppLogGroup();
    }

    $app_log_line = self::$app_log_group->addLogLine();
    $app_log_line->setTimestampUsec(intval(microtime(true) * 1e6));
    $app_log_line->setLevel($severity);
    $app_log_line->setMessage($message);

    if (function_exists('_gae_stderr_log')) {
      _gae_stderr_log($severity, $message);
    }

    self::flushIfNeeded();
  }