当前位置: 首页>>代码示例>>Java>>正文


Java RequestLogs.getStartTimeUsec方法代码示例

本文整理汇总了Java中com.google.appengine.api.log.RequestLogs.getStartTimeUsec方法的典型用法代码示例。如果您正苦于以下问题:Java RequestLogs.getStartTimeUsec方法的具体用法?Java RequestLogs.getStartTimeUsec怎么用?Java RequestLogs.getStartTimeUsec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.appengine.api.log.RequestLogs的用法示例。


在下文中一共展示了RequestLogs.getStartTimeUsec方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testStartAndEndTimeUsec

import com.google.appengine.api.log.RequestLogs; //导入方法依赖的package包/类
@Test
@InSequence(20)
public void testStartAndEndTimeUsec() throws Exception {
    RequestLogs requestLogs1 = getRequestLogs1();

    long time1 = getTime(1);
    long time2 = getTime(2);
    long startTimeUsec = requestLogs1.getStartTimeUsec();
    assertTrue("expected startTimeUsec to be >= " + time1 + ", but was " + startTimeUsec, startTimeUsec >= time1);
    assertTrue("expected startTimeUsec to be <= " + time2 + ", but was " + startTimeUsec, startTimeUsec <= time2);

    long endTimeUsec = requestLogs1.getEndTimeUsec();
    assertTrue("expected endTimeUsec to be >= " + time1 + ", but was " + endTimeUsec, endTimeUsec >= time1);
    assertTrue("expected endTimeUsec to be <= " + time2 + ", but was " + endTimeUsec, endTimeUsec <= time2);

    assertTrue("expected endTimeUsec to be more than startTimeUsec, but it wasn't (startTime was " + startTimeUsec + "; endTime was " + endTimeUsec, startTimeUsec < endTimeUsec);
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:18,代码来源:RequestLogsTest.java

示例2: doGet

import com.google.appengine.api.log.RequestLogs; //导入方法依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
       throws IOException {

  resp.setContentType("text/html");
  PrintWriter writer = resp.getWriter();
  writer.println("<!DOCTYPE html>");
  writer.println("<meta charset=\"utf-8\">");
  writer.println("<title>App Engine Logs Sample</title>");

  // We use this to break out of our iteration loop, limiting record
  // display to 5 request logs at a time.
  int limit = 5;

  // This retrieves the offset from the Next link upon user click.
  String offset = req.getParameter("offset");

  // We want the App logs for each request log
  LogQuery query = LogQuery.Builder.withDefaults();
  query.includeAppLogs(true);

  // Set the offset value retrieved from the Next link click.
  if (offset != null) {
    query.offset(offset);
  }

  // This gets filled from the last request log in the iteration
  String lastOffset = null;
  int count = 0;

  // Display a few properties of each request log.
  for (RequestLogs record : LogServiceFactory.getLogService().fetch(query)) {
    writer.println("<br>REQUEST LOG <br>");
    DateTime reqTime = new DateTime(record.getStartTimeUsec() / 1000);
    writer.println("IP: " + record.getIp() + "<br>");
    writer.println("Method: " + record.getMethod() + "<br>");
    writer.println("Resource " + record.getResource() + "<br>");
    writer.println(String.format("<br>Date: %s", reqTime.toString()));

    lastOffset = record.getOffset();

    // Display all the app logs for each request log.
    for (AppLogLine appLog : record.getAppLogLines()) {
      writer.println("<br>" + "APPLICATION LOG" + "<br>");
      DateTime appTime = new DateTime(appLog.getTimeUsec() / 1000);
      writer.println(String.format("<br>Date: %s", appTime.toString()));
      writer.println("<br>Level: " + appLog.getLogLevel() + "<br>");
      writer.println("Message: " + appLog.getLogMessage() + "<br> <br>");
    }

    if (++count >= limit) {
      break;
    }
  }

  // When the user clicks this link, the offset is processed in the
  // GET handler and used to cycle through to the next 5 request logs.
  writer.println(String.format("<br><a href=\"/?offset=%s\">Next</a>", lastOffset));
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:60,代码来源:LogsServlet.java

示例3: doGet

import com.google.appengine.api.log.RequestLogs; //导入方法依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {

  resp.setContentType("text/html");
  PrintWriter writer = resp.getWriter();
  writer.println("<!DOCTYPE html>");
  writer.println("<meta charset=\"utf-8\">");
  writer.println("<title>App Engine Logs Sample</title>");

  // We use this to break out of our iteration loop, limiting record
  // display to 5 request logs at a time.
  int limit = 5;

  // This retrieves the offset from the Next link upon user click.
  String offset = req.getParameter("offset");

  // We want the App logs for each request log
  LogQuery query = LogQuery.Builder.withDefaults();
  query.includeAppLogs(true);

  // Set the offset value retrieved from the Next link click.
  if (offset != null) {
    query.offset(offset);
  }

  // This gets filled from the last request log in the iteration
  String lastOffset = null;
  int count = 0;

  // Display a few properties of each request log.
  for (RequestLogs record : LogServiceFactory.getLogService().fetch(query)) {
    writer.println("<br>REQUEST LOG <br>");
    DateTime reqTime = new DateTime(record.getStartTimeUsec() / 1000);
    writer.println("IP: " + record.getIp() + "<br>");
    writer.println("Method: " + record.getMethod() + "<br>");
    writer.println("Resource " + record.getResource() + "<br>");
    writer.println(String.format("<br>Date: %s", reqTime.toString()));

    lastOffset = record.getOffset();

    // Display all the app logs for each request log.
    for (AppLogLine appLog : record.getAppLogLines()) {
      writer.println("<br>" + "APPLICATION LOG" + "<br>");
      DateTime appTime = new DateTime(appLog.getTimeUsec() / 1000);
      writer.println(String.format("<br>Date: %s", appTime.toString()));
      writer.println("<br>Level: " + appLog.getLogLevel() + "<br>");
      writer.println("Message: " + appLog.getLogMessage() + "<br> <br>");
    }

    if (++count >= limit) {
      break;
    }
  }

  // When the user clicks this link, the offset is processed in the
  // GET handler and used to cycle through to the next 5 request logs.
  writer.println(String.format("<br><a href=\"/?offset=%s\">Next</a>", lastOffset));
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:59,代码来源:LogsServlet.java

示例4: processLog

import com.google.appengine.api.log.RequestLogs; //导入方法依赖的package包/类
@Override
public void processLog(RequestLogs log) {
	timestamp = log.getStartTimeUsec();
}
 
开发者ID:steveseo,项目名称:l2bq,代码行数:5,代码来源:TimestampFieldExporter.java


注:本文中的com.google.appengine.api.log.RequestLogs.getStartTimeUsec方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。