@@ -24,9 +24,8 @@ public class EngineMain {
2424
2525 @ SuppressWarnings ("all" )
2626 public static void main (String [] args ) {
27- System .out .println ("=== Jar Analyzer Engine " + EngineConst .version + " ===" );
28- System .out .println ("Build SQLite database from JAR/WAR files" );
29- System .out .println ();
27+ logger .info ("=== Jar Analyzer Engine {} ===" , EngineConst .version );
28+ logger .info ("Build SQLite database from JAR/WAR files" );
3029
3130 EngineBuildCmd cmd = new EngineBuildCmd ();
3231 JCommander jc = JCommander .newBuilder ()
@@ -37,7 +36,7 @@ public static void main(String[] args) {
3736 try {
3837 jc .parse (args );
3938 } catch (Exception e ) {
40- System . err . println ("Error: " + e .getMessage ());
39+ logger . error ("Error: {}" , e .getMessage ());
4140 jc .usage ();
4241 System .exit (1 );
4342 return ;
@@ -49,15 +48,15 @@ public static void main(String[] args) {
4948 }
5049
5150 if (cmd .jarPath == null || cmd .jarPath .isEmpty ()) {
52- System . err . println ("Error: --jar parameter is required" );
51+ logger . error ("Error: --jar parameter is required" );
5352 jc .usage ();
5453 System .exit (1 );
5554 return ;
5655 }
5756
5857 Path jarPath = Paths .get (cmd .jarPath );
5958 if (!Files .exists (jarPath )) {
60- System . err . println ("Error: JAR path does not exist: " + cmd .jarPath );
59+ logger . error ("Error: JAR path does not exist: {}" , cmd .jarPath );
6160 System .exit (1 );
6261 return ;
6362 }
@@ -76,7 +75,7 @@ public static void main(String[] args) {
7675 if (Files .exists (rtPath )) {
7776 config .setRtJarPath (rtPath );
7877 } else {
79- System . err . println ( "Warning: rt.jar path does not exist: " + cmd .rtJarPath );
78+ logger . warn ( " rt.jar path does not exist: {}" , cmd .rtJarPath );
8079 }
8180 }
8281
@@ -86,7 +85,7 @@ public static void main(String[] args) {
8685 config .setClassBlackList (new String (Files .readAllBytes (
8786 Paths .get (cmd .classBlackListFile ))));
8887 } catch (IOException e ) {
89- System . err . println ( "Warning: cannot read black list file: " + cmd .classBlackListFile );
88+ logger . warn ( " cannot read black list file: {}" , cmd .classBlackListFile );
9089 }
9190 } else if (cmd .classBlackList != null ) {
9291 config .setClassBlackList (cmd .classBlackList );
@@ -98,24 +97,23 @@ public static void main(String[] args) {
9897 config .setClassWhiteList (new String (Files .readAllBytes (
9998 Paths .get (cmd .classWhiteListFile ))));
10099 } catch (IOException e ) {
101- System . err . println ( "Warning: cannot read white list file: " + cmd .classWhiteListFile );
100+ logger . warn ( " cannot read white list file: {}" , cmd .classWhiteListFile );
102101 }
103102 } else if (cmd .classWhiteList != null ) {
104103 config .setClassWhiteList (cmd .classWhiteList );
105104 }
106105
107106 // Print config summary
108- System .out .println ("Configuration:" );
109- System .out .println (" JAR Path: " + config .getJarPath ());
110- System .out .println (" DB Path: jar-analyzer.db" );
111- System .out .println (" Temp Dir: " + EngineConst .tempDir );
112- System .out .println (" Quick Mode: " + config .isQuickMode ());
113- System .out .println (" Fix Class: " + config .isFixClass ());
114- System .out .println (" Inner JARs: " + config .isJarsInJar ());
115- System .out .println (" Fix Impl: " + config .isFixMethodImpl ());
116- System .out .println (" Black List: " + (config .getClassBlackList () != null ? "set" : "none" ));
117- System .out .println (" White List: " + (config .getClassWhiteList () != null ? "set" : "none" ));
118- System .out .println ();
107+ logger .info ("Configuration:" );
108+ logger .info (" JAR Path: {}" , config .getJarPath ());
109+ logger .info (" DB Path: jar-analyzer.db" );
110+ logger .info (" Temp Dir: {}" , EngineConst .tempDir );
111+ logger .info (" Quick Mode: {}" , config .isQuickMode ());
112+ logger .info (" Fix Class: {}" , config .isFixClass ());
113+ logger .info (" Inner JARs: {}" , config .isJarsInJar ());
114+ logger .info (" Fix Impl: {}" , config .isFixMethodImpl ());
115+ logger .info (" Black List: {}" , config .getClassBlackList () != null ? "set" : "none" );
116+ logger .info (" White List: {}" , config .getClassWhiteList () != null ? "set" : "none" );
119117
120118 long startTime = System .currentTimeMillis ();
121119
@@ -129,9 +127,8 @@ public static void main(String[] args) {
129127 }
130128
131129 long elapsed = System .currentTimeMillis () - startTime ;
132- System .out .println ();
133- System .out .println ("=== Build Complete ===" );
134- System .out .printf ("Time elapsed: %.2f seconds%n" , elapsed / 1000.0 );
135- System .out .println ("Database: jar-analyzer.db" );
130+ logger .info ("=== Build Complete ===" );
131+ logger .info ("Time elapsed: {} seconds" , String .format ("%.2f" , elapsed / 1000.0 ));
132+ logger .info ("Database: jar-analyzer.db" );
136133 }
137134}
0 commit comments