@@ -126,6 +126,7 @@ public static void pushToTorna(TornaApi tornaApi, ApiConfig apiConfig, JavaProje
126126 private static void pushToTornaAll (TornaApi tornaApi , ApiConfig apiConfig , JavaProjectBuilder builder ) {
127127 // Build push document information
128128 Map <String , String > requestJson = TornaConstants .buildParams (PUSH , new Gson ().toJson (tornaApi ), apiConfig );
129+ TornaUtil .printDebugInfo (apiConfig , null , requestJson , PUSH , true );
129130 // Push dictionary information
130131 Map <String , Object > dicMap = new HashMap <>(2 );
131132 List <TornaDic > docDicts = TornaUtil .buildTornaDic (DocUtil .buildDictionary (apiConfig , builder ));
@@ -190,23 +191,45 @@ public static boolean setDebugEnv(ApiConfig apiConfig, TornaApi tornaApi) {
190191 */
191192 public static void printDebugInfo (ApiConfig apiConfig , String responseMsg , Map <String , String > requestJson ,
192193 String category ) {
194+ printDebugInfo (apiConfig , responseMsg , requestJson , category , false );
195+ }
196+
197+ /**
198+ * Prints debug information with mode support.
199+ * @param apiConfig The API configuration object containing OpenUrl, appToken, etc.
200+ * @param responseMsg The response message, null for pre-request mode.
201+ * @param requestJson The request JSON object in key-value pairs.
202+ * @param category The category of the request or response for classifying debug
203+ * information.
204+ * @param isPreRequest true for pre-request mode, false for post-request mode.
205+ */
206+ public static void printDebugInfo (ApiConfig apiConfig , String responseMsg , Map <String , String > requestJson ,
207+ String category , boolean isPreRequest ) {
193208 if (apiConfig .isTornaDebug ()) {
194209 String sb = "Configuration information : \n " + "OpenUrl: " + apiConfig .getOpenUrl () + "\n " + "appToken: "
195210 + apiConfig .getAppToken () + "\n " ;
196211 System .out .println (sb );
197- try {
198- JsonElement element = JsonParser .parseString (responseMsg );
212+ if (isPreRequest ) {
199213 TornaRequestInfo info = new TornaRequestInfo ().of ()
200214 .setCategory (category )
201- .setCode (element .getAsJsonObject ().get (TornaConstants .CODE ).getAsString ())
202- .setMessage (element .getAsJsonObject ().get (TornaConstants .MESSAGE ).getAsString ())
203215 .setRequestInfo (requestJson )
204216 .setResponseInfo (responseMsg );
205- System .out .println (info .buildInfo ());
217+ System .out .println (info .buildRequestInfo ());
206218 }
207- catch (Exception e ) {
208- // Ex : Nginx Error,Tomcat Error
209- System .out .println ("Response Error : \n " + responseMsg );
219+ else {
220+ try {
221+ JsonElement element = JsonParser .parseString (responseMsg );
222+ TornaRequestInfo info = new TornaRequestInfo ().of ()
223+ .setCategory (category )
224+ .setCode (element .getAsJsonObject ().get (TornaConstants .CODE ).getAsString ())
225+ .setMessage (element .getAsJsonObject ().get (TornaConstants .MESSAGE ).getAsString ())
226+ .setRequestInfo (requestJson )
227+ .setResponseInfo (responseMsg );
228+ System .out .println (info .buildInfo ());
229+ }
230+ catch (Exception e ) {
231+ System .out .println ("Response Error : \n " + responseMsg );
232+ }
210233 }
211234 }
212235 }
0 commit comments