flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joshtynj...@apache.org
Subject git commit: [flex-utilities] [refs/heads/develop] - flex-sdk-converter: DownloadRetriever and ProgressBar use slf4j SimpleLogger so that Maven -q option will correctly hide non-error output
Date Sun, 23 Jul 2017 19:29:31 GMT
Repository: flex-utilities
Updated Branches:
  refs/heads/develop 8b168c154 -> b1a013c96


flex-sdk-converter: DownloadRetriever and ProgressBar use slf4j SimpleLogger so that Maven
-q option will correctly hide non-error output


Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/b1a013c9
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/b1a013c9
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/b1a013c9

Branch: refs/heads/develop
Commit: b1a013c9694699081277dca2b690655cc9dbe6fc
Parents: 8b168c1
Author: Josh Tynjala <joshtynjala@apache.org>
Authored: Sun Jul 23 12:29:22 2017 -0700
Committer: Josh Tynjala <joshtynjala@apache.org>
Committed: Sun Jul 23 12:29:22 2017 -0700

----------------------------------------------------------------------
 .../flex-sdk-converter/retrievers/base/pom.xml  |  5 ++
 .../converter/retrievers/utils/ProgressBar.java |  6 ++-
 .../retrievers/download/DownloadRetriever.java  | 48 +++++++++++---------
 3 files changed, 36 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b1a013c9/flex-maven-tools/flex-sdk-converter/retrievers/base/pom.xml
----------------------------------------------------------------------
diff --git a/flex-maven-tools/flex-sdk-converter/retrievers/base/pom.xml b/flex-maven-tools/flex-sdk-converter/retrievers/base/pom.xml
index 53db71c..fba0fa4 100644
--- a/flex-maven-tools/flex-sdk-converter/retrievers/base/pom.xml
+++ b/flex-maven-tools/flex-sdk-converter/retrievers/base/pom.xml
@@ -57,6 +57,11 @@
             <artifactId>commons-lang3</artifactId>
             <version>3.3.2</version>
         </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <version>1.7.21</version>
+        </dependency>
 
         <!--TEST-->
         <dependency>

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b1a013c9/flex-maven-tools/flex-sdk-converter/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/utils/ProgressBar.java
----------------------------------------------------------------------
diff --git a/flex-maven-tools/flex-sdk-converter/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/utils/ProgressBar.java
b/flex-maven-tools/flex-sdk-converter/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/utils/ProgressBar.java
index c15d26b..dece112 100644
--- a/flex-maven-tools/flex-sdk-converter/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/utils/ProgressBar.java
+++ b/flex-maven-tools/flex-sdk-converter/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/utils/ProgressBar.java
@@ -17,12 +17,16 @@
 package org.apache.flex.utilities.converter.retrievers.utils;
 
 import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Created by cdutz on 24.05.2014.
  */
 public class ProgressBar {
 
+    private static final Logger LOG = LoggerFactory.getLogger(ProgressBar.class);
+
     protected long total;
 
     public ProgressBar(long total) {
@@ -39,7 +43,7 @@ public class ProgressBar {
                 ((double) current / (double) total) * (double) 100);
         final int segmentsTransferred = transferredPercent / 2;
         final int segmentsRest = 50 - segmentsTransferred;
-        System.out.print("\r" + String.format(" %3d", transferredPercent) + "% [" +
+        LOG.info("\r" + String.format(" %3d", transferredPercent) + "% [" +
                 StringUtils.repeat("=", segmentsTransferred) +
                 ((segmentsRest > 0) ? ">" + StringUtils.repeat(" ", segmentsRest -
1) : "") + "] ");
     }

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/b1a013c9/flex-maven-tools/flex-sdk-converter/retrievers/download/src/main/java/org/apache/flex/utilities/converter/retrievers/download/DownloadRetriever.java
----------------------------------------------------------------------
diff --git a/flex-maven-tools/flex-sdk-converter/retrievers/download/src/main/java/org/apache/flex/utilities/converter/retrievers/download/DownloadRetriever.java
b/flex-maven-tools/flex-sdk-converter/retrievers/download/src/main/java/org/apache/flex/utilities/converter/retrievers/download/DownloadRetriever.java
index 2700464..bde30be 100644
--- a/flex-maven-tools/flex-sdk-converter/retrievers/download/src/main/java/org/apache/flex/utilities/converter/retrievers/download/DownloadRetriever.java
+++ b/flex-maven-tools/flex-sdk-converter/retrievers/download/src/main/java/org/apache/flex/utilities/converter/retrievers/download/DownloadRetriever.java
@@ -32,6 +32,8 @@ import org.apache.http.client.methods.HttpGet;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
@@ -62,6 +64,8 @@ public class DownloadRetriever extends BaseRetriever {
 
     public static final long MEGABYTE = 1 << 20;
 
+    private static final Logger LOG = LoggerFactory.getLogger(DownloadRetriever.class);
+
     /**
      * Wrapper to allow simple overriding of this property.
      *
@@ -140,7 +144,7 @@ public class DownloadRetriever extends BaseRetriever {
                     FileUtils.moveFile(targetFile, libDestFile);
                     return targetDirectory;
                 } else {
-                    System.out.println("Extracting archive to temp directory.");
+                    LOG.info("Extracting archive to temp directory.");
                     File targetDirectory = new File(targetFile.getParent(),
                             targetFile.getName().substring(0, targetFile.getName().lastIndexOf(".")
- 1));
                     if (type.equals(SdkType.SWFOBJECT)) {
@@ -148,9 +152,9 @@ public class DownloadRetriever extends BaseRetriever {
                     } else {
                         unpack(targetFile, targetDirectory);
                     }
-                    System.out.println();
-                    System.out.println("Finished extracting.");
-                    System.out.println("===========================================================");
+                    LOG.info("");
+                    LOG.info("Finished extracting.");
+                    LOG.info("===========================================================");
 
                     // In case of the swfobject, delete some stuff we don't want in there.
                     if (type.equals(SdkType.SWFOBJECT)) {
@@ -207,12 +211,12 @@ public class DownloadRetriever extends BaseRetriever {
             final long expectedSize = connection.getContentLength();
             long transferedSize = 0L;
 
-            System.out.println("===========================================================");
-            System.out.println("Downloading " + sourceUrl.toString());
+            LOG.info("===========================================================");
+            LOG.info("Downloading " + sourceUrl.toString());
             if (expectedSize > 1014 * 1024) {
-                System.out.println("Expected size: " + (expectedSize / 1024 / 1024) + "MB");
+                LOG.info("Expected size: " + (expectedSize / 1024 / 1024) + "MB");
             } else {
-                System.out.println("Expected size: " + (expectedSize / 1024) + "KB");
+                LOG.info("Expected size: " + (expectedSize / 1024) + "KB");
             }
             final ProgressBar progressBar = new ProgressBar(expectedSize);
             while (transferedSize < expectedSize) {
@@ -235,9 +239,9 @@ public class DownloadRetriever extends BaseRetriever {
                 }
             }
         }
-        System.out.println();
-        System.out.println("Finished downloading.");
-        System.out.println("===========================================================");
+        LOG.info("");
+        LOG.info("Finished downloading.");
+        LOG.info("===========================================================");
     }
 
     protected void performSafeDownload(URI sourceUri, File targetFile) throws IOException
{
@@ -259,8 +263,8 @@ public class DownloadRetriever extends BaseRetriever {
 
             String reasonPhrase = response.getStatusLine().getReasonPhrase();
             int statusCode = response.getStatusLine().getStatusCode();
-            System.out.println(String.format("statusCode: %d", statusCode));
-            System.out.println(String.format("reasonPhrase: %s", reasonPhrase));
+            LOG.info(String.format("statusCode: %d", statusCode));
+            LOG.info(String.format("reasonPhrase: %s", reasonPhrase));
 
             HttpEntity entity = response.getEntity();
             InputStream content = entity.getContent();
@@ -276,11 +280,11 @@ public class DownloadRetriever extends BaseRetriever {
             ////////////////////////////////////////////////////////////////////////////////
 
                 final long expectedSize = entity.getContentLength();
-                System.out.println("===========================================================");
-                System.out.println("Downloading " + sourceUri.toString());
+                LOG.info("===========================================================");
+                LOG.info("Downloading " + sourceUri.toString());
                 if (expectedSize <= 0) {
                     try {
-                        System.out.println("Unknown size.");
+                        LOG.info("Unknown size.");
                         IOUtils.copy(content, fos);
                     } finally {
                         // close http network connection
@@ -288,9 +292,9 @@ public class DownloadRetriever extends BaseRetriever {
                     }
                 } else {
                     if (expectedSize > 1014 * 1024) {
-                        System.out.println("Expected size: " + (expectedSize / 1024 / 1024)
+ "MB");
+                        LOG.info("Expected size: " + (expectedSize / 1024 / 1024) + "MB");
                     } else {
-                        System.out.println("Expected size: " + (expectedSize / 1024) + "KB");
+                        LOG.info("Expected size: " + (expectedSize / 1024) + "KB");
                     }
                     final ProgressBar progressBar = new ProgressBar(expectedSize);
                     long transferredSize = 0L;
@@ -304,10 +308,10 @@ public class DownloadRetriever extends BaseRetriever {
                         progressBar.updateProgress(transferredSize);
                     }
                     fos.close();
-                    System.out.println();
+                    LOG.info("");
                 }
-                System.out.println("Finished downloading.");
-                System.out.println("===========================================================");
+                LOG.info("Finished downloading.");
+                LOG.info("===========================================================");
             } finally {
                 if(rbc != null) {
                     try {
@@ -347,7 +351,7 @@ public class DownloadRetriever extends BaseRetriever {
                 SocketAddress socketAddress = new InetSocketAddress(proxySettings.getHost(),
proxySettings.getPort());
                 Proxy proxy = new Proxy(Proxy.Type.valueOf(proxySettings.getProtocol().toUpperCase()),
socketAddress);
                 connection = configUrl.openConnection(proxy);
-                System.out.println("Using proxy: " + proxySettings.getHost());
+                LOG.info("Using proxy: " + proxySettings.getHost());
             } else {
                 connection = configUrl.openConnection();
             }


Mime
View raw message