This is an automated email from the ASF dual-hosted git repository.

ningjiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-toolkit.git

commit f060c88dab6787f62ed3d880ae681644ab953072
Author: kakulisen <18813972...@163.com>
AuthorDate: Tue May 28 14:18:29 2019 +0800

    optimize logging
    
    Signed-off-by: kakulisen <18813972...@163.com>
---
 .../apache/servicecomb/toolkit/common/ImmediateClassLoader.java    | 7 ++++++-
 .../servicecomb/toolkit/docgen/ContractsSwaggerUIGenerator.java    | 6 +++++-
 .../main/java/org/apache/servicecomb/toolkit/cli/CodeGenerate.java | 6 +++++-
 .../main/java/org/apache/servicecomb/toolkit/cli/DocGenerate.java  | 7 +++++--
 .../org/apache/servicecomb/toolkit/plugin/VerifyContractsMojo.java | 5 ++++-
 5 files changed, 25 insertions(+), 6 deletions(-)

diff --git 
a/common/src/main/java/org/apache/servicecomb/toolkit/common/ImmediateClassLoader.java
 
b/common/src/main/java/org/apache/servicecomb/toolkit/common/ImmediateClassLoader.java
index f03314a..08ccced 100755
--- 
a/common/src/main/java/org/apache/servicecomb/toolkit/common/ImmediateClassLoader.java
+++ 
b/common/src/main/java/org/apache/servicecomb/toolkit/common/ImmediateClassLoader.java
@@ -17,12 +17,17 @@
 
 package org.apache.servicecomb.toolkit.common;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.io.File;
 import java.net.URL;
 import java.net.URLClassLoader;
 
 public class ImmediateClassLoader extends URLClassLoader {
 
+  private final static Logger LOGGER = 
LoggerFactory.getLogger(ImmediateClassLoader.class);
+
   private String classPath;
 
   public ImmediateClassLoader(URL[] urls, ClassLoader parent) {
@@ -45,7 +50,7 @@ public class ImmediateClassLoader extends URLClassLoader {
               .replace(".class", "");
           loadClass(className);
         } catch (ClassNotFoundException e) {
-          e.printStackTrace();
+          LOGGER.error(e.getMessage());
         }
       } else if (file.isDirectory()) {
         for (File f : file.listFiles()) {
diff --git 
a/doc-generator/src/main/java/org/apache/servicecomb/toolkit/docgen/ContractsSwaggerUIGenerator.java
 
b/doc-generator/src/main/java/org/apache/servicecomb/toolkit/docgen/ContractsSwaggerUIGenerator.java
index 8d16173..5a27171 100755
--- 
a/doc-generator/src/main/java/org/apache/servicecomb/toolkit/docgen/ContractsSwaggerUIGenerator.java
+++ 
b/doc-generator/src/main/java/org/apache/servicecomb/toolkit/docgen/ContractsSwaggerUIGenerator.java
@@ -30,9 +30,13 @@ import java.util.regex.Pattern;
 
 import io.swagger.models.Swagger;
 import io.swagger.util.Json;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class ContractsSwaggerUIGenerator implements DocGenerator {
 
+  private final static Logger LOGGER = 
LoggerFactory.getLogger(ContractsSwaggerUIGenerator.class);
+
   private static Pattern variablePattern = 
Pattern.compile("(?<=\\{\\{)[a-zA-Z0-9_-]*(?=\\}\\})");
 
   private final static String DOC_FORMAT = "swagger-ui";
@@ -65,7 +69,7 @@ public class ContractsSwaggerUIGenerator implements 
DocGenerator {
 
       Files.write(outputFile, swaggerUiHtml.getBytes());
     } catch (IOException e) {
-      e.printStackTrace();
+      LOGGER.error(e.getMessage());
     }
 
     return swaggerUiHtml;
diff --git 
a/toolkit-cli/src/main/java/org/apache/servicecomb/toolkit/cli/CodeGenerate.java
 
b/toolkit-cli/src/main/java/org/apache/servicecomb/toolkit/cli/CodeGenerate.java
index 074f7f9..49f99d1 100755
--- 
a/toolkit-cli/src/main/java/org/apache/servicecomb/toolkit/cli/CodeGenerate.java
+++ 
b/toolkit-cli/src/main/java/org/apache/servicecomb/toolkit/cli/CodeGenerate.java
@@ -33,11 +33,15 @@ import 
org.apache.servicecomb.toolkit.codegen.DefaultCodeGenerator;
 import io.airlift.airline.Command;
 import io.airlift.airline.Option;
 import io.swagger.codegen.config.CodegenConfigurator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 @Command(name = "codegenerate",
     description = "Generate multiple models of microservice project by OpenAPI 
specification file")
 public class CodeGenerate implements Runnable {
 
+  private final static Logger LOGGER = 
LoggerFactory.getLogger(CodeGenerate.class);
+
   @Option(name = {"-p", "--programming-model"}, title = "programming model", 
required = false,
       description = "programming model, as SpringMVC, POJO, JAX-RS, and 
SpringBoot")
   private String programmingModel;
@@ -98,7 +102,7 @@ public class CodeGenerate implements Runnable {
             }
           });
         } catch (IOException e) {
-          e.printStackTrace();
+          LOGGER.error(e.getMessage());
         }
       } else {
         configurator.setInputSpec(specFile);
diff --git 
a/toolkit-cli/src/main/java/org/apache/servicecomb/toolkit/cli/DocGenerate.java 
b/toolkit-cli/src/main/java/org/apache/servicecomb/toolkit/cli/DocGenerate.java
index 7113b9c..988389a 100755
--- 
a/toolkit-cli/src/main/java/org/apache/servicecomb/toolkit/cli/DocGenerate.java
+++ 
b/toolkit-cli/src/main/java/org/apache/servicecomb/toolkit/cli/DocGenerate.java
@@ -32,10 +32,14 @@ import org.apache.servicecomb.swagger.SwaggerUtils;
 
 import io.airlift.airline.Command;
 import io.airlift.airline.Option;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 @Command(name = "docgenerate", description = "Generate document by OpenAPI 
specification file")
 public class DocGenerate implements Runnable {
 
+  private final static Logger LOGGER = 
LoggerFactory.getLogger(CodeGenerate.class);
+
   @Option(name = {"-i", "--input"}, title = "OpenAPI specification file", 
required = true,
       description = "location of the OpenAPI specification file, as URL or 
file (required)")
   private String specFile;
@@ -80,8 +84,7 @@ public class DocGenerate implements Runnable {
             format);
       }
     } catch (IOException e) {
-      // command line , direct print to screen
-      e.printStackTrace();
+      LOGGER.error(e.getMessage());
     }
   }
 }
diff --git 
a/toolkit-maven-plugin/src/main/java/org/apache/servicecomb/toolkit/plugin/VerifyContractsMojo.java
 
b/toolkit-maven-plugin/src/main/java/org/apache/servicecomb/toolkit/plugin/VerifyContractsMojo.java
index 0ef19c4..c548d62 100755
--- 
a/toolkit-maven-plugin/src/main/java/org/apache/servicecomb/toolkit/plugin/VerifyContractsMojo.java
+++ 
b/toolkit-maven-plugin/src/main/java/org/apache/servicecomb/toolkit/plugin/VerifyContractsMojo.java
@@ -31,6 +31,8 @@ import org.apache.maven.plugins.annotations.ResolutionScope;
 import org.apache.maven.project.MavenProject;
 import org.apache.servicecomb.toolkit.common.ContractComparator;
 import org.apache.servicecomb.toolkit.common.ContractsUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 @Mojo(name = "verifyContracts", defaultPhase = LifecyclePhase.COMPILE, 
requiresDependencyResolution = ResolutionScope.COMPILE)
 @Execute(goal = "verifyContracts",
@@ -38,6 +40,7 @@ import org.apache.servicecomb.toolkit.common.ContractsUtils;
 )
 public class VerifyContractsMojo extends AbstractMojo {
 
+  private final static Logger LOGGER = 
LoggerFactory.getLogger(VerifyContractsMojo.class);
 
   @Parameter(defaultValue = "${project}", required = true, readonly = true)
   private MavenProject project;
@@ -81,7 +84,7 @@ public class VerifyContractsMojo extends AbstractMojo {
         }
       });
     } catch (IOException e) {
-      e.printStackTrace();
+      LOGGER.error(e.getMessage());
     }
   }
 }

Reply via email to