@@ -33,6 +33,7 @@ class ZHttpClient private constructor(builder: Builder) {
3333 private val filesBufferSize = builder.getBufferSize()
3434 private val gson = Gson ()
3535 val requestRetryMechanism = builder.getRequestRetryMechanism()
36+ var allowLogging = builder.getAllowLogging()
3637
3738 /* *
3839 * Get the base URL of the client.
@@ -409,9 +410,9 @@ class ZHttpClient private constructor(builder: Builder) {
409410 var retryCount = requestRetryMechanism!! .retryCount
410411
411412 while (retryCount-- > 0 ) {
412- println (" ZHttp: $type : remaining attempts :$retryCount " )
413+ if (allowLogging) println (" ZHttp: $type : remaining attempts :$retryCount " )
413414 val response = requestBlock()
414- println (" ZHttp: $type : response :$response " )
415+ if (allowLogging) println (" ZHttp: $type : response :$response " )
415416
416417 if (response != null ) {
417418 if (response.exception == null || requestRetryMechanism.retryOnExceptions.none {
@@ -426,7 +427,7 @@ class ZHttpClient private constructor(builder: Builder) {
426427 }
427428
428429 if (retryCount == 0 && response != null ) {
429- System .err.println (" ZHttp: $type : maximum attempts exceeded." )
430+ if (allowLogging) System .err.println (" ZHttp: $type : maximum attempts exceeded." )
430431 return response
431432 }
432433
@@ -452,6 +453,7 @@ class ZHttpClient private constructor(builder: Builder) {
452453 )
453454 private var filesBufferSize = 1024
454455 private var requestRetryMechanism: RequestRetryMechanism ? = null
456+ private var allowLogging = false
455457
456458 /* *
457459 * Set the base URL for the HTTP client.
@@ -554,6 +556,17 @@ class ZHttpClient private constructor(builder: Builder) {
554556 return this
555557 }
556558
559+ /* *
560+ * Set the logging status for the HTTP client.
561+ *
562+ * @param allowLogging The logging status to be set.
563+ * @return This builder instance for method chaining.
564+ */
565+ fun allowLogging (allowLogging : Boolean ): Builder {
566+ this .allowLogging = allowLogging
567+ return this
568+ }
569+
557570 /* *
558571 * Get the base URL configured in the builder.
559572 *
@@ -608,6 +621,15 @@ class ZHttpClient private constructor(builder: Builder) {
608621 return requestRetryMechanism
609622 }
610623
624+ /* *
625+ * Get the logging status configured in the builder.
626+ *
627+ * @return The status.
628+ */
629+ internal fun getAllowLogging (): Boolean {
630+ return allowLogging
631+ }
632+
611633 /* *
612634 * Build and return a new instance of ZHttpClient with the configured settings.
613635 *
0 commit comments