|
3 | 3 | import java.io.File; |
4 | 4 | import java.io.FileOutputStream; |
5 | 5 | import java.io.IOException; |
6 | | - |
| 6 | +import java.util.logging.ConsoleHandler; |
| 7 | +import java.util.logging.Formatter; |
| 8 | +import java.util.logging.Level; |
| 9 | +import java.util.logging.LogRecord; |
| 10 | +import java.util.logging.Logger; |
| 11 | +import java.util.logging.StreamHandler; |
7 | 12 | import com.eclipsesource.json.Json; |
8 | 13 | import com.eclipsesource.json.JsonArray; |
9 | 14 | import org.gradle.tooling.GradleConnectionException; |
|
19 | 24 | public class CliApp { |
20 | 25 | private File sourceDir; |
21 | 26 | private File targetFile; |
| 27 | + private Logger logger; |
| 28 | + private StreamHandler handler; |
22 | 29 |
|
23 | 30 | public CliApp(File sourceDir, File targetFile) { |
24 | 31 | this.sourceDir = sourceDir; |
25 | 32 | this.targetFile = targetFile; |
| 33 | + |
| 34 | + this.handler = new ConsoleHandler(); |
| 35 | + this.handler.setFormatter(new BasicWriteFormatter()); |
| 36 | + this.handler.setLevel(Level.ALL); |
| 37 | + |
| 38 | + this.logger = Logger.getLogger("CliApp"); |
| 39 | + this.logger.setUseParentHandlers(false); |
| 40 | + this.logger.addHandler(handler); |
| 41 | + } |
| 42 | + |
| 43 | + private static class BasicWriteFormatter extends Formatter { |
| 44 | + @Override |
| 45 | + public String format(LogRecord record) { |
| 46 | + return record.getMessage(); |
| 47 | + } |
26 | 48 | } |
27 | 49 |
|
28 | 50 | public static void main(String[] args) throws CliAppException, IOException { |
@@ -58,7 +80,7 @@ private JsonArray getProjects() throws CliAppException { |
58 | 80 | ProgressListener progressListener = new ProgressListener() { |
59 | 81 | @Override |
60 | 82 | public void statusChanged(ProgressEvent progressEvent) { |
61 | | - System.out.print("."); |
| 83 | + logger.info("."); |
62 | 84 | } |
63 | 85 | }; |
64 | 86 |
|
|
0 commit comments