This repository has been archived by the owner on Nov 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a status servlet to show you whether mache can successfully retri…
…eve logs
- Loading branch information
1 parent
7901044
commit a6086f5
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
src/com/streak/logging/analysis/TestLogsAccessibleServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.streak.logging.analysis; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import com.google.appengine.api.log.LogQuery; | ||
import com.google.appengine.api.log.LogService; | ||
import com.google.appengine.api.log.LogServiceFactory; | ||
import com.google.appengine.api.log.RequestLogs; | ||
|
||
public class TestLogsAccessibleServlet extends HttpServlet { | ||
|
||
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { | ||
resp.setContentType("text/plain"); | ||
|
||
String exporterSetClassStr = AnalysisUtility.extractParameterOrThrow(req, AnalysisConstants.BIGQUERY_FIELD_EXPORTER_SET_PARAM); | ||
BigqueryFieldExporterSet exporterSet = AnalysisUtility.instantiateExporterSet(exporterSetClassStr); | ||
|
||
LogService ls = LogServiceFactory.getLogService(); | ||
LogQuery lq = new LogQuery(); | ||
long currMillis = System.currentTimeMillis(); | ||
lq = lq.startTimeUsec((currMillis - 5 * 60 * 1000) * 1000) | ||
.endTimeUsec(currMillis * 1000) | ||
.includeAppLogs(true); | ||
|
||
|
||
List<String> appVersions = exporterSet.applicationVersionsToExport(); | ||
if (appVersions != null) { | ||
lq = lq.majorVersionIds(appVersions); | ||
} | ||
|
||
Iterable<RequestLogs> logs = ls.fetch(lq); | ||
|
||
for (RequestLogs rl : logs) { | ||
resp.getWriter().println(rl.getCombined() + "\n"); | ||
} | ||
|
||
} | ||
} |