From 7684caf2104d94e4247e9545241caee2c8a4abd2 Mon Sep 17 00:00:00 2001 From: Les Vogel <lesv@users.noreply.github.com> Date: Thu, 1 Mar 2018 10:10:31 -0800 Subject: [PATCH] Remove logs sample (#1039) --- appengine-java8/logs/README.md | 21 ---- appengine-java8/logs/pom.xml | 91 ---------------- .../example/appengine/logs/LogsServlet.java | 100 ------------------ .../src/main/webapp/WEB-INF/appengine-web.xml | 22 ---- .../main/webapp/WEB-INF/logging.properties | 14 --- appengine-java8/pom.xml | 1 - 6 files changed, 249 deletions(-) delete mode 100644 appengine-java8/logs/README.md delete mode 100644 appengine-java8/logs/pom.xml delete mode 100644 appengine-java8/logs/src/main/java/com/example/appengine/logs/LogsServlet.java delete mode 100644 appengine-java8/logs/src/main/webapp/WEB-INF/appengine-web.xml delete mode 100644 appengine-java8/logs/src/main/webapp/WEB-INF/logging.properties diff --git a/appengine-java8/logs/README.md b/appengine-java8/logs/README.md deleted file mode 100644 index 8e8f2d5ea59..00000000000 --- a/appengine-java8/logs/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# Users Authentication sample for Google App Engine - -<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=appengine-java8/logs/README.md"> -<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a> - -This sample demonstrates how to use the [Logs API][log-docs] on [Google App -Engine][ae-docs]. - -[log-docs]: https://cloud.google.com/appengine/docs/java/logs/ -[ae-docs]: https://cloud.google.com/appengine/docs/java/ - -## Running locally - -The Logs API only generates output for deployed apps, so this program should not be run locally. - -## Deploying - -This example uses the -[Cloud SDK maven plugin](https://cloud.google.com/appengine/docs/java/tools/using-maven). - - mvn appengine:deploy diff --git a/appengine-java8/logs/pom.xml b/appengine-java8/logs/pom.xml deleted file mode 100644 index ba613c504a5..00000000000 --- a/appengine-java8/logs/pom.xml +++ /dev/null @@ -1,91 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Copyright 2016 Google Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<project> - <modelVersion>4.0.0</modelVersion> - <packaging>war</packaging> - <version>1.0-SNAPSHOT</version> - <groupId>com.example.appengine</groupId> - <artifactId>appengine-logs-j8</artifactId> - - <!-- - The parent pom defines common style checks and testing strategies for our samples. - Removing or replacing it should not affect the execution of the samples in anyway. - --> - <parent> - <groupId>com.google.cloud.samples</groupId> - <artifactId>shared-configuration</artifactId> - <version>1.0.8</version> - </parent> - - <properties> - <maven.compiler.target>1.8</maven.compiler.target> - <maven.compiler.source>1.8</maven.compiler.source> - </properties> - - <dependencies> - <dependency> - <groupId>com.google.appengine</groupId> - <artifactId>appengine-api-1.0-sdk</artifactId> - <version>1.9.62</version> - </dependency> - <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - <version>20.0</version> - </dependency> - - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>javax.servlet-api</artifactId> - <version>3.1.0</version> - <type>jar</type> - <scope>provided</scope> - </dependency> - - <dependency> - <groupId>org.json</groupId> - <artifactId>json</artifactId> - <version>20180130</version> - </dependency> - <dependency> - <groupId>joda-time</groupId> - <artifactId>joda-time</artifactId> - <version>2.9.9</version> - </dependency> - </dependencies> - <build> - <!-- for hot reload of the web application --> - <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes - </outputDirectory> - <plugins> - <plugin> - <groupId>com.google.cloud.tools</groupId> - <artifactId>appengine-maven-plugin</artifactId> - <version>1.3.1</version> - <configuration> - <deploy.promote>true</deploy.promote> - <deploy.stopPreviousVersion>true</deploy.stopPreviousVersion> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-war-plugin</artifactId> - <version>3.1.0</version> - </plugin> - </plugins> - </build> -</project> diff --git a/appengine-java8/logs/src/main/java/com/example/appengine/logs/LogsServlet.java b/appengine-java8/logs/src/main/java/com/example/appengine/logs/LogsServlet.java deleted file mode 100644 index 8b45542fb26..00000000000 --- a/appengine-java8/logs/src/main/java/com/example/appengine/logs/LogsServlet.java +++ /dev/null @@ -1,100 +0,0 @@ -/* Copyright 2016 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// [START logs_API_example] - -package com.example.appengine.logs; - -import com.google.appengine.api.log.AppLogLine; -import com.google.appengine.api.log.LogQuery; -import com.google.appengine.api.log.LogServiceFactory; -import com.google.appengine.api.log.RequestLogs; -import java.io.IOException; -import java.io.PrintWriter; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.joda.time.DateTime; - -// Get request logs along with their app log lines and display them 5 at -// a time, using a Next link to cycle through to the next 5. -// With @WebServlet annotation the webapp/WEB-INF/web.xml is no longer required. -@WebServlet( - name = "logs", - description = "Logs: Display 5 lines of the request log", - urlPatterns = "/logs" -) -public class LogsServlet extends HttpServlet { - - @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)); - } -} -// [END logs_API_example] diff --git a/appengine-java8/logs/src/main/webapp/WEB-INF/appengine-web.xml b/appengine-java8/logs/src/main/webapp/WEB-INF/appengine-web.xml deleted file mode 100644 index 202e048ae2e..00000000000 --- a/appengine-java8/logs/src/main/webapp/WEB-INF/appengine-web.xml +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- [START_EXCLUDE] --> -<!-- - Copyright 2016 Google Inc. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<!-- [END_EXCLUDE] --> -<appengine-web-app xmlns="http://appengine.google.com/ns/1.0"> - <runtime>java8</runtime> - <threadsafe>true</threadsafe> - <system-properties> - <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/> - </system-properties> -</appengine-web-app> diff --git a/appengine-java8/logs/src/main/webapp/WEB-INF/logging.properties b/appengine-java8/logs/src/main/webapp/WEB-INF/logging.properties deleted file mode 100644 index 3e7f85b9dc1..00000000000 --- a/appengine-java8/logs/src/main/webapp/WEB-INF/logging.properties +++ /dev/null @@ -1,14 +0,0 @@ -# A default java.util.logging configuration. -# (All App Engine logging is through java.util.logging by default). -# -# To use this configuration, copy it into your application's WEB-INF -# folder and add the following to your appengine-web.xml: -# -# <system-properties> -# <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/> -# </system-properties> -# - -# Set the default logging level for all loggers to WARNING -.level = WARNING - diff --git a/appengine-java8/pom.xml b/appengine-java8/pom.xml index 8b96e8d923d..99c3c1dcb0a 100644 --- a/appengine-java8/pom.xml +++ b/appengine-java8/pom.xml @@ -57,7 +57,6 @@ <module>guestbook-cloud-datastore</module> <module>guestbook-objectify</module> <module>images</module> - <module>logs</module> <module>mailgun</module> <module>mailjet</module> <module>memcache</module>