Migrating to fluent logging (red)

PiperOrigin-RevId: 307690960
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java
index f407639..3b039ed 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java
@@ -25,6 +25,7 @@
 import com.google.common.collect.Lists;
 import com.google.common.eventbus.EventBus;
 import com.google.common.eventbus.SubscriberExceptionHandler;
+import com.google.common.flogger.GoogleLogger;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.Uninterruptibles;
 import com.google.devtools.build.lib.actions.ActionKeyContext;
@@ -126,7 +127,6 @@
 import java.util.function.Function;
 import java.util.function.Supplier;
 import java.util.logging.Handler;
-import java.util.logging.Level;
 import java.util.logging.LogRecord;
 import java.util.logging.Logger;
 import java.util.regex.Matcher;
@@ -144,7 +144,7 @@
   private static final Pattern suppressFromLog =
       Pattern.compile("--client_env=([^=]*(?:auth|pass|cookie)[^=]*)=", Pattern.CASE_INSENSITIVE);
 
-  private static final Logger logger = Logger.getLogger(BlazeRuntime.class.getName());
+  private static final GoogleLogger logger = GoogleLogger.forEnclosingClass();
 
   private final FileSystem fileSystem;
   private final Iterable<BlazeModule> blazeModules;
@@ -753,8 +753,8 @@
       // Run Blaze in batch mode.
       System.exit(batchMain(modules, args));
     }
-    logger.info(
-        "Starting Bazel server with " + maybeGetPidString() + "args " + Arrays.toString(args));
+    logger.atInfo().log(
+        "Starting Bazel server with %s, args %s", maybeGetPidString(), Arrays.toString(args));
     try {
       // Run Blaze in server mode.
       System.exit(serverMain(modules, OutErr.SYSTEM_OUT_ERR, args));
@@ -886,7 +886,7 @@
           while (true) {
             count++;
             Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS);
-            logger.warning("Slow interrupt number " + count + " in batch mode");
+            logger.atWarning().log("Slow interrupt number %d in batch mode", count);
             ThreadUtils.warnAboutSlowInterrupt();
           }
         };
@@ -894,7 +894,7 @@
     return new InterruptSignalHandler() {
       @Override
       public void run() {
-        logger.info("User interrupt");
+        logger.atInfo().log("User interrupt");
         OutErr.SYSTEM_OUT_ERR.printErrLn("Bazel received an interrupt");
         mainThread.interrupt();
 
@@ -904,7 +904,7 @@
           interruptWatcherThread.setDaemon(true);
           interruptWatcherThread.start();
         } else if (curNumInterrupts == 2) {
-          logger.warning("Second --batch interrupt: Reverting to JVM SIGINT handler");
+          logger.atWarning().log("Second --batch interrupt: Reverting to JVM SIGINT handler");
           uninstall();
         }
       }
@@ -918,11 +918,9 @@
   private static int batchMain(Iterable<BlazeModule> modules, String[] args) {
     InterruptSignalHandler signalHandler = captureSigint();
     CommandLineOptions commandLineOptions = splitStartupOptions(modules, args);
-    logger.info(
-        "Running Bazel in batch mode with "
-            + maybeGetPidString()
-            + "startup args "
-            + commandLineOptions.getStartupArgs());
+    logger.atInfo().log(
+        "Running Bazel in batch mode with %s, startup args %s",
+        maybeGetPidString(), commandLineOptions.getStartupArgs());
 
     BlazeRuntime runtime;
     InvocationPolicy policy;
@@ -952,7 +950,7 @@
     boolean shutdownDone = false;
 
     try {
-      logger.info(getRequestLogString(commandLineOptions.getOtherArgs()));
+      logger.atInfo().log(getRequestLogString(commandLineOptions.getOtherArgs()));
       BlazeCommandResult result =
           dispatcher.exec(
               policy,
@@ -1001,7 +999,7 @@
       } catch (IOException e) {
         // We are in batch mode, thus, stdout/stderr are the same as that of the client.
         System.err.println("Cannot execute process for 'run' command: " + e.getMessage());
-        logger.log(Level.SEVERE, "Exception while executing binary from 'run' command", e);
+        logger.atSevere().withCause(e).log("Exception while executing binary from 'run' command");
         return ExitCode.LOCAL_ENVIRONMENTAL_ERROR.getNumericExitCode();
       }
     } catch (InterruptedException e) {
@@ -1053,7 +1051,7 @@
           new InterruptSignalHandler() {
             @Override
             public void run() {
-              logger.severe("User interrupt");
+              logger.atSevere().log("User interrupt");
               rpcServer[0].interrupt();
             }
           };
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionRewindStrategy.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionRewindStrategy.java
index 2238225..5853ad5 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionRewindStrategy.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ActionRewindStrategy.java
@@ -29,6 +29,7 @@
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Maps;
+import com.google.common.flogger.GoogleLogger;
 import com.google.common.graph.EndpointPair;
 import com.google.common.graph.GraphBuilder;
 import com.google.common.graph.ImmutableGraph;
@@ -55,7 +56,6 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.logging.Logger;
 import javax.annotation.Nullable;
 
 /**
@@ -64,7 +64,7 @@
  * restarted in order to recreate the lost inputs.
  */
 public class ActionRewindStrategy {
-  private static final Logger logger = Logger.getLogger(ActionRewindStrategy.class.getName());
+  private static final GoogleLogger logger = GoogleLogger.forEnclosingClass();
   @VisibleForTesting public static final int MAX_REPEATED_LOST_INPUTS = 20;
   @VisibleForTesting public static final int MAX_ACTION_REWIND_EVENTS = 5;
   private static final int MAX_LOST_INPUTS_RECORDED = 5;
@@ -213,11 +213,10 @@
         throw new ActionExecutionException(
             lostInputsException, failedAction, /*catastrophe=*/ false);
       } else if (0 < priorLosses) {
-        logger.info(
-            String.format(
-                "lost input again (#%s) for the same action. lostInput: %s, "
-                    + "lostInput digest: %s, failedAction: %.10000s",
-                priorLosses + 1, lostInputsByDigest.get(digest), digest, failedAction));
+        logger.atInfo().log(
+            "lost input again (#%s) for the same action. lostInput: %s, "
+                + "lostInput digest: %s, failedAction: %.10000s",
+            priorLosses + 1, lostInputsByDigest.get(digest), digest, failedAction);
       }
     }
     return lostInputRecordsThisAction.build();
@@ -291,11 +290,10 @@
       //
       // In other cases, such as with bugs, when the action fails enough it will cause a crash in
       // checkIfActionLostInputTooManyTimes. We log that this has occurred.
-      logger.warning(
-          String.format(
-              "lostInput not a dep of the failed action, and can't be associated with such a dep. "
-                  + "lostInput: %s, owners: %s, failedAction: %.10000s",
-              lostInput, owners, failedAction));
+      logger.atWarning().log(
+          "lostInput not a dep of the failed action, and can't be associated with such a dep. "
+              + "lostInput: %s, owners: %s, failedAction: %.10000s",
+          lostInput, owners, failedAction);
     }
     return lostInputOwningDirectDeps;
   }