@@ -34,6 +34,8 @@ protected static class Index {
34
34
public static final String HEADER_INDEX = "header_index" ;
35
35
public static final String STATUS_INDEX = "code_index" ;
36
36
public static final String API_DESC_INDEX = "api_desc_index" ;
37
+ public static final String CAUSE_INDEX = "cause_index" ;
38
+ public static final String REQUEST_ID_INDEX = "request_id_index" ;
37
39
}
38
40
39
41
public HttpBuilder apiDesc (String desc ) {
@@ -136,6 +138,29 @@ public HttpBuilder timezone(TimezoneType timezone) {
136
138
return this .timezone (timezone .getTimeZoneId ());
137
139
}
138
140
141
+ public HttpBuilder cause (Throwable e ) {
142
+ if (e == null ) {
143
+ return this ;
144
+ }
145
+ return this .cause (e .getMessage ());
146
+ }
147
+
148
+ public HttpBuilder cause (String e ) {
149
+ if (String4j .isEmpty (e )) {
150
+ return this ;
151
+ }
152
+ this .placeholders .put (Index .CAUSE_INDEX , e );
153
+ return this ;
154
+ }
155
+
156
+ public HttpBuilder requestId (String requestId ) {
157
+ if (String4j .isEmpty (requestId )) {
158
+ return this ;
159
+ }
160
+ this .placeholders .put (Index .REQUEST_ID_INDEX , requestId );
161
+ return this ;
162
+ }
163
+
139
164
@ SuppressWarnings ({"unchecked" })
140
165
@ Override
141
166
public String toString () {
@@ -180,6 +205,9 @@ public String toString() {
180
205
this .code (String4j .trimWhitespace (url ));
181
206
}
182
207
this .line (2 );
208
+ if (this .placeholders .containsKey (Index .REQUEST_ID_INDEX )) {
209
+ this .bold ("SSID:" ).code ((String ) this .placeholders .get (Index .REQUEST_ID_INDEX )).line ();
210
+ }
183
211
if (Object4j .allNotNull (this .start )) {
184
212
if (String4j .isEmpty (this .timezone )) {
185
213
this .bold ("RFT:" ).timestamp (this .start ).line ();
@@ -217,6 +245,10 @@ public String toString() {
217
245
Map <String , Object > request = (Map <String , Object >) Json4j .toMapFrom (this .placeholders .get (Index .RESPONSE_INDEX ));
218
246
this .bold ("Resp:" ).preformatted ("json" , request );
219
247
}
248
+ if (this .placeholders .containsKey (Index .CAUSE_INDEX )) {
249
+ this .line ();
250
+ this .bold ("Ex:" ).preformatted ("java" , (String ) this .placeholders .get (Index .CAUSE_INDEX ));
251
+ }
220
252
return super .toString ();
221
253
}
222
254
}
0 commit comments