diff options
author | 2017-09-04 18:51:57 +0200 | |
---|---|---|
committer | 2017-09-05 09:53:57 +0200 | |
commit | 97abb524bacc6d8527744657642f79c25c843c59 (patch) | |
tree | 0b8672d74ab81480cc3a9c89f50b4369adb610e0 /src/main/java/com/google | |
parent | d7a2f112cc668f4dcd0ea905f9d53bb6f8d3d550 (diff) |
Rename all logger instances to "logger" (instead "LOG" or "log").
RELNOTES: None.
PiperOrigin-RevId: 167505493
Diffstat (limited to 'src/main/java/com/google')
40 files changed, 270 insertions, 254 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/actions/cache/CompactPersistentActionCache.java b/src/main/java/com/google/devtools/build/lib/actions/cache/CompactPersistentActionCache.java index 95a986053e..e432a83ec5 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/cache/CompactPersistentActionCache.java +++ b/src/main/java/com/google/devtools/build/lib/actions/cache/CompactPersistentActionCache.java @@ -17,7 +17,6 @@ import static java.nio.charset.StandardCharsets.ISO_8859_1; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.devtools.build.lib.actions.cache.ActionCache.Entry; import com.google.devtools.build.lib.concurrent.ThreadSafety.ConditionallyThreadSafe; import com.google.devtools.build.lib.profiler.AutoProfiler; import com.google.devtools.build.lib.util.Clock; @@ -66,7 +65,8 @@ public class CompactPersistentActionCache implements ActionCache { private static final int VERSION = 12; - private static final Logger LOG = Logger.getLogger(CompactPersistentActionCache.class.getName()); + private static final Logger logger = + Logger.getLogger(CompactPersistentActionCache.class.getName()); private final class ActionMap extends PersistentMap<Integer, byte[]> { private final Clock clock; @@ -99,7 +99,7 @@ public class CompactPersistentActionCache implements ActionCache { @Override protected void markAsDirty() { try (AutoProfiler p = - AutoProfiler.logged("slow write to journal", LOG, MIN_TIME_FOR_LOGGING_MILLIS)) { + AutoProfiler.logged("slow write to journal", logger, MIN_TIME_FOR_LOGGING_MILLIS)) { super.markAsDirty(); } } diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BlazeVersionInfo.java b/src/main/java/com/google/devtools/build/lib/analysis/BlazeVersionInfo.java index 1056d23a12..866ab6fc78 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/BlazeVersionInfo.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/BlazeVersionInfo.java @@ -17,7 +17,6 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.devtools.build.lib.util.StringUtilities; - import java.util.Date; import java.util.Map; import java.util.logging.Logger; @@ -36,7 +35,7 @@ public class BlazeVersionInfo { private final Map<String, String> buildData = Maps.newTreeMap(); private static BlazeVersionInfo instance = null; - private static final Logger LOG = Logger.getLogger(BlazeVersionInfo.class.getName()); + private static final Logger logger = Logger.getLogger(BlazeVersionInfo.class.getName()); /** Key for the release timestamp is seconds. */ public static final String BUILD_TIMESTAMP = "Build timestamp as int"; @@ -60,9 +59,9 @@ public class BlazeVersionInfo { private static void logVersionInfo(BlazeVersionInfo info) { if (info.getSummary() == null) { - LOG.warning("Blaze release version information not available"); + logger.warning("Blaze release version information not available"); } else { - LOG.info("Blaze version info: " + info.getSummary()); + logger.info("Blaze version info: " + info.getSummary()); } } diff --git a/src/main/java/com/google/devtools/build/lib/buildeventstream/transports/BinaryFormatFileTransport.java b/src/main/java/com/google/devtools/build/lib/buildeventstream/transports/BinaryFormatFileTransport.java index af3560080a..70d500dfeb 100644 --- a/src/main/java/com/google/devtools/build/lib/buildeventstream/transports/BinaryFormatFileTransport.java +++ b/src/main/java/com/google/devtools/build/lib/buildeventstream/transports/BinaryFormatFileTransport.java @@ -34,7 +34,7 @@ import java.util.logging.Logger; */ public final class BinaryFormatFileTransport extends FileTransport { - private static final Logger log = Logger.getLogger(BinaryFormatFileTransport.class.getName()); + private static final Logger logger = Logger.getLogger(BinaryFormatFileTransport.class.getName()); private static final int MAX_VARINT_BYTES = 9; private final PathConverter pathConverter; @@ -72,7 +72,7 @@ public final class BinaryFormatFileTransport extends FileTransport { protoEvent.writeDelimitedTo(out); writeData(out.toByteArray()); } catch (IOException e) { - log.log(Level.SEVERE, e.getMessage(), e); + logger.log(Level.SEVERE, e.getMessage(), e); @SuppressWarnings({"unused", "nullness"}) Future<?> possiblyIgnoredError = close(); } diff --git a/src/main/java/com/google/devtools/build/lib/buildeventstream/transports/FileTransport.java b/src/main/java/com/google/devtools/build/lib/buildeventstream/transports/FileTransport.java index fcb265447a..0d5fabf214 100644 --- a/src/main/java/com/google/devtools/build/lib/buildeventstream/transports/FileTransport.java +++ b/src/main/java/com/google/devtools/build/lib/buildeventstream/transports/FileTransport.java @@ -20,7 +20,6 @@ import static com.google.common.base.Preconditions.checkState; import com.google.common.annotations.VisibleForTesting; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; -import com.google.devtools.build.lib.buildeventstream.BuildEvent; import com.google.devtools.build.lib.buildeventstream.BuildEventTransport; import java.io.IOException; import java.nio.ByteBuffer; @@ -35,21 +34,20 @@ import java.util.logging.Logger; /** * Non-blocking file transport. * - * <p>Implementors of this class need to implement {@link #sendBuildEvent(BuildEvent)} which + * <p>Implementors of this class need to implement {@code #sendBuildEvent(BuildEvent)} which * serializes the build event and writes it to file using {@link #writeData(byte[])}. */ abstract class FileTransport implements BuildEventTransport { /** * We use an {@link AsynchronousFileChannel} to perform non-blocking writes to a file. It get's - * tricky when it comes to {@link #close()}, as we may only complete the returned future when - * all writes have completed (succeeded or failed). Thus, we use a field - * {@link #outstandingWrites} to keep track of the number of writes that have not completed yet. - * It's simply incremented before a new write and decremented after a write has completed. When - * it's {@code 0} it's safe to complete the close future. + * tricky when it comes to {@link #close()}, as we may only complete the returned future when all + * writes have completed (succeeded or failed). Thus, we use a field {@link #outstandingWrites} to + * keep track of the number of writes that have not completed yet. It's simply incremented before + * a new write and decremented after a write has completed. When it's {@code 0} it's safe to + * complete the close future. */ - - private static final Logger log = Logger.getLogger(FileTransport.class.getName()); + private static final Logger logger = Logger.getLogger(FileTransport.class.getName()); @VisibleForTesting final AsynchronousFileChannel ch; @@ -107,7 +105,7 @@ abstract class FileTransport implements BuildEventTransport { ch.force(true); ch.close(); } catch (IOException e) { - log.log(Level.SEVERE, e.getMessage(), e); + logger.log(Level.SEVERE, e.getMessage(), e); } finally { closeFuture.set(null); } @@ -133,7 +131,7 @@ abstract class FileTransport implements BuildEventTransport { @Override public void failed(Throwable exc, Void attachment) { - log.log(Level.SEVERE, exc.getMessage(), exc); + logger.log(Level.SEVERE, exc.getMessage(), exc); countWriteAndTryClose(); // There is no point in trying to continue. Close the transport. @SuppressWarnings({"unused", "nullness"}) diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/BuildRequest.java b/src/main/java/com/google/devtools/build/lib/buildtool/BuildRequest.java index 75ba13177a..d020dfa6e8 100644 --- a/src/main/java/com/google/devtools/build/lib/buildtool/BuildRequest.java +++ b/src/main/java/com/google/devtools/build/lib/buildtool/BuildRequest.java @@ -58,7 +58,7 @@ import java.util.regex.Pattern; * as --keep_going, --jobs, etc. */ public class BuildRequest implements OptionsClassProvider { - private static final Logger log = Logger.getLogger(BuildRequest.class.getName()); + private static final Logger logger = Logger.getLogger(BuildRequest.class.getName()); /** * Options interface--can be used to parse command-line arguments. @@ -417,7 +417,7 @@ public class BuildRequest implements OptionsClassProvider { if (fixedAutoJobs == null) { jobs = (int) Math.ceil(LocalHostCapacity.getLocalHostCapacity().getCpuUsage()); if (jobs > MAX_JOBS) { - log.warning( + logger.warning( "Detected " + jobs + " processors, which exceed the maximum allowed number of jobs of " @@ -428,7 +428,7 @@ public class BuildRequest implements OptionsClassProvider { } else { jobs = fixedAutoJobs; } - log.info("Flag \"jobs\" was set to \"auto\"; using " + jobs + " jobs"); + logger.info("Flag \"jobs\" was set to \"auto\"; using " + jobs + " jobs"); return jobs; } else { return super.convert(input); diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java b/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java index 56b1b906b3..cf6c4e2ff5 100644 --- a/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java +++ b/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java @@ -167,7 +167,7 @@ public class ExecutionTool { } } - static final Logger log = Logger.getLogger(ExecutionTool.class.getName()); + static final Logger logger = Logger.getLogger(ExecutionTool.class.getName()); private final CommandEnvironment env; private final BlazeRuntime runtime; @@ -723,7 +723,8 @@ public class ExecutionTool { private void saveActionCache(ActionCache actionCache) { ActionCacheStatistics.Builder builder = ActionCacheStatistics.newBuilder(); - AutoProfiler p = AutoProfiler.profiledAndLogged("Saving action cache", ProfilerTask.INFO, log); + AutoProfiler p = + AutoProfiler.profiledAndLogged("Saving action cache", ProfilerTask.INFO, logger); try { builder.setSizeInBytes(actionCache.save()); } catch (IOException e) { diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/OutputDirectoryLinksUtils.java b/src/main/java/com/google/devtools/build/lib/buildtool/OutputDirectoryLinksUtils.java index fd1fae5798..e4b2b68a83 100644 --- a/src/main/java/com/google/devtools/build/lib/buildtool/OutputDirectoryLinksUtils.java +++ b/src/main/java/com/google/devtools/build/lib/buildtool/OutputDirectoryLinksUtils.java @@ -14,6 +14,7 @@ package com.google.devtools.build.lib.buildtool; import static com.google.common.base.Preconditions.checkArgument; + import com.google.common.base.Joiner; import com.google.common.collect.ImmutableList; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; @@ -24,11 +25,9 @@ import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.build.lib.vfs.Symlinks; - import java.io.IOException; import java.util.ArrayList; import java.util.List; - import javax.annotation.Nullable; /** @@ -210,7 +209,7 @@ public class OutputDirectoryLinksUtils { Path link = base.getRelative(name); try { if (link.exists(Symlinks.NOFOLLOW)) { - ExecutionTool.log.finest("Removing " + link); + ExecutionTool.logger.finest("Removing " + link); link.delete(); } return true; diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/SymlinkForest.java b/src/main/java/com/google/devtools/build/lib/buildtool/SymlinkForest.java index bcea3d8ae5..0523f097c2 100644 --- a/src/main/java/com/google/devtools/build/lib/buildtool/SymlinkForest.java +++ b/src/main/java/com/google/devtools/build/lib/buildtool/SymlinkForest.java @@ -37,8 +37,8 @@ import java.util.logging.Logger; */ class SymlinkForest { - private static final Logger log = Logger.getLogger(SymlinkForest.class.getName()); - private static final boolean LOG_FINER = log.isLoggable(Level.FINER); + private static final Logger logger = Logger.getLogger(SymlinkForest.class.getName()); + private static final boolean LOG_FINER = logger.isLoggable(Level.FINER); private final ImmutableMap<PackageIdentifier, Path> packageRoots; private final Path execroot; @@ -145,7 +145,7 @@ class SymlinkForest { } if (entry.getValue().size() > 1) { if (LOG_FINER) { - log.finer("mkdir " + execroot.getRelative(dir.getPathUnderExecRoot())); + logger.finer("mkdir " + execroot.getRelative(dir.getPathUnderExecRoot())); } FileSystemUtils.createDirectoryAndParents( execroot.getRelative(dir.getPathUnderExecRoot())); @@ -165,8 +165,11 @@ class SymlinkForest { // This is the top-most dir that can be linked to a single root. Make it so. Path root = roots.iterator().next(); // lone root in set if (LOG_FINER) { - log.finer("ln -s " + root.getRelative(dir.getSourceRoot()) + " " - + execroot.getRelative(dir.getPathUnderExecRoot())); + logger.finer( + "ln -s " + + root.getRelative(dir.getSourceRoot()) + + " " + + execroot.getRelative(dir.getPathUnderExecRoot())); } execroot.getRelative(dir.getPathUnderExecRoot()) .createSymbolicLink(root.getRelative(dir.getSourceRoot())); @@ -184,8 +187,8 @@ class SymlinkForest { Path absdir = root.getRelative(dir.getSourceRoot()); if (absdir.isDirectory()) { if (LOG_FINER) { - log.finer("ln -s " + absdir + "/* " - + execroot.getRelative(dir.getSourceRoot()) + "/"); + logger.finer( + "ln -s " + absdir + "/* " + execroot.getRelative(dir.getSourceRoot()) + "/"); } for (Path target : absdir.getDirectoryEntries()) { PathFragment p = target.relativeTo(root); @@ -195,7 +198,7 @@ class SymlinkForest { } } } else { - log.fine("Symlink planting skipping dir '" + absdir + "'"); + logger.fine("Symlink planting skipping dir '" + absdir + "'"); } } catch (IOException e) { e.printStackTrace(); diff --git a/src/main/java/com/google/devtools/build/lib/concurrent/ThrowableRecordingRunnableWrapper.java b/src/main/java/com/google/devtools/build/lib/concurrent/ThrowableRecordingRunnableWrapper.java index f66e23070f..5256742878 100644 --- a/src/main/java/com/google/devtools/build/lib/concurrent/ThrowableRecordingRunnableWrapper.java +++ b/src/main/java/com/google/devtools/build/lib/concurrent/ThrowableRecordingRunnableWrapper.java @@ -28,7 +28,7 @@ public class ThrowableRecordingRunnableWrapper { private final String name; private AtomicReference<Throwable> errorRef = new AtomicReference<>(); - private static final Logger LOG = + private static final Logger logger = Logger.getLogger(ThrowableRecordingRunnableWrapper.class.getName()); public ThrowableRecordingRunnableWrapper(String name) { @@ -46,7 +46,7 @@ public class ThrowableRecordingRunnableWrapper { runnable.run(); } catch (Throwable error) { errorRef.compareAndSet(null, error); - LOG.log(Level.SEVERE, "Error thrown by runnable in " + name, error); + logger.log(Level.SEVERE, "Error thrown by runnable in " + name, error); } }; } diff --git a/src/main/java/com/google/devtools/build/lib/exec/FileWriteStrategy.java b/src/main/java/com/google/devtools/build/lib/exec/FileWriteStrategy.java index 5ae15c5660..2ada360baa 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/FileWriteStrategy.java +++ b/src/main/java/com/google/devtools/build/lib/exec/FileWriteStrategy.java @@ -33,7 +33,7 @@ import java.util.logging.Logger; */ @ExecutionStrategy(name = { "local" }, contextType = FileWriteActionContext.class) public final class FileWriteStrategy implements FileWriteActionContext { - private static final Logger LOG = Logger.getLogger(FileWriteStrategy.class.getName()); + private static final Logger logger = Logger.getLogger(FileWriteStrategy.class.getName()); public static final Class<FileWriteStrategy> TYPE = FileWriteStrategy.class; public FileWriteStrategy() { @@ -44,8 +44,8 @@ public final class FileWriteStrategy implements FileWriteActionContext { throws ExecException, InterruptedException { // TODO(ulfjack): Consider acquiring local resources here before trying to write the file. try (AutoProfiler p = - AutoProfiler.logged( - "running " + action.prettyPrint(), LOG, /*minTimeForLoggingInMilliseconds=*/ 100)) { + AutoProfiler.logged( + "running " + action.prettyPrint(), logger, /*minTimeForLoggingInMilliseconds=*/ 100)) { try { Path outputPath = Iterables.getOnlyElement(action.getOutputs()).getPath(); try (OutputStream out = new BufferedOutputStream(outputPath.getOutputStream())) { diff --git a/src/main/java/com/google/devtools/build/lib/exec/SymlinkTreeStrategy.java b/src/main/java/com/google/devtools/build/lib/exec/SymlinkTreeStrategy.java index 914f62a795..80a5c1bda1 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/SymlinkTreeStrategy.java +++ b/src/main/java/com/google/devtools/build/lib/exec/SymlinkTreeStrategy.java @@ -31,7 +31,7 @@ import java.util.logging.Logger; */ @ExecutionStrategy(contextType = SymlinkTreeActionContext.class) public final class SymlinkTreeStrategy implements SymlinkTreeActionContext { - private static final Logger LOG = Logger.getLogger(SymlinkTreeStrategy.class.getName()); + private static final Logger logger = Logger.getLogger(SymlinkTreeStrategy.class.getName()); private final OutputService outputService; private final BinTools binTools; @@ -49,8 +49,8 @@ public final class SymlinkTreeStrategy implements SymlinkTreeActionContext { boolean enableRunfiles) throws ActionExecutionException, InterruptedException { try (AutoProfiler p = - AutoProfiler.logged( - "running " + action.prettyPrint(), LOG, /*minTimeForLoggingInMilliseconds=*/ 100)) { + AutoProfiler.logged( + "running " + action.prettyPrint(), logger, /*minTimeForLoggingInMilliseconds=*/ 100)) { try { SymlinkTreeHelper helper = new SymlinkTreeHelper( action.getInputManifest().getPath(), diff --git a/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java b/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java index b03acc5610..7394213628 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java +++ b/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java @@ -328,7 +328,7 @@ public final class PackageFactory { } } - private static final Logger LOG = Logger.getLogger(PackageFactory.class.getName()); + private static final Logger logger = Logger.getLogger(PackageFactory.class.getName()); private final RuleFactory ruleFactory; private final RuleClassProvider ruleClassProvider; @@ -1345,9 +1345,9 @@ public final class PackageFactory { List<Statement> preludeStatements, ExtendedEventHandler eventHandler) { // Logged messages are used as a testability hook tracing the parsing progress - LOG.fine("Starting to parse " + packageId); + logger.fine("Starting to parse " + packageId); BuildFileAST buildFileAST = BuildFileAST.parseBuildFile(in, preludeStatements, eventHandler); - LOG.fine("Finished parsing of " + packageId); + logger.fine("Finished parsing of " + packageId); return buildFileAST; } diff --git a/src/main/java/com/google/devtools/build/lib/profiler/Profiler.java b/src/main/java/com/google/devtools/build/lib/profiler/Profiler.java index 2ad353f6da..863391bd88 100644 --- a/src/main/java/com/google/devtools/build/lib/profiler/Profiler.java +++ b/src/main/java/com/google/devtools/build/lib/profiler/Profiler.java @@ -118,7 +118,7 @@ import java.util.zip.DeflaterOutputStream; */ @ThreadSafe public final class Profiler { - private static final Logger LOG = Logger.getLogger(Profiler.class.getName()); + private static final Logger logger = Logger.getLogger(Profiler.class.getName()); public static final int MAGIC = 0x11223344; @@ -739,7 +739,7 @@ public final class Profiler { if (localStack == null || localQueue == null) { // Variables have been nulled out by #clear in between the check the caller made and this // point in the code. Probably due to an asynchronous crash. - LOG.severe("Variables null in profiler for " + type + ", probably due to async crash"); + logger.severe("Variables null in profiler for " + type + ", probably due to async crash"); return; } TaskData parent = localStack.peek(); diff --git a/src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java b/src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java index 3bd547ceb9..5229575efe 100644 --- a/src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java +++ b/src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java @@ -139,7 +139,7 @@ public class SkyQueryEnvironment extends AbstractBlazeQueryEnvironment<Target> static final int BATCH_CALLBACK_SIZE = 10000; protected static final int DEFAULT_THREAD_COUNT = Runtime.getRuntime().availableProcessors(); private static final int MAX_QUERY_EXPRESSION_LOG_CHARS = 1000; - private static final Logger LOG = Logger.getLogger(SkyQueryEnvironment.class.getName()); + private static final Logger logger = Logger.getLogger(SkyQueryEnvironment.class.getName()); private final BlazeTargetAccessor accessor = new BlazeTargetAccessor(this); protected final int loadingPhaseThreads; @@ -249,7 +249,7 @@ public class SkyQueryEnvironment extends AbstractBlazeQueryEnvironment<Target> // assume here that this environment cannot be initialized-but-stale if the factory is up // to date. EvaluationResult<SkyValue> result; - try (AutoProfiler p = AutoProfiler.logged("evaluation and walkable graph", LOG)) { + try (AutoProfiler p = AutoProfiler.logged("evaluation and walkable graph", logger)) { result = graphFactory.prepareAndGet(roots, loadingPhaseThreads, universeEvalEventHandler); } @@ -363,12 +363,15 @@ public class SkyQueryEnvironment extends AbstractBlazeQueryEnvironment<Target> public final QueryExpression transformParsedQuery(QueryExpression queryExpression) { QueryExpressionMapper mapper = getQueryExpressionMapper(); QueryExpression transformedQueryExpression = queryExpression.accept(mapper); - LOG.info(String.format( - "transformed query [%s] to [%s]", - Ascii.truncate( - queryExpression.toString(), MAX_QUERY_EXPRESSION_LOG_CHARS, "[truncated]"), - Ascii.truncate( - transformedQueryExpression.toString(), MAX_QUERY_EXPRESSION_LOG_CHARS, "[truncated]"))); + logger.info( + String.format( + "transformed query [%s] to [%s]", + Ascii.truncate( + queryExpression.toString(), MAX_QUERY_EXPRESSION_LOG_CHARS, "[truncated]"), + Ascii.truncate( + transformedQueryExpression.toString(), + MAX_QUERY_EXPRESSION_LOG_CHARS, + "[truncated]"))); return transformedQueryExpression; } @@ -392,7 +395,7 @@ public class SkyQueryEnvironment extends AbstractBlazeQueryEnvironment<Target> throwableToThrow = throwable; } finally { if (throwableToThrow != null) { - LOG.log( + logger.log( Level.INFO, "About to shutdown query threadpool because of throwable", throwableToThrow); diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/FakeCppCompileAction.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/FakeCppCompileAction.java index a73ea273ec..bf6b9fdc70 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/FakeCppCompileAction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/FakeCppCompileAction.java @@ -47,7 +47,7 @@ import java.util.logging.Logger; @ThreadCompatible public class FakeCppCompileAction extends CppCompileAction { - private static final Logger log = Logger.getLogger(FakeCppCompileAction.class.getName()); + private static final Logger logger = Logger.getLogger(FakeCppCompileAction.class.getName()); public static final UUID GUID = UUID.fromString("8ab63589-be01-4a39-b770-b98ae8b03493"); @@ -130,7 +130,7 @@ public class FakeCppCompileAction extends CppCompileAction { setModuleFileFlags(); // First, do a normal compilation, to generate the ".d" file. The generated object file is built // to a temporary location (tempOutputFile) and ignored afterwards. - log.info("Generating " + getDotdFile()); + logger.info("Generating " + getDotdFile()); CppCompileActionContext context = actionExecutionContext.getContext(actionContext); CppCompileActionContext.Reply reply = null; try { @@ -193,7 +193,7 @@ public class FakeCppCompileAction extends CppCompileAction { // Generate a fake ".o" file containing the command line needed to generate // the real object file. - log.info("Generating " + outputFile); + logger.info("Generating " + outputFile); // A cc_fake_binary rule generates fake .o files and a fake target file, // which merely contain instructions on building the real target. We need to diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandEventHandler.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandEventHandler.java index 7d10f655cd..081d76d527 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandEventHandler.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandEventHandler.java @@ -40,7 +40,7 @@ import org.joda.time.format.DateTimeFormatter; */ public class BlazeCommandEventHandler implements EventHandler { - private static final Logger LOG = Logger.getLogger(BlazeCommandEventHandler.class.getName()); + private static final Logger logger = Logger.getLogger(BlazeCommandEventHandler.class.getName()); public enum UseColor { YES, NO, AUTO } public enum UseCurses { YES, NO, AUTO } @@ -351,7 +351,7 @@ public class BlazeCommandEventHandler implements EventHandler { // This can happen in server mode if the blaze client has exited, or if output is redirected // to a file and the disk is full, etc. May be moot in the case of full disk, or useful in // the case of real bug in our handling of streams. - LOG.log(Level.WARNING, "Failed to write event", e); + logger.log(Level.WARNING, "Failed to write event", e); } } 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 cbd0a4e9d6..66defced52 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 @@ -120,7 +120,7 @@ public final class BlazeRuntime { private static final Pattern suppressFromLog = Pattern.compile("--client_env=([^=]*(?:auth|pass|cookie)[^=]*)=", Pattern.CASE_INSENSITIVE); - private static final Logger LOG = Logger.getLogger(BlazeRuntime.class.getName()); + private static final Logger logger = Logger.getLogger(BlazeRuntime.class.getName()); private final Iterable<BlazeModule> blazeModules; private final Map<String, BlazeCommand> commandMap = new LinkedHashMap<>(); @@ -522,7 +522,7 @@ public final class BlazeRuntime { public static final class RemoteExceptionHandler implements SubscriberExceptionHandler { @Override public void handleException(Throwable exception, SubscriberExceptionContext context) { - LOG.log(Level.SEVERE, "Failure in EventBus subscriber", exception); + logger.log(Level.SEVERE, "Failure in EventBus subscriber", exception); LoggingUtil.logToRemote(Level.SEVERE, "Failure in EventBus subscriber.", exception); } } @@ -550,7 +550,7 @@ public final class BlazeRuntime { // Run Blaze in batch mode. System.exit(batchMain(modules, args)); } - LOG.info( + logger.info( "Starting Blaze server with pid " + maybeGetPidString() + " and args " @@ -689,7 +689,7 @@ public final class BlazeRuntime { while (true) { count++; Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS); - LOG.warning("Slow interrupt number " + count + " in batch mode"); + logger.warning("Slow interrupt number " + count + " in batch mode"); ThreadUtils.warnAboutSlowInterrupt(); } }; @@ -697,7 +697,7 @@ public final class BlazeRuntime { new InterruptSignalHandler() { @Override public void run() { - LOG.info("User interrupt"); + logger.info("User interrupt"); OutErr.SYSTEM_OUT_ERR.printErrLn("Blaze received an interrupt"); mainThread.interrupt(); @@ -707,7 +707,7 @@ public final class BlazeRuntime { interruptWatcherThread.setDaemon(true); interruptWatcherThread.start(); } else if (curNumInterrupts == 2) { - LOG.warning("Second --batch interrupt: Reverting to JVM SIGINT handler"); + logger.warning("Second --batch interrupt: Reverting to JVM SIGINT handler"); uninstall(); } } @@ -721,7 +721,7 @@ public final class BlazeRuntime { private static int batchMain(Iterable<BlazeModule> modules, String[] args) { captureSigint(); CommandLineOptions commandLineOptions = splitStartupOptions(modules, args); - LOG.info( + logger.info( "Running Blaze in batch mode with " + maybeGetPidString() + "startup args " @@ -751,7 +751,7 @@ public final class BlazeRuntime { BlazeCommandDispatcher dispatcher = new BlazeCommandDispatcher(runtime); try { - LOG.info(getRequestLogString(commandLineOptions.getOtherArgs())); + logger.info(getRequestLogString(commandLineOptions.getOtherArgs())); return dispatcher.exec( policy, commandLineOptions.getOtherArgs(), @@ -785,7 +785,7 @@ public final class BlazeRuntime { new InterruptSignalHandler() { @Override public void run() { - LOG.severe("User interrupt"); + logger.severe("User interrupt"); blazeServer.interrupt(); } }; diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeWorkspace.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeWorkspace.java index cc9d949ae4..a20fe4ebd3 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeWorkspace.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeWorkspace.java @@ -50,7 +50,7 @@ import javax.annotation.Nullable; public final class BlazeWorkspace { public static final String DO_NOT_BUILD_FILE_NAME = "DO_NOT_BUILD_HERE"; - private static final Logger LOG = Logger.getLogger(BlazeRuntime.class.getName()); + private static final Logger logger = Logger.getLogger(BlazeRuntime.class.getName()); private final BlazeRuntime runtime; private final SubscriberExceptionHandler eventBusExceptionHandler; @@ -224,11 +224,11 @@ public final class BlazeWorkspace { */ public ActionCache getPersistentActionCache(Reporter reporter) throws IOException { if (actionCache == null) { - try (AutoProfiler p = profiledAndLogged("Loading action cache", ProfilerTask.INFO, LOG)) { + try (AutoProfiler p = profiledAndLogged("Loading action cache", ProfilerTask.INFO, logger)) { try { actionCache = new CompactPersistentActionCache(getCacheDirectory(), runtime.getClock()); } catch (IOException e) { - LOG.log(Level.WARNING, "Failed to load action cache: " + e.getMessage(), e); + logger.log(Level.WARNING, "Failed to load action cache: " + e.getMessage(), e); LoggingUtil.logToRemote( Level.WARNING, "Failed to load action cache: " + e.getMessage(), e); reporter.handle( @@ -273,7 +273,7 @@ public final class BlazeWorkspace { "only Blaze will modify this directory and the files in it,", "so if you change anything here you may mess up Blaze's cache."); } catch (IOException e) { - LOG.warning("Couldn't write to '" + outputBaseReadmeFile + "': " + e.getMessage()); + logger.warning("Couldn't write to '" + outputBaseReadmeFile + "': " + e.getMessage()); } } @@ -282,7 +282,7 @@ public final class BlazeWorkspace { FileSystemUtils.createDirectoryAndParents(filePath.getParentDirectory()); FileSystemUtils.writeContent(filePath, ISO_8859_1, getWorkspace().toString()); } catch (IOException e) { - LOG.warning("Couldn't write to '" + filePath + "': " + e.getMessage()); + logger.warning("Couldn't write to '" + filePath + "': " + e.getMessage()); } } @@ -302,7 +302,7 @@ public final class BlazeWorkspace { try { FileSystemUtils.createDirectoryAndParents(directories.getExecRoot()); } catch (IOException e) { - LOG.warning( + logger.warning( "failed to create execution root '" + directories.getExecRoot() + "': " + e.getMessage()); } } diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BuildEventStreamer.java b/src/main/java/com/google/devtools/build/lib/runtime/BuildEventStreamer.java index 8888804698..069044cbe4 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BuildEventStreamer.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BuildEventStreamer.java @@ -97,7 +97,7 @@ public class BuildEventStreamer implements EventHandler { // Will be set to true if the build was invoked through "bazel test". private boolean isTestCommand; - private static final Logger log = Logger.getLogger(BuildEventStreamer.class.getName()); + private static final Logger logger = Logger.getLogger(BuildEventStreamer.class.getName()); /** * Provider for stdout and stderr output. @@ -326,7 +326,7 @@ public class BuildEventStreamer implements EventHandler { Futures.allAsList(closeFutures).get(); f.cancel(true); } catch (Exception e) { - log.severe("Failed to close a build event transport: " + e); + logger.severe("Failed to close a build event transport: " + e); } } finally { if (executor != null) { diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BuildSummaryStatsModule.java b/src/main/java/com/google/devtools/build/lib/runtime/BuildSummaryStatsModule.java index ee2ca955e9..0805acd138 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BuildSummaryStatsModule.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BuildSummaryStatsModule.java @@ -35,7 +35,7 @@ import java.util.logging.Logger; */ public class BuildSummaryStatsModule extends BlazeModule { - private static final Logger LOG = Logger.getLogger(BuildSummaryStatsModule.class.getName()); + private static final Logger logger = Logger.getLogger(BuildSummaryStatsModule.class.getName()); private SimpleCriticalPathComputer criticalPathComputer; private EventBus eventBus; @@ -83,9 +83,10 @@ public class BuildSummaryStatsModule extends BlazeModule { AggregatedCriticalPath<SimpleCriticalPathComponent> criticalPath = criticalPathComputer.aggregate(); items.add(criticalPath.toStringSummary()); - LOG.info(criticalPath.toString()); - LOG.info("Slowest actions:\n " + Joiner.on("\n ") - .join(criticalPathComputer.getSlowestComponents())); + logger.info(criticalPath.toString()); + logger.info( + "Slowest actions:\n " + + Joiner.on("\n ").join(criticalPathComputer.getSlowestComponents())); // We reverse the critical path because the profiler expect events ordered by the time // when the actions were executed while critical path computation is stored in the reverse // way. diff --git a/src/main/java/com/google/devtools/build/lib/runtime/CacheFileDigestsModule.java b/src/main/java/com/google/devtools/build/lib/runtime/CacheFileDigestsModule.java index 1c94bd8a17..4fb26a5478 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/CacheFileDigestsModule.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/CacheFileDigestsModule.java @@ -25,7 +25,7 @@ import java.util.logging.Logger; /** Enables the caching of file digests in {@link DigestUtils}. */ public class CacheFileDigestsModule extends BlazeModule { - private static final Logger log = Logger.getLogger(CacheFileDigestsModule.class.getName()); + private static final Logger logger = Logger.getLogger(CacheFileDigestsModule.class.getName()); /** Stats gathered at the beginning of a command, to compute deltas on completion. */ private CacheStats stats; @@ -45,7 +45,7 @@ public class CacheFileDigestsModule extends BlazeModule { * @param stats the cache statistics to be logged */ private static void logStats(String message, CacheStats stats) { - log.info( + logger.info( message + ": hit count=" + stats.hitCount() @@ -64,14 +64,14 @@ public class CacheFileDigestsModule extends BlazeModule { ExecutionOptions options = request.getOptions(ExecutionOptions.class); if (lastKnownCacheSize == null || options.cacheSizeForComputedFileDigests != lastKnownCacheSize) { - log.info("Reconfiguring cache with size=" + options.cacheSizeForComputedFileDigests); + logger.info("Reconfiguring cache with size=" + options.cacheSizeForComputedFileDigests); DigestUtils.configureCache(options.cacheSizeForComputedFileDigests); lastKnownCacheSize = options.cacheSizeForComputedFileDigests; } if (options.cacheSizeForComputedFileDigests == 0) { stats = null; - log.info("Disabled cache"); + logger.info("Disabled cache"); } else { stats = DigestUtils.getCacheStats(); logStats("Accumulated cache stats before command", stats); diff --git a/src/main/java/com/google/devtools/build/lib/runtime/CommandExecutor.java b/src/main/java/com/google/devtools/build/lib/runtime/CommandExecutor.java index 3d2b46d310..f57c8ca04a 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/CommandExecutor.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/CommandExecutor.java @@ -30,7 +30,7 @@ import java.util.logging.Logger; * <p>This is the common execution path between the gRPC server and the legacy AF_UNIX server. */ public class CommandExecutor implements ServerCommand { - private static final Logger LOG = Logger.getLogger(CommandExecutor.class.getName()); + private static final Logger logger = Logger.getLogger(CommandExecutor.class.getName()); private boolean shutdown; private final BlazeRuntime runtime; @@ -52,7 +52,7 @@ public class CommandExecutor implements ServerCommand { long firstContactTime, Optional<List<Pair<String, String>>> startupOptionsTaggedWithBazelRc) throws InterruptedException { - LOG.info(BlazeRuntime.getRequestLogString(args)); + logger.info(BlazeRuntime.getRequestLogString(args)); try { return dispatcher.exec( @@ -70,7 +70,7 @@ public class CommandExecutor implements ServerCommand { PrintWriter writer = new PrintWriter(message, true); e.printStackTrace(writer); writer.flush(); - LOG.severe(message.toString()); + logger.severe(message.toString()); } shutdown = true; runtime.shutdown(); diff --git a/src/main/java/com/google/devtools/build/lib/runtime/RetainedHeapLimiter.java b/src/main/java/com/google/devtools/build/lib/runtime/RetainedHeapLimiter.java index bdd594886f..b55853b7a3 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/RetainedHeapLimiter.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/RetainedHeapLimiter.java @@ -36,7 +36,7 @@ import javax.management.openmbean.CompositeData; * exit with an {@link OutOfMemoryError}. */ class RetainedHeapLimiter implements NotificationListener { - private static final Logger LOG = Logger.getLogger(RetainedHeapLimiter.class.getName()); + private static final Logger logger = Logger.getLogger(RetainedHeapLimiter.class.getName()); private static final long MIN_TIME_BETWEEN_TRIGGERED_GC_MILLISECONDS = 60000; private static int registeredOccupiedHeapPercentageThreshold = -1; @@ -121,12 +121,12 @@ class RetainedHeapLimiter implements NotificationListener { space.getMax(), occupiedHeapPercentageThreshold); System.err.println(exitMsg); - LOG.info(exitMsg); + logger.info(exitMsg); // Exits the runtime. BugReport.handleCrash(new OutOfMemoryError(exitMsg)); } else if (System.currentTimeMillis() - lastTriggeredGcInMilliseconds > MIN_TIME_BETWEEN_TRIGGERED_GC_MILLISECONDS) { - LOG.info( + logger.info( "Triggering a full GC with " + space.getUsed() + " out of " diff --git a/src/main/java/com/google/devtools/build/lib/server/GrpcServerImpl.java b/src/main/java/com/google/devtools/build/lib/server/GrpcServerImpl.java index 3f3b46b413..1c23317dc0 100644 --- a/src/main/java/com/google/devtools/build/lib/server/GrpcServerImpl.java +++ b/src/main/java/com/google/devtools/build/lib/server/GrpcServerImpl.java @@ -107,7 +107,7 @@ import javax.annotation.concurrent.GuardedBy; * which results in the main thread of the command being interrupted. */ public class GrpcServerImpl implements RPCServer { - private static final Logger log = Logger.getLogger(GrpcServerImpl.class.getName()); + private static final Logger logger = Logger.getLogger(GrpcServerImpl.class.getName()); // UTF-8 won't do because we want to be able to pass arbitrary binary strings. // Not that the internals of Bazel handle that correctly, but why not make at least this little @@ -131,7 +131,7 @@ public class GrpcServerImpl implements RPCServer { runningCommands.notify(); } - log.info(String.format("Starting command %s on thread %s", id, thread.getName())); + logger.info(String.format("Starting command %s on thread %s", id, thread.getName())); } @Override @@ -144,7 +144,7 @@ public class GrpcServerImpl implements RPCServer { runningCommands.notify(); } - log.info(String.format("Finished command %s on thread %s", id, thread.getName())); + logger.info(String.format("Finished command %s on thread %s", id, thread.getName())); } } @@ -225,20 +225,20 @@ public class GrpcServerImpl implements RPCServer { this.actionQueue = new LinkedBlockingQueue<>(); this.exchanger = new Exchanger<>(); this.observer = observer; - this.observer.setOnCancelHandler(() -> { - Thread commandThread = GrpcSink.this.commandThread.get(); - if (commandThread != null) { - log.info( - String.format( - "Interrupting thread %s due to the streaming %s call being cancelled " - + "(likely client hang up or explicit gRPC-level cancellation)", - commandThread.getName(), - rpcCommandName)); - commandThread.interrupt(); - } + this.observer.setOnCancelHandler( + () -> { + Thread commandThread = GrpcSink.this.commandThread.get(); + if (commandThread != null) { + logger.info( + String.format( + "Interrupting thread %s due to the streaming %s call being cancelled " + + "(likely client hang up or explicit gRPC-level cancellation)", + commandThread.getName(), rpcCommandName)); + commandThread.interrupt(); + } - actionQueue.offer(SinkThreadAction.DISCONNECT); - }); + actionQueue.offer(SinkThreadAction.DISCONNECT); + }); this.observer.setOnReadyHandler(() -> actionQueue.offer(SinkThreadAction.READY)); this.future = executor.submit(GrpcSink.this::call); } @@ -317,8 +317,10 @@ public class GrpcServerImpl implements RPCServer { // notified about this and interrupt the command thread, but in the meantime, we can just // ignore the error; the client is dead, so there isn't anyone to talk to so swallowing the // output is fine. - log.info(String.format("Client cancelled command for streamer thread %s", - Thread.currentThread().getName())); + logger.info( + String.format( + "Client cancelled command for streamer thread %s", + Thread.currentThread().getName())); } } @@ -350,7 +352,8 @@ public class GrpcServerImpl implements RPCServer { break; case DISCONNECT: - log.info("Client disconnected for stream thread " + Thread.currentThread().getName()); + logger.info( + "Client disconnected for stream thread " + Thread.currentThread().getName()); disconnected.set(true); if (itemPending) { exchange(new SinkThreadItem(false, null), true); @@ -424,7 +427,7 @@ public class GrpcServerImpl implements RPCServer { // that when gRPC notifies us about the disconnection (see the call to setOnCancelHandler) // we interrupt the command thread, which should be enough to make the server come around // as soon as possible. - log.info( + logger.info( String.format( "Client disconnected received for command %s on thread %s", commandIdBytes.toStringUtf8(), Thread.currentThread().getName())); @@ -466,21 +469,21 @@ public class GrpcServerImpl implements RPCServer { String pidFileContents = new String(FileSystemUtils.readContentAsLatin1(pidFile)); ok = pidFileContents.equals(pidInFile); } catch (IOException e) { - log.info("Cannot read PID file: " + e.getMessage()); + logger.info("Cannot read PID file: " + e.getMessage()); // Handled by virtue of ok not being set to true } if (!ok) { synchronized (PidFileWatcherThread.this) { if (shuttingDown) { - log.warning("PID file deleted or overwritten but shutdown is already in progress"); + logger.warning("PID file deleted or overwritten but shutdown is already in progress"); break; } shuttingDown = true; // Someone overwrote the PID file. Maybe it's another server, so shut down as quickly // as possible without even running the shutdown hooks (that would delete it) - log.severe("PID file deleted or overwritten, exiting as quickly as possible"); + logger.severe("PID file deleted or overwritten, exiting as quickly as possible"); Runtime.getRuntime().halt(ExitCode.BLAZE_INTERNAL_ERROR.getNumericExitCode()); } } @@ -777,7 +780,7 @@ public class GrpcServerImpl implements RPCServer { printErr.println("=======[BLAZE SERVER: ENCOUNTERED IO EXCEPTION]======="); e.printStackTrace(printErr); printErr.println("====================================================="); - log.severe(err.toString()); + logger.severe(err.toString()); } private void executeCommand( @@ -792,7 +795,7 @@ public class GrpcServerImpl implements RPCServer { .build()); observer.onCompleted(); } catch (StatusRuntimeException e) { - log.info("Client cancelled command while rejecting it: " + e.getMessage()); + logger.info("Client cancelled command while rejecting it: " + e.getMessage()); } return; } @@ -833,7 +836,7 @@ public class GrpcServerImpl implements RPCServer { .setCommandId(commandId) .build()); } catch (StatusRuntimeException e) { - log.info( + logger.info( "The client cancelled the command before receiving the command id: " + e.getMessage()); } @@ -863,8 +866,9 @@ public class GrpcServerImpl implements RPCServer { if (sink.finish()) { // Client disconnected. Then we are not allowed to call any methods on the observer. - log.info(String.format("Client disconnected before we could send exit code for command %s", - commandId)); + logger.info( + String.format( + "Client disconnected before we could send exit code for command %s", commandId)); return; } @@ -892,8 +896,10 @@ public class GrpcServerImpl implements RPCServer { observer.onCompleted(); } catch (StatusRuntimeException e) { // The client cancelled the call. Log an error and go on. - log.info(String.format("Client cancelled command %s just right before its end: %s", - commandId, e.getMessage())); + logger.info( + String.format( + "Client cancelled command %s just right before its end: %s", + commandId, e.getMessage())); } } @@ -927,7 +933,7 @@ public class GrpcServerImpl implements RPCServer { @Override public void cancel( final CancelRequest request, final StreamObserver<CancelResponse> streamObserver) { - log.info(String.format("Got CancelRequest for command id %s", request.getCommandId())); + logger.info(String.format("Got CancelRequest for command id %s", request.getCommandId())); if (!request.getCookie().equals(requestCookie)) { streamObserver.onCompleted(); return; @@ -944,14 +950,14 @@ public class GrpcServerImpl implements RPCServer { synchronized (runningCommands) { RunningCommand pendingCommand = runningCommands.get(request.getCommandId()); if (pendingCommand != null) { - log.info( + logger.info( String.format( "Interrupting command %s on thread %s", request.getCommandId(), pendingCommand.thread.getName())); pendingCommand.thread.interrupt(); startSlowInterruptWatcher(ImmutableSet.of(request.getCommandId())); } else { - log.info("Cannot find command " + request.getCommandId() + " to interrupt"); + logger.info("Cannot find command " + request.getCommandId() + " to interrupt"); } } @@ -960,7 +966,7 @@ public class GrpcServerImpl implements RPCServer { streamObserver.onCompleted(); } catch (StatusRuntimeException e) { // There is no one to report the failure to - log.info( + logger.info( "Client cancelled RPC of cancellation request for " + request.getCommandId()); } } diff --git a/src/main/java/com/google/devtools/build/lib/server/IdleServerTasks.java b/src/main/java/com/google/devtools/build/lib/server/IdleServerTasks.java index db7cd4df0b..0a2c702e45 100644 --- a/src/main/java/com/google/devtools/build/lib/server/IdleServerTasks.java +++ b/src/main/java/com/google/devtools/build/lib/server/IdleServerTasks.java @@ -37,7 +37,7 @@ class IdleServerTasks { private final Path workspaceDir; private final ScheduledThreadPoolExecutor executor; - private static final Logger log = Logger.getLogger(IdleServerTasks.class.getName()); + private static final Logger logger = Logger.getLogger(IdleServerTasks.class.getName()); private static final long FIVE_MIN_MILLIS = 1000 * 60 * 5; @@ -57,10 +57,11 @@ class IdleServerTasks { Preconditions.checkState(!executor.isShutdown()); // Do a GC cycle while the server is idle. - @SuppressWarnings("unused") + @SuppressWarnings("unused") Future<?> possiblyIgnoredError = - executor.schedule(() -> { - try (AutoProfiler p = AutoProfiler.logged("Idle GC", log)) { + executor.schedule( + () -> { + try (AutoProfiler p = AutoProfiler.logged("Idle GC", logger)) { System.gc(); } }, @@ -130,7 +131,7 @@ class IdleServerTasks { try { memInfo = new ProcMeminfoParser(); } catch (IOException e) { - log.info("Could not process /proc/meminfo: " + e); + logger.info("Could not process /proc/meminfo: " + e); return true; } @@ -150,9 +151,8 @@ class IdleServerTasks { // If the system as a whole is low on memory, let this server die. if (fractionFree < .1) { - log.info("Terminating due to memory constraints"); - log.info(String.format("Total physical:%d\nTotal free: %d\n", - totalPhysical, totalFree)); + logger.info("Terminating due to memory constraints"); + logger.info(String.format("Total physical:%d\nTotal free: %d\n", totalPhysical, totalFree)); return false; } diff --git a/src/main/java/com/google/devtools/build/lib/shell/Command.java b/src/main/java/com/google/devtools/build/lib/shell/Command.java index 8413441f1f..46eefeec6a 100644 --- a/src/main/java/com/google/devtools/build/lib/shell/Command.java +++ b/src/main/java/com/google/devtools/build/lib/shell/Command.java @@ -113,8 +113,8 @@ import javax.annotation.Nullable; */ public final class Command { - private static final Logger log = - Logger.getLogger("com.google.devtools.build.lib.shell.Command"); + private static final Logger logger = + Logger.getLogger("com.google.devtools.build.lib.shell.Command"); /** Pass this value to {@link #execute} to indicate that no input should be written to stdin. */ public static final InputStream NO_INPUT = new NullInputStream(); @@ -408,8 +408,8 @@ public final class Command { } private static void processInput(InputStream stdinInput, Subprocess process) { - if (log.isLoggable(Level.FINER)) { - log.finer(stdinInput.toString()); + if (logger.isLoggable(Level.FINER)) { + logger.finer(stdinInput.toString()); } try (OutputStream out = process.getOutputStream()) { ByteStreams.copy(stdinInput, out); @@ -428,11 +428,11 @@ public final class Command { private CommandResult waitForProcessToComplete( Subprocess process, Consumers.OutErrConsumers outErr, boolean killSubprocessOnInterrupt) throws AbnormalTerminationException { - log.finer("Waiting for process..."); + logger.finer("Waiting for process..."); TerminationStatus status = waitForProcess(process, killSubprocessOnInterrupt); - log.finer(status.toString()); + logger.finer(status.toString()); try { if (Thread.currentThread().isInterrupted()) { @@ -498,9 +498,9 @@ public final class Command { } private void logCommand() { - if (!log.isLoggable(Level.FINE)) { + if (!logger.isLoggable(Level.FINE)) { return; } - log.fine(toDebugString()); + logger.fine(toDebugString()); } } diff --git a/src/main/java/com/google/devtools/build/lib/shell/CommandResult.java b/src/main/java/com/google/devtools/build/lib/shell/CommandResult.java index a682779a4e..24e0947258 100644 --- a/src/main/java/com/google/devtools/build/lib/shell/CommandResult.java +++ b/src/main/java/com/google/devtools/build/lib/shell/CommandResult.java @@ -26,8 +26,8 @@ import java.util.logging.Logger; */ public final class CommandResult { - private static final Logger log = - Logger.getLogger("com.google.devtools.build.lib.shell.Command"); + private static final Logger logger = + Logger.getLogger("com.google.devtools.build.lib.shell.Command"); private static final byte[] NO_BYTES = new byte[0]; @@ -90,16 +90,16 @@ public final class CommandResult { } void logThis() { - if (!log.isLoggable(Level.FINER)) { + if (!logger.isLoggable(Level.FINER)) { return; } - log.finer(terminationStatus.toString()); + logger.finer(terminationStatus.toString()); if (stdout == NO_OUTPUT_COLLECTED) { return; } - log.finer("Stdout: " + LogUtil.toTruncatedString(stdout.toByteArray())); - log.finer("Stderr: " + LogUtil.toTruncatedString(stderr.toByteArray())); + logger.finer("Stdout: " + LogUtil.toTruncatedString(stdout.toByteArray())); + logger.finer("Stderr: " + LogUtil.toTruncatedString(stderr.toByteArray())); } } diff --git a/src/main/java/com/google/devtools/build/lib/shell/Consumers.java b/src/main/java/com/google/devtools/build/lib/shell/Consumers.java index b3864d36da..94e2d74349 100644 --- a/src/main/java/com/google/devtools/build/lib/shell/Consumers.java +++ b/src/main/java/com/google/devtools/build/lib/shell/Consumers.java @@ -37,8 +37,8 @@ import java.util.logging.Logger; */ final class Consumers { - private static final Logger log = - Logger.getLogger("com.google.devtools.build.lib.shell.Command"); + private static final Logger logger = + Logger.getLogger("com.google.devtools.build.lib.shell.Command"); private Consumers() {} @@ -137,7 +137,7 @@ final class Consumers { @Override public void logConsumptionStrategy() { - log.finer("Output will be sent to streams provided by client"); + logger.finer("Output will be sent to streams provided by client"); } @Override protected Runnable createConsumingAndClosingSink(InputStream in, @@ -161,7 +161,7 @@ final class Consumers { @Override public void logConsumptionStrategy() { - log.finer("Output will be accumulated (promptly read off) and returned"); + logger.finer("Output will be accumulated (promptly read off) and returned"); } @Override public Runnable createConsumingAndClosingSink(InputStream in, boolean closeConsumer) { @@ -183,7 +183,7 @@ final class Consumers { @Override public void logConsumptionStrategy() { - log.finer("Output will be ignored"); + logger.finer("Output will be ignored"); } @Override public Runnable createConsumingAndClosingSink(InputStream in, boolean closeConsumer) { @@ -325,7 +325,7 @@ final class Consumers { closeable.close(); } catch (IOException ioe) { String message = "Unexpected exception while closing input stream"; - log.log(Level.WARNING, message, ioe); + logger.log(Level.WARNING, message, ioe); } } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/DiffAwarenessManager.java b/src/main/java/com/google/devtools/build/lib/skyframe/DiffAwarenessManager.java index 76f00a7fb4..26b90b59a2 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/DiffAwarenessManager.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/DiffAwarenessManager.java @@ -31,7 +31,7 @@ import javax.annotation.Nullable; */ public final class DiffAwarenessManager { - private static final Logger LOG = Logger.getLogger(DiffAwarenessManager.class.getName()); + private static final Logger logger = Logger.getLogger(DiffAwarenessManager.class.getName()); // The manager attempts to instantiate these in the order in which they are passed to the // constructor; this is critical in the case where a factory always succeeds. @@ -97,14 +97,14 @@ public final class DiffAwarenessManager { View baselineView = diffAwarenessState.baselineView; if (baselineView == null) { - LOG.info("Initial baseline view for " + pathEntry + " is " + newView); + logger.info("Initial baseline view for " + pathEntry + " is " + newView); diffAwarenessState.baselineView = newView; return BrokenProcessableModifiedFileSet.INSTANCE; } ModifiedFileSet diff; - LOG.info("About to compute diff between " + baselineView + " and " + newView + " for " - + pathEntry); + logger.info( + "About to compute diff between " + baselineView + " and " + newView + " for " + pathEntry); try { diff = diffAwareness.getDiff(baselineView, newView); } catch (BrokenDiffAwarenessException e) { @@ -122,7 +122,7 @@ public final class DiffAwarenessManager { private void handleBrokenDiffAwareness( EventHandler eventHandler, Path pathEntry, BrokenDiffAwarenessException e) { currentDiffAwarenessStates.remove(pathEntry); - LOG.info("Broken diff awareness for " + pathEntry + ": " + e); + logger.info("Broken diff awareness for " + pathEntry + ": " + e); eventHandler.handle(Event.warn(e.getMessage() + "... temporarily falling back to manually " + "checking files for changes")); } @@ -140,7 +140,8 @@ public final class DiffAwarenessManager { for (DiffAwareness.Factory factory : diffAwarenessFactories) { DiffAwareness newDiffAwareness = factory.maybeCreate(pathEntry); if (newDiffAwareness != null) { - LOG.info("Using " + newDiffAwareness.name() + " DiffAwareness strategy for " + pathEntry); + logger.info( + "Using " + newDiffAwareness.name() + " DiffAwareness strategy for " + pathEntry); diffAwarenessState = new DiffAwarenessState(newDiffAwareness, /*previousView=*/null); currentDiffAwarenessStates.put(pathEntry, diffAwarenessState); return diffAwarenessState; diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ExternalFilesHelper.java b/src/main/java/com/google/devtools/build/lib/skyframe/ExternalFilesHelper.java index efdff45af3..e589cd8f41 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ExternalFilesHelper.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ExternalFilesHelper.java @@ -30,7 +30,7 @@ import java.util.logging.Logger; /** Common utilities for dealing with paths outside the package roots. */ public class ExternalFilesHelper { - private static final Logger LOG = Logger.getLogger(ExternalFilesHelper.class.getName()); + private static final Logger logger = Logger.getLogger(ExternalFilesHelper.class.getName()); private static final int MAX_NUM_EXTERNAL_FILES_TO_LOG = 100; private final AtomicReference<PathPackageLocator> pkgLocator; @@ -187,7 +187,7 @@ public class ExternalFilesHelper { } if (fileType == FileType.EXTERNAL && numExternalFilesLogged.incrementAndGet() < MAX_NUM_EXTERNAL_FILES_TO_LOG) { - LOG.info("Encountered an external path " + rootedPath); + logger.info("Encountered an external path " + rootedPath); } return; } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/FilesystemValueChecker.java b/src/main/java/com/google/devtools/build/lib/skyframe/FilesystemValueChecker.java index 4bd6dc804b..52ef735822 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/FilesystemValueChecker.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/FilesystemValueChecker.java @@ -70,7 +70,7 @@ import javax.annotation.Nullable; public class FilesystemValueChecker { private static final int DIRTINESS_CHECK_THREADS = 200; - private static final Logger LOG = Logger.getLogger(FilesystemValueChecker.class.getName()); + private static final Logger logger = Logger.getLogger(FilesystemValueChecker.class.getName()); private static final Predicate<SkyKey> ACTION_FILTER = SkyFunctionName.functionIs(SkyFunctions.ACTION_EXECUTION); @@ -162,10 +162,10 @@ public class FilesystemValueChecker { @Nullable final BatchStat batchStatter, ModifiedFileSet modifiedOutputFiles) throws InterruptedException { if (modifiedOutputFiles == ModifiedFileSet.NOTHING_MODIFIED) { - LOG.info("Not checking for dirty actions since nothing was modified"); + logger.info("Not checking for dirty actions since nothing was modified"); return ImmutableList.of(); } - LOG.info("Accumulating dirty actions"); + logger.info("Accumulating dirty actions"); final int numOutputJobs = Runtime.getRuntime().availableProcessors() * 4; final Set<SkyKey> actionSkyKeys = new HashSet<>(); for (SkyKey key : valuesMap.keySet()) { @@ -179,7 +179,7 @@ public class FilesystemValueChecker { for (SkyKey key : actionSkyKeys) { outputShards.add(Pair.of(key, (ActionExecutionValue) valuesMap.get(key))); } - LOG.info("Sharded action values for batching"); + logger.info("Sharded action values for batching"); ExecutorService executor = Executors.newFixedThreadPool( numOutputJobs, @@ -221,7 +221,7 @@ public class FilesystemValueChecker { boolean interrupted = ExecutorUtil.interruptibleShutdown(executor); Throwables.propagateIfPossible(wrapper.getFirstThrownError()); - LOG.info("Completed output file stat checks"); + logger.info("Completed output file stat checks"); if (interrupted) { throw new InterruptedException(); } @@ -260,12 +260,15 @@ public class FilesystemValueChecker { List<Artifact> artifacts = ImmutableList.copyOf(fileToKeyAndValue.keySet()); List<FileStatusWithDigest> stats; try { - stats = batchStatter.batchStat(/*includeDigest=*/true, /*includeLinks=*/true, - Artifact.asPathFragments(artifacts)); + stats = + batchStatter.batchStat( + /*includeDigest=*/ true, + /*includeLinks=*/ true, + Artifact.asPathFragments(artifacts)); } catch (IOException e) { // Batch stat did not work. Log an exception and fall back on system calls. LoggingUtil.logToRemote(Level.WARNING, "Unable to process batch stat", e); - LOG.log(Level.WARNING, "Unable to process batch stat", e); + logger.log(Level.WARNING, "Unable to process batch stat", e); outputStatJob(dirtyKeys, shard, knownModifiedOutputFiles, sortedKnownModifiedOutputFiles) .run(); return; @@ -274,8 +277,11 @@ public class FilesystemValueChecker { return; } - Preconditions.checkState(artifacts.size() == stats.size(), - "artifacts.size() == %s stats.size() == %s", artifacts.size(), stats.size()); + Preconditions.checkState( + artifacts.size() == stats.size(), + "artifacts.size() == %s stats.size() == %s", + artifacts.size(), + stats.size()); for (int i = 0; i < artifacts.size(); i++) { Artifact artifact = artifacts.get(i); FileStatusWithDigest stat = stats.get(i); @@ -284,11 +290,12 @@ public class FilesystemValueChecker { SkyKey key = keyAndValue.getFirst(); FileValue lastKnownData = actionValue.getAllFileValues().get(artifact); try { - FileValue newData = ActionMetadataHandler.fileValueFromArtifact(artifact, stat, - tsgm); + FileValue newData = ActionMetadataHandler.fileValueFromArtifact(artifact, stat, tsgm); if (!newData.equals(lastKnownData)) { - updateIntraBuildModifiedCounter(stat != null ? stat.getLastChangeTime() : -1, - lastKnownData.isSymlink(), newData.isSymlink()); + updateIntraBuildModifiedCounter( + stat != null ? stat.getLastChangeTime() : -1, + lastKnownData.isSymlink(), + newData.isSymlink()); modifiedOutputFilesCounter.getAndIncrement(); dirtyKeys.add(key); } @@ -310,9 +317,8 @@ public class FilesystemValueChecker { // Count the changed directory as one "file". // TODO(bazel-team): There are no tests for this codepath. try { - updateIntraBuildModifiedCounter(path.exists() - ? path.getLastModifiedTime() - : -1, false, path.isSymbolicLink()); + updateIntraBuildModifiedCounter( + path.exists() ? path.getLastModifiedTime() : -1, false, path.isSymbolicLink()); } catch (IOException e) { // Do nothing here. } @@ -470,17 +476,20 @@ public class FilesystemValueChecker { new ThrowableRecordingRunnableWrapper("FilesystemValueChecker#getDirtyValues"); final AtomicInteger numKeysScanned = new AtomicInteger(0); final AtomicInteger numKeysChecked = new AtomicInteger(0); - ElapsedTimeReceiver elapsedTimeReceiver = new ElapsedTimeReceiver() { - @Override - public void accept(long elapsedTimeNanos) { - if (elapsedTimeNanos > 0) { - LOG.info(String.format("Spent %d ms checking %d filesystem nodes (%d scanned)", - TimeUnit.MILLISECONDS.convert(elapsedTimeNanos, TimeUnit.NANOSECONDS), - numKeysChecked.get(), - numKeysScanned.get())); + ElapsedTimeReceiver elapsedTimeReceiver = + new ElapsedTimeReceiver() { + @Override + public void accept(long elapsedTimeNanos) { + if (elapsedTimeNanos > 0) { + logger.info( + String.format( + "Spent %d ms checking %d filesystem nodes (%d scanned)", + TimeUnit.MILLISECONDS.convert(elapsedTimeNanos, TimeUnit.NANOSECONDS), + numKeysChecked.get(), + numKeysScanned.get())); + } } - } - }; + }; try (AutoProfiler prof = AutoProfiler.create(elapsedTimeReceiver)) { for (final SkyKey key : keys) { numKeysScanned.incrementAndGet(); diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/LegacyLoadingPhaseRunner.java b/src/main/java/com/google/devtools/build/lib/skyframe/LegacyLoadingPhaseRunner.java index e5b57adecf..21ef63412f 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/LegacyLoadingPhaseRunner.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/LegacyLoadingPhaseRunner.java @@ -69,7 +69,7 @@ import javax.annotation.Nullable; * <p>The Skyframe-based re-implementation of this class is in TargetPatternPhaseFunction. */ public final class LegacyLoadingPhaseRunner extends LoadingPhaseRunner { - private static final Logger LOG = Logger.getLogger(LoadingPhaseRunner.class.getName()); + private static final Logger logger = Logger.getLogger(LoadingPhaseRunner.class.getName()); private final PackageManager packageManager; private final TargetPatternEvaluator targetPatternEvaluator; @@ -96,7 +96,7 @@ public final class LegacyLoadingPhaseRunner extends LoadingPhaseRunner { boolean determineTests, @Nullable LoadingCallback callback) throws TargetParsingException, LoadingFailedException, InterruptedException { - LOG.info("Starting pattern evaluation"); + logger.info("Starting pattern evaluation"); Stopwatch timer = Stopwatch.createStarted(); if (options.buildTestsOnly && options.compileOneDependency) { throw new LoadingFailedException( @@ -175,7 +175,7 @@ public final class LegacyLoadingPhaseRunner extends LoadingPhaseRunner { LoadingPhaseRunner.maybeReportDeprecation(eventHandler, targets.getTargets()); long targetPatternEvalTime = timer.stop().elapsed(TimeUnit.MILLISECONDS); - LOG.info("Starting test suite expansion"); + logger.info("Starting test suite expansion"); timer = Stopwatch.createStarted(); ImmutableSet<Target> targetsToLoad = targets.getTargets(); @@ -219,7 +219,7 @@ public final class LegacyLoadingPhaseRunner extends LoadingPhaseRunner { patternParsingValue.getTestSuiteTargets(), packageManager.getAndClearStatistics(), testSuiteTime)); - LOG.info("Target pattern evaluation finished"); + logger.info("Target pattern evaluation finished"); return patternParsingValue.toLoadingResult(); } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java index 59f9b17cde..e4859d10bb 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java @@ -90,7 +90,7 @@ import java.util.logging.Logger; */ public final class SequencedSkyframeExecutor extends SkyframeExecutor { - private static final Logger LOG = Logger.getLogger(SequencedSkyframeExecutor.class.getName()); + private static final Logger logger = Logger.getLogger(SequencedSkyframeExecutor.class.getName()); private boolean lastAnalysisDiscarded = false; @@ -411,8 +411,9 @@ public final class SequencedSkyframeExecutor extends SkyframeExecutor { EnumSet<FileType> fileTypesToCheck = checkOutputFiles ? EnumSet.of(FileType.EXTERNAL, FileType.EXTERNAL_REPO, FileType.OUTPUT) : EnumSet.of(FileType.EXTERNAL, FileType.EXTERNAL_REPO); - LOG.info("About to scan skyframe graph checking for filesystem nodes of types " - + Iterables.toString(fileTypesToCheck)); + logger.info( + "About to scan skyframe graph checking for filesystem nodes of types " + + Iterables.toString(fileTypesToCheck)); Differencer.Diff diff = fsvc.getDirtyKeys( memoizingEvaluator.getValues(), @@ -478,7 +479,7 @@ public final class SequencedSkyframeExecutor extends SkyframeExecutor { } } - LOG.info(result.toString()); + logger.info(result.toString()); } private static int getNumberOfModifiedFiles(Iterable<SkyKey> modifiedValues) { @@ -502,7 +503,7 @@ public final class SequencedSkyframeExecutor extends SkyframeExecutor { incrementalState); incrementalState = IncrementalState.CLEAR_EDGES_AND_ACTIONS; // Graph will be recreated on next sync. - LOG.info("Set incremental state to " + incrementalState); + logger.info("Set incremental state to " + incrementalState); } removeActionsAfterEvaluation.set(incrementalState == IncrementalState.CLEAR_EDGES_AND_ACTIONS); } @@ -575,7 +576,7 @@ public final class SequencedSkyframeExecutor extends SkyframeExecutor { Collection<ConfiguredTarget> topLevelTargets, Collection<AspectValue> topLevelAspects) { topLevelTargets = ImmutableSet.copyOf(topLevelTargets); topLevelAspects = ImmutableSet.copyOf(topLevelAspects); - try (AutoProfiler p = AutoProfiler.logged("discarding analysis cache", LOG)) { + try (AutoProfiler p = AutoProfiler.logged("discarding analysis cache", logger)) { lastAnalysisDiscarded = true; Iterator<? extends Map.Entry<SkyKey, ? extends NodeEntry>> it = memoizingEvaluator.getGraphMap().entrySet().iterator(); diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java index bfd7cb7fcf..d46779124c 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java @@ -292,7 +292,7 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory { private PerBuildSyscallCache perBuildSyscallCache; private int lastConcurrencyLevel = -1; - private static final Logger LOG = Logger.getLogger(SkyframeExecutor.class.getName()); + private static final Logger logger = Logger.getLogger(SkyframeExecutor.class.getName()); protected SkyframeExecutor( EvaluatorSupplier evaluatorSupplier, @@ -837,7 +837,7 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory { // modified files for targets in current request. Skyframe may check for modification all files // from previous requests. protected void informAboutNumberOfModifiedFiles() { - LOG.info(String.format("Found %d modified files from last build", modifiedFiles)); + logger.info(String.format("Found %d modified files from last build", modifiedFiles)); } public EventBus getEventBus() { @@ -884,8 +884,9 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory { // information here, so we compute it ourselves. // TODO(bazel-team): Fancy filesystems could provide it with a hypothetically modified // DiffAwareness interface. - LOG.info("About to recompute filesystem nodes corresponding to files that are known to have " - + "changed"); + logger.info( + "About to recompute filesystem nodes corresponding to files that are known to have " + + "changed"); FilesystemValueChecker fsvc = new FilesystemValueChecker(tsgm, null); Map<SkyKey, SkyValue> valuesMap = memoizingEvaluator.getValues(); Differencer.DiffWithDelta diff = @@ -1145,7 +1146,7 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory { || skyframeBuildView.isSomeConfiguredTargetInvalidated()) { // This operation is somewhat expensive, so we only do it if the graph might have changed in // some way -- either we analyzed a new target or we invalidated an old one. - try (AutoProfiler p = AutoProfiler.logged("discovering artifact conflicts", LOG)) { + try (AutoProfiler p = AutoProfiler.logged("discovering artifact conflicts", logger)) { skyframeActionExecutor.findAndStoreArtifactConflicts(getActionLookupValues()); skyframeBuildView.resetEvaluatedConfiguredTargetFlag(); // The invalidated configured targets flag will be reset later in the evaluate() call. diff --git a/src/main/java/com/google/devtools/build/lib/util/PersistentMap.java b/src/main/java/com/google/devtools/build/lib/util/PersistentMap.java index 4e3ad87d9b..f1979ad65c 100644 --- a/src/main/java/com/google/devtools/build/lib/util/PersistentMap.java +++ b/src/main/java/com/google/devtools/build/lib/util/PersistentMap.java @@ -71,7 +71,7 @@ public abstract class PersistentMap<K, V> extends ForwardingMap<K, V> { private static final int ENTRY_MAGIC = 0xfe; private static final int MIN_MAPFILE_SIZE = 16; private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8; - private static final Logger LOG = Logger.getLogger(PersistentMap.class.getName()); + private static final Logger logger = Logger.getLogger(PersistentMap.class.getName()); private final int version; private final Path mapFile; @@ -388,7 +388,7 @@ public abstract class PersistentMap<K, V> extends ForwardingMap<K, V> { in.close(); } - LOG.info(String.format("Loaded cache '%s' [%s bytes]", mapFile, fileSize)); + logger.info(String.format("Loaded cache '%s' [%s bytes]", mapFile, fileSize)); } /** diff --git a/src/main/java/com/google/devtools/build/lib/util/ThreadUtils.java b/src/main/java/com/google/devtools/build/lib/util/ThreadUtils.java index 7f74e2e09b..cec0a971b8 100644 --- a/src/main/java/com/google/devtools/build/lib/util/ThreadUtils.java +++ b/src/main/java/com/google/devtools/build/lib/util/ThreadUtils.java @@ -13,7 +13,6 @@ // limitations under the License. package com.google.devtools.build.lib.util; - import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; @@ -22,22 +21,22 @@ import java.util.logging.Logger; * Utility methods relating to threads and stack traces. */ public class ThreadUtils { - private static final Logger LOG = Logger.getLogger(ThreadUtils.class.getName()); + private static final Logger logger = Logger.getLogger(ThreadUtils.class.getName()); private ThreadUtils() { } /** Write a thread dump to the blaze.INFO log if interrupt took too long. */ public static synchronized void warnAboutSlowInterrupt() { - LOG.warning("Interrupt took too long. Dumping thread state."); + logger.warning("Interrupt took too long. Dumping thread state."); for (Map.Entry <Thread, StackTraceElement[]> e : Thread.getAllStackTraces().entrySet()) { Thread t = e.getKey(); - LOG.warning("\"" + t.getName() + "\"" + " " - + " Thread id=" + t.getId() + " " + t.getState()); + logger.warning( + "\"" + t.getName() + "\"" + " " + " Thread id=" + t.getId() + " " + t.getState()); for (StackTraceElement line : e.getValue()) { - LOG.warning("\t" + line); + logger.warning("\t" + line); } - LOG.warning(""); + logger.warning(""); } LoggingUtil.logToRemote(Level.WARNING, "Slow interrupt", new SlowInterruptException()); } diff --git a/src/main/java/com/google/devtools/build/lib/util/io/AnsiTerminalPrinter.java b/src/main/java/com/google/devtools/build/lib/util/io/AnsiTerminalPrinter.java index 1341cb2e43..e1dd5e5ec3 100644 --- a/src/main/java/com/google/devtools/build/lib/util/io/AnsiTerminalPrinter.java +++ b/src/main/java/com/google/devtools/build/lib/util/io/AnsiTerminalPrinter.java @@ -15,7 +15,6 @@ package com.google.devtools.build.lib.util.io; import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadCompatible; - import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; @@ -64,7 +63,7 @@ public class AnsiTerminalPrinter { } } - private static final Logger LOG = Logger.getLogger(AnsiTerminalPrinter.class.getName()); + private static final Logger logger = Logger.getLogger(AnsiTerminalPrinter.class.getName()); private static final EnumSet<Mode> MODES = EnumSet.allOf(Mode.class); private static final Pattern PATTERN = Pattern.compile(MODE_PATTERN); @@ -149,7 +148,7 @@ public class AnsiTerminalPrinter { } catch (IOException e) { // AnsiTerminal state is now considered to be inconsistent - coloring // should be disabled to prevent future use of AnsiTerminal instance. - LOG.warning("Disabling coloring due to " + e.getMessage()); + logger.warning("Disabling coloring due to " + e.getMessage()); useColor = false; } } diff --git a/src/main/java/com/google/devtools/build/lib/util/io/TimestampGranularityMonitor.java b/src/main/java/com/google/devtools/build/lib/util/io/TimestampGranularityMonitor.java index 2924b3777f..874703086f 100644 --- a/src/main/java/com/google/devtools/build/lib/util/io/TimestampGranularityMonitor.java +++ b/src/main/java/com/google/devtools/build/lib/util/io/TimestampGranularityMonitor.java @@ -19,7 +19,6 @@ import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe; import com.google.devtools.build.lib.profiler.Profiler; import com.google.devtools.build.lib.profiler.ProfilerTask; import com.google.devtools.build.lib.util.Clock; - import com.google.devtools.build.lib.vfs.PathFragment; import java.util.logging.Logger; @@ -75,7 +74,8 @@ import java.util.logging.Logger; */ @ThreadCompatible public class TimestampGranularityMonitor { - private static final Logger log = Logger.getLogger(TimestampGranularityMonitor.class.getName()); + private static final Logger logger = + Logger.getLogger(TimestampGranularityMonitor.class.getName()); /** * The time of the start of the current Blaze command, @@ -127,11 +127,11 @@ public class TimestampGranularityMonitor { @ThreadSafe public void notifyDependenceOnFileTime(PathFragment path, long mtime) { if (mtime == this.commandStartTimeMillis) { - log.info("Will have to wait for a millisecond on completion because of " + path); + logger.info("Will have to wait for a millisecond on completion because of " + path); this.waitAMillisecond = true; } if (mtime == this.commandStartTimeMillisRounded) { - log.info("Will have to wait for a second on completion because of " + path); + logger.info("Will have to wait for a second on completion because of " + path); this.waitASecond = true; } } @@ -187,8 +187,11 @@ public class TimestampGranularityMonitor { Profiler.instance().logSimpleTask(startedWaiting, ProfilerTask.WAIT, "Timestamp granularity"); - log.info("Waited for " + (clock.currentTimeMillis() - before) + "ms for file system" - + " to catch up"); + logger.info( + "Waited for " + + (clock.currentTimeMillis() - before) + + "ms for file system" + + " to catch up"); } } diff --git a/src/main/java/com/google/devtools/build/lib/vfs/ZipFileSystem.java b/src/main/java/com/google/devtools/build/lib/vfs/ZipFileSystem.java index aa9ad1ae29..92117434b2 100644 --- a/src/main/java/com/google/devtools/build/lib/vfs/ZipFileSystem.java +++ b/src/main/java/com/google/devtools/build/lib/vfs/ZipFileSystem.java @@ -37,7 +37,7 @@ import java.util.zip.ZipFile; */ @ThreadCompatible // Can only be accessed from one thread at a time (including its Path objects) public class ZipFileSystem extends ReadonlyFileSystem implements Closeable { - private static final Logger log = Logger.getLogger(ZipFileSystem.class.getName()); + private static final Logger logger = Logger.getLogger(ZipFileSystem.class.getName()); private final File tempFile; // In case this needs to be written to the file system private final ZipFile zipFile; @@ -312,8 +312,9 @@ public class ZipFileSystem extends ReadonlyFileSystem implements Closeable { zipFile.close(); } catch (IOException e) { // Not a lot can be done about this. Log an error and move on. - log.warning(String.format( - "Error while closing zip file '%s': %s", zipFile.getName(), e.getMessage())); + logger.warning( + String.format( + "Error while closing zip file '%s': %s", zipFile.getName(), e.getMessage())); } if (tempFile != null) { tempFile.delete(); diff --git a/src/main/java/com/google/devtools/common/options/InvocationPolicyEnforcer.java b/src/main/java/com/google/devtools/common/options/InvocationPolicyEnforcer.java index e76688c6d0..37753a9955 100644 --- a/src/main/java/com/google/devtools/common/options/InvocationPolicyEnforcer.java +++ b/src/main/java/com/google/devtools/common/options/InvocationPolicyEnforcer.java @@ -49,7 +49,7 @@ import javax.annotation.Nullable; */ public final class InvocationPolicyEnforcer { - private static final Logger log = Logger.getLogger(InvocationPolicyEnforcer.class.getName()); + private static final Logger logger = Logger.getLogger(InvocationPolicyEnforcer.class.getName()); private static final Function<Object, String> INVOCATION_POLICY_SOURCE = o -> "Invocation policy"; @@ -108,7 +108,7 @@ public final class InvocationPolicyEnforcer { // This flag doesn't exist. We are deliberately lenient if the flag policy has a flag // we don't know about. This is for better future proofing so that as new flags are added, // new policies can use the new flags without worrying about older versions of Bazel. - log.info( + logger.info( String.format("Flag '%s' specified by invocation policy does not exist", flagName)); continue; } @@ -156,11 +156,10 @@ public final class InvocationPolicyEnforcer { throw new PolicyOperationNotSetException(flagName); default: - log.warning( + logger.warning( String.format( "Unknown operation '%s' from invocation policy for flag '%s'", - flagPolicy.getOperationCase(), - flagName)); + flagPolicy.getOperationCase(), flagName)); break; } } @@ -273,7 +272,7 @@ public final class InvocationPolicyEnforcer { case OPERATION_NOT_SET: throw new PolicyOperationNotSetException(expansionPolicy.getFlagName()); default: - log.warning( + logger.warning( String.format( "Unknown operation '%s' from invocation policy for flag '%s'", expansionPolicy.getOperationCase(), expansionFlagName)); @@ -313,7 +312,7 @@ public final class InvocationPolicyEnforcer { .build(); boolean isExpansion = originalOptionDescription.isExpansion(); - if (!subflags.isEmpty() && log.isLoggable(Level.FINE)) { + if (!subflags.isEmpty() && logger.isLoggable(Level.FINE)) { // Log the expansion. Since this is logged regardless of user provided command line, it is // only really useful for understanding the invocation policy itself. Most of the time, // invocation policy does not change, so this can be a log level fine. @@ -322,15 +321,16 @@ public final class InvocationPolicyEnforcer { subflagNames.add("--" + subflag.getName()); } - log.logp(Level.FINE, + logger.logp( + Level.FINE, "InvocationPolicyEnforcer", "expandPolicy", String.format( - "Expanding %s on option %s to its %s: %s.", - originalPolicy.getOperationCase(), - originalPolicy.getFlagName(), - isExpansion ? "expansions" : "implied flags", - Joiner.on("; ").join(subflagNames))); + "Expanding %s on option %s to its %s: %s.", + originalPolicy.getOperationCase(), + originalPolicy.getFlagName(), + isExpansion ? "expansions" : "implied flags", + Joiner.on("; ").join(subflagNames))); } // Repeated flags are special, and could set multiple times in an expansion, with the user @@ -489,7 +489,7 @@ public final class InvocationPolicyEnforcer { private static void logInApplySetValueOperation(String formattingString, Object... objects) { // Finding the caller here is relatively expensive and shows up in profiling, so provide it // manually. - log.logp( + logger.logp( Level.INFO, "InvocationPolicyEnforcer", "applySetValueOperation", @@ -573,15 +573,11 @@ public final class InvocationPolicyEnforcer { if (desc != null) { clearedFlagDefaultValue = desc.getOptionDefinition().getDefaultValue(); } - log.info( + logger.info( String.format( "Using default value '%s' for flag '%s' as " + "specified by %s invocation policy, overriding original value '%s' from '%s'", - clearedFlagDefaultValue, - clearedFlagName, - policyType, - originalValue, - source)); + clearedFlagDefaultValue, clearedFlagName, policyType, originalValue, source)); } } @@ -713,7 +709,7 @@ public final class InvocationPolicyEnforcer { convertedPolicyValues, optionDescription.getOptionDefinition().getDefaultValue())) { if (newValue != null) { // Use the default value from the policy. - log.info( + logger.info( String.format( "Overriding default value '%s' for flag '%s' with value '%s' " + "specified by invocation policy. %sed values are: %s", @@ -775,15 +771,11 @@ public final class InvocationPolicyEnforcer { if (!isFlagValueAllowed(convertedPolicyValues, valueDescription.getValue())) { if (newValue != null) { - log.info( + logger.info( String.format( "Overriding disallowed value '%s' for flag '%s' with value '%s' " + "specified by invocation policy. %sed values are: %s", - valueDescription.getValue(), - flagName, - newValue, - policyType, - policyValues)); + valueDescription.getValue(), flagName, newValue, policyType, policyValues)); parser.clearValue(flagName); setFlagValue(parser, flagName, newValue); } else if (useDefault) { |