SammyVimes commented on code in PR #1249:
URL: https://github.com/apache/ignite-3/pull/1249#discussion_r1010263166


##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/logger/HttpLogging.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cli.logger;
+
+import java.io.PrintWriter;
+import okhttp3.OkHttpClient.Builder;
+import okhttp3.logging.HttpLoggingInterceptor;
+import okhttp3.logging.HttpLoggingInterceptor.Level;
+import org.apache.ignite.rest.client.invoker.ApiClient;
+import org.apache.ignite.rest.client.invoker.Configuration;
+
+/** Helper class for logging HTTP requests/responses from generated REST API 
client. */
+public class HttpLogging {
+    /**
+     * Starts logging HTTP requests/responses to specified {@code PrintWriter}.
+     *
+     * @param output Print writer to print logs to.
+     */
+    public static void startHttpLogging(PrintWriter output) {
+        ApiClient client = Configuration.getDefaultApiClient();
+        Builder builder = client.getHttpClient().newBuilder();
+
+        HttpLoggingInterceptor interceptor = new 
HttpLoggingInterceptor(output::println);
+        interceptor.setLevel(Level.BASIC);
+        builder.interceptors().add(interceptor);
+
+        client.setHttpClient(builder.build());
+    }
+
+    /**
+     * Stops logging previously started by {@link 
HttpLogging#startHttpLogging(PrintWriter)}.
+     */
+    public static void stopHttpLogging() {
+        ApiClient client = Configuration.getDefaultApiClient();
+        Builder builder = client.getHttpClient().newBuilder();
+
+        builder.interceptors().clear();

Review Comment:
   Won't it clear **all** interceptors when we only want to stop http log? 
   Also, adding a test checking correct behaviour of this method would be cool



##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/core/flow/builder/FlowBuilder.java:
##########
@@ -102,6 +102,14 @@ default <OT> FlowBuilder<I, OT> map(Function<O, OT> 
mapper) {
      */
     FlowBuilder<I, O> exceptionHandler(ExceptionHandler<?> exceptionHandler);
 
+    /**
+     * Adds verbose output from debug log to the output.
+     *
+     * @param verbose if @{code true}, flow execution will print debug logs
+     * @return instance of builder

Review Comment:
   ```suggestion
        * @param verbose If @{code true}, flow execution will print debug logs.
        * @return Builder instance.
   ```



##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/BaseCommand.java:
##########
@@ -29,6 +29,9 @@ public abstract class BaseCommand {
     @Option(names = {"-h", "--help"}, usageHelp = true, description = "Show 
this help message and exit.")
     protected boolean usageHelpRequested;
 
+    @Option(names = {"-v", "--verbose"}, description = "Show additional 
information about errors.")
+    protected boolean verbose;

Review Comment:
   Is it always about errors?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to