@Override public boolean isEnabled(LogLevel level) { org.gradle.api.logging.LogLevel logLevel; switch (level) { case DEBUG: logLevel = org.gradle.api.logging.LogLevel.DEBUG; break; case INFO: logLevel = org.gradle.api.logging.LogLevel.INFO; break; case LIFECYCLE: logLevel = org.gradle.api.logging.LogLevel.LIFECYCLE; break; case WARN: logLevel = org.gradle.api.logging.LogLevel.WARN; break; case QUIET: logLevel = org.gradle.api.logging.LogLevel.QUIET; break; default: logLevel = org.gradle.api.logging.LogLevel.ERROR; break; } return logger.isEnabled(logLevel); }
static void logMsg(LogLevel level, PrintWriter printWriter, String format, Object arg) { log.log(level, format, arg); if (printWriter != null && log.isEnabled(level)) { printWriter.printf(format.replace("{}", "%s"), arg); printWriter.println(); } }
static void logMsg(LogLevel level, PrintWriter printWriter, String format, Object arg1, Object arg2) { log.log(level, format, arg1, arg2); if (printWriter != null && log.isEnabled(level)) { printWriter.printf(format.replace("{}", "%s"), arg1, arg2); printWriter.println(); } } }
static void logMsg(LogLevel level, PrintWriter printWriter, String msg) { log.log(level, msg); if (printWriter != null && log.isEnabled(level)) { printWriter.println(msg); } }
@Override public void console(String rawString) { // Cloud SDK installation is somewhat verbose, so we'd like to log it at the LIFECYCLE level. // Gradle's logging api doesn't let us log without adding a newline at the end of the message, // so we need to use System.out.print() to display rawString in its original format. The problem // is that Gradle redirects standard output to its logging system at the QUIET level. So, in // order to print to LIFECYCLE without adding a newline, we just check that our desired level // is enabled before trying to print. if (project.getLogger().isEnabled(LogLevel.LIFECYCLE)) { System.out.print(rawString); } } }
private boolean isInfoLog() { return project.getLogger().isEnabled(LogLevel.INFO); }
private boolean isDebugLog() { return project.getLogger().isEnabled(LogLevel.DEBUG); }
private boolean isVerbose() { return project.getLogger().isEnabled(LogLevel.INFO); }
private boolean isDebugLog() { return project.getLogger().isEnabled(LogLevel.DEBUG); }
@Override public void visitFieldInsn(int opcode, String owner, String fieldName, String fieldDesc) { if (opcode != Opcodes.GETSTATIC || owner.startsWith("java/lang/")) { // skip! this.mv.visitFieldInsn(opcode, owner, fieldName, fieldDesc); return; } String typeName = owner.substring(owner.lastIndexOf('/') + 1); String key = typeName + '.' + fieldName; if (rSymbols.containsKey(key)) { Integer value = rSymbols.get(key); if (value == null) throw new UnsupportedOperationException("value of " + key + " is null!"); if (logger.isEnabled(LogLevel.DEBUG)) { logger.debug("replace {}.{} to 0x{}", owner, fieldName, Integer.toHexString(value)); } pushInt(this.mv, value); } else if (owner.endsWith("/R$styleable")) { // replace all */R$styleable ref! this.mv.visitFieldInsn(opcode, RSymbols.R_STYLEABLES_CLASS_NAME, fieldName, fieldDesc); } else { this.mv.visitFieldInsn(opcode, owner, fieldName, fieldDesc); } } };
@Override public void verbose(@NonNull String s, Object... objects) { if (!logger.isEnabled(LogLevel.DEBUG)) { return; } if (objects == null || objects.length == 0) { logger.log(LogLevel.DEBUG, s); } else { logger.log(LogLevel.DEBUG, String.format(s, objects)); } } }
@Override public void warning(@NonNull String s, Object... objects) { if (!logger.isEnabled(LogLevel.WARN)) { return; } if (objects == null || objects.length == 0) { logger.log(LogLevel.WARN, s); } else { logger.log(LogLevel.WARN, String.format(s, objects)); } }
@Override public void info(@NonNull String s, Object... objects) { if (!logger.isEnabled(infoLogLevel)) { return; } if (objects == null || objects.length == 0) { logger.log(infoLogLevel, s); } else { logger.log(infoLogLevel, String.format(s, objects)); } }
@Override public void error(Throwable throwable, String s, Object... objects) { if (throwable instanceof MergingException) { // MergingExceptions have a known cause: they aren't internal errors, they // are errors in the user's code, so a full exception is not helpful (and // these exceptions should include a pointer to the user's error right in // the message). // // Furthermore, these exceptions are already caught by the MergeResources // and MergeAsset tasks, so don't duplicate the output return; } if (!logger.isEnabled(LogLevel.ERROR)) { return; } if (objects != null && objects.length > 0) { s = String.format(s, objects); } if (throwable == null) { logger.log(LogLevel.ERROR, s); } else { logger.log(LogLevel.ERROR, s, throwable); } }
private void log(@NonNull LogLevel logLevel, @NonNull String s, @Nullable Object[] objects){ if (!logger.isEnabled(logLevel)) { return; } if (objects == null || objects.length == 0) { logger.log(logLevel, s); } else { logger.log(logLevel, String.format(s, objects)); } } }
@Override public void error(@Nullable Throwable throwable, @Nullable String s, Object... objects) { if (throwable instanceof MergingException) { // MergingExceptions have a known cause: they aren't internal errors, they // are errors in the user's code, so a full exception is not helpful (and // these exceptions should include a pointer to the user's error right in // the message). // // Furthermore, these exceptions are already caught by the MergeResources // and MergeAsset tasks, so don't duplicate the output return; } if (!logger.isEnabled(ILOGGER_ERROR)) { return; } if (s == null) { s = "[no message defined]"; } else if (objects != null && objects.length > 0) { s = String.format(s, objects); } if (throwable == null) { logger.log(ILOGGER_ERROR, s); } else { logger.log(ILOGGER_ERROR, s, throwable); } }
if (logger.isEnabled(LogLevel.DEBUG)) { logger.debug(String.format("File moved from %1$s to %2$s", oldLocation.getPath(), newLocation.getPath()));
@TaskAction public void executeAction() { if (instantRunBuildContext.getBuildHasFailed()) { try { instantRunBuildContext.writeTmpBuildInfo(tmpBuildInfoFile); } catch (ParserConfigurationException | IOException e) { throw new RuntimeException("Exception while saving temp-build-info.xml", e); } return; } // done with the instant run context. instantRunBuildContext.close(); try { String xml = instantRunBuildContext.toXml(); if (logger.isEnabled(LogLevel.DEBUG)) { logger.debug("build-id $1$l, build-info.xml : %2$s", instantRunBuildContext.getBuildId(), xml); } Files.createParentDirs(buildInfoFile); Files.write(xml, buildInfoFile, Charsets.UTF_8); } catch (Exception e) { throw new RuntimeException("Exception while saving build-info.xml", e); } // Record instant run status in analytics for this build ProcessProfileWriter.getGlobalProperties() .setInstantRunStatus( InstantRunAnalyticsHelper.generateAnalyticsProto(instantRunBuildContext)); }
@Override @TaskAction public void proguard() throws ParseException, IOException { if (logger.isEnabled(LogLevel.INFO)) { logger.info("test module mapping file " + mappingConfiguration.getSingleFile()); for (Object file : variantConfiguration.getAllPackagedJars()) { logger.info("test module proguard input " + file); } for (Object file : variantConfiguration.getProvidedOnlyJars()) { logger.info("test module proguard library " + file); } } if (mappingConfiguration.getSingleFile().isFile()) { applymapping(mappingConfiguration.getSingleFile()); } super.proguard(); } }
@Override @TaskAction public void proguard() throws ParseException, IOException { if (logger.isEnabled(LogLevel.INFO)) { logger.info("test module mapping file " + mappingConfiguration.getSingleFile()); for (Object file : variantConfiguration.getPackagedJars()) { logger.info("test module proguard input " + file); } for (Object file : variantConfiguration.getProvidedOnlyJars()) { logger.info("test module proguard library " + file); } } if (mappingConfiguration.getSingleFile().isFile()) { applymapping(mappingConfiguration.getSingleFile()); } super.proguard(); } }