33
44package com .azure .core .http .policy ;
55
6- import com .azure .core .util .CoreUtils ;
76import com .azure .core .util .ClientOptions ;
7+ import com .azure .core .util .CoreUtils ;
88import com .azure .core .util .logging .ClientLogger ;
99
1010import java .util .Arrays ;
@@ -22,6 +22,10 @@ public class HttpLogOptions {
2222 private Set <String > allowedHeaderNames ;
2323 private Set <String > allowedQueryParamNames ;
2424 private boolean prettyPrintBody ;
25+
26+ private HttpRequestLogger requestLogger ;
27+ private HttpResponseLogger responseLogger ;
28+
2529 private final ClientLogger logger = new ClientLogger (HttpLogOptions .class );
2630
2731 private static final int MAX_APPLICATION_ID_LENGTH = 24 ;
@@ -96,10 +100,9 @@ public Set<String> getAllowedHeaderNames() {
96100 *
97101 * <p>
98102 * This method sets the provided header names to be the whitelisted header names which will be logged for all HTTP
99- * requests and responses, overwriting any previously configured headers, including the default set. Additionally,
100- * users can use {@link HttpLogOptions#addAllowedHeaderName(String)} or
101- * {@link HttpLogOptions#getAllowedHeaderNames()} to add or remove more headers names to the existing set of
102- * allowed header names.
103+ * requests and responses, overwriting any previously configured headers. Additionally, users can use {@link
104+ * HttpLogOptions#addAllowedHeaderName(String)} or {@link HttpLogOptions#getAllowedHeaderNames()} to add or remove
105+ * more headers names to the existing set of allowed header names.
103106 * </p>
104107 *
105108 * @param allowedHeaderNames The list of whitelisted header names from the user.
@@ -202,12 +205,60 @@ public boolean isPrettyPrintBody() {
202205 /**
203206 * Sets flag to allow pretty printing of message bodies.
204207 *
205- * @param prettyPrintBody If true, pretty prints message bodies when logging. If the detailLevel does not
206- * include body logging, this flag does nothing.
208+ * @param prettyPrintBody If true, pretty prints message bodies when logging. If the detailLevel does not include
209+ * body logging, this flag does nothing.
207210 * @return The updated HttpLogOptions object.
208211 */
209212 public HttpLogOptions setPrettyPrintBody (boolean prettyPrintBody ) {
210213 this .prettyPrintBody = prettyPrintBody ;
211214 return this ;
212215 }
216+
217+ /**
218+ * Gets the {@link HttpRequestLogger} that will be used to log HTTP requests.
219+ * <p>
220+ * A default {@link HttpRequestLogger} will be used if one isn't supplied.
221+ *
222+ * @return The {@link HttpRequestLogger} that will be used to log HTTP requests.
223+ */
224+ public HttpRequestLogger getRequestLogger () {
225+ return requestLogger ;
226+ }
227+
228+ /**
229+ * Sets the {@link HttpRequestLogger} that will be used to log HTTP requests.
230+ * <p>
231+ * A default {@link HttpRequestLogger} will be used if one isn't supplied.
232+ *
233+ * @param requestLogger The {@link HttpRequestLogger} that will be used to log HTTP requests.
234+ * @return The updated HttpLogOptions object.
235+ */
236+ public HttpLogOptions setRequestLogger (HttpRequestLogger requestLogger ) {
237+ this .requestLogger = requestLogger ;
238+ return this ;
239+ }
240+
241+ /**
242+ * Gets the {@link HttpResponseLogger} that will be used to log HTTP responses.
243+ * <p>
244+ * A default {@link HttpResponseLogger} will be used if one isn't supplied.
245+ *
246+ * @return The {@link HttpResponseLogger} that will be used to log HTTP responses.
247+ */
248+ public HttpResponseLogger getResponseLogger () {
249+ return responseLogger ;
250+ }
251+
252+ /**
253+ * Sets the {@link HttpResponseLogger} that will be used to log HTTP responses.
254+ * <p>
255+ * A default {@link HttpResponseLogger} will be used if one isn't supplied.
256+ *
257+ * @param responseLogger The {@link HttpResponseLogger} that will be used to log HTTP responses.
258+ * @return The updated HttpLogOptions object.
259+ */
260+ public HttpLogOptions setResponseLogger (HttpResponseLogger responseLogger ) {
261+ this .responseLogger = responseLogger ;
262+ return this ;
263+ }
213264}
0 commit comments