本文整理了Java中org.gradle.api.logging.Logger.isEnabled()
方法的一些代码示例,展示了Logger.isEnabled()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.isEnabled()
方法的具体详情如下:
包路径:org.gradle.api.logging.Logger
类名称:Logger
方法名:isEnabled
[英]Returns true if the given log level is enabled for this logger.
[中]如果为此记录器启用了给定日志级别,则返回true。
代码示例来源:origin: CoffeePartner/capt
@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);
}
代码示例来源:origin: gradle.plugin.org.openrepose/gradle-linkchecker-plugin
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();
}
}
代码示例来源:origin: gradle.plugin.org.openrepose/gradle-linkchecker-plugin
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();
}
}
}
代码示例来源:origin: gradle.plugin.org.openrepose/gradle-linkchecker-plugin
static void logMsg(LogLevel level, PrintWriter printWriter, String msg) {
log.log(level, msg);
if (printWriter != null && log.isEnabled(level)) {
printWriter.println(msg);
}
}
代码示例来源:origin: GoogleCloudPlatform/app-gradle-plugin
@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);
}
}
}
代码示例来源:origin: com.android.tools.build/gradle-core
private boolean isInfoLog() {
return project.getLogger().isEnabled(LogLevel.INFO);
}
代码示例来源:origin: com.android.tools.build/gradle-core
private boolean isDebugLog() {
return project.getLogger().isEnabled(LogLevel.DEBUG);
}
代码示例来源:origin: com.amazon.device.tools.build/gradle-core
private boolean isVerbose() {
return project.getLogger().isEnabled(LogLevel.INFO);
}
代码示例来源:origin: com.amazon.device.tools.build/gradle-core
private boolean isDebugLog() {
return project.getLogger().isEnabled(LogLevel.DEBUG);
}
代码示例来源:origin: yrom/shrinker
@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);
}
}
};
代码示例来源:origin: com.amazon.device.tools.build/gradle-core
@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));
}
}
}
代码示例来源:origin: com.amazon.device.tools.build/gradle-core
@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));
}
}
代码示例来源:origin: com.amazon.device.tools.build/gradle-core
@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));
}
}
代码示例来源:origin: com.amazon.device.tools.build/gradle-core
@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);
}
}
代码示例来源:origin: com.android.tools.build/gradle-core
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));
}
}
}
代码示例来源:origin: com.android.tools.build/gradle-core
@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);
}
}
代码示例来源:origin: com.android.tools.build/gradle-core
if (logger.isEnabled(LogLevel.DEBUG)) {
logger.debug(String.format("File moved from %1$s to %2$s",
oldLocation.getPath(), newLocation.getPath()));
代码示例来源:origin: com.android.tools.build/gradle-core
@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));
}
代码示例来源:origin: com.android.tools.build/gradle-core
@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();
}
}
代码示例来源:origin: com.amazon.device.tools.build/gradle-core
@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();
}
}
内容来源于网络,如有侵权,请联系作者删除!