summaryrefslogtreecommitdiffstats
path: root/jack
diff options
context:
space:
mode:
authorJean-Philippe Lesot <jplesot@google.com>2015-03-13 16:12:27 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-03-13 16:12:27 +0000
commit492645221137af8bb3fdf2613aeedd0a146b7710 (patch)
tree59554e0245e740889d29b77f59fd0243c0bc9bf3 /jack
parentee60907ebfce90c6ec8fb44833025f75967bd89a (diff)
parent2282698f8fc035c0722225931ead9c653d95e202 (diff)
downloadtoolchain_jack-492645221137af8bb3fdf2613aeedd0a146b7710.tar.gz
toolchain_jack-492645221137af8bb3fdf2613aeedd0a146b7710.tar.bz2
toolchain_jack-492645221137af8bb3fdf2613aeedd0a146b7710.zip
Merge "Add property to set an output file by reporter level" into ub-jack
Diffstat (limited to 'jack')
-rw-r--r--jack/src/com/android/jack/reporting/CommonReporter.java18
-rw-r--r--jack/src/com/android/jack/reporting/DefaultReporter.java10
-rw-r--r--jack/src/com/android/jack/reporting/Reporter.java32
-rw-r--r--jack/src/com/android/jack/reporting/SdkReporter.java10
4 files changed, 65 insertions, 5 deletions
diff --git a/jack/src/com/android/jack/reporting/CommonReporter.java b/jack/src/com/android/jack/reporting/CommonReporter.java
index d7b8f2ea..6561d78b 100644
--- a/jack/src/com/android/jack/reporting/CommonReporter.java
+++ b/jack/src/com/android/jack/reporting/CommonReporter.java
@@ -21,10 +21,14 @@ import com.android.jack.Options.VerbosityLevel;
import com.android.jack.frontend.java.EcjProblem;
import com.android.jack.reporting.Reportable.ProblemLevel;
import com.android.sched.util.config.ThreadConfig;
+import com.android.sched.util.file.OutputStreamFile;
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import java.io.PrintStream;
+import java.util.EnumMap;
+import java.util.Map;
+import java.util.Map.Entry;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
@@ -39,8 +43,18 @@ abstract class CommonReporter implements Reporter {
private final VerbosityLevel verbosityLevel = ThreadConfig.get(Options.VERBOSITY_LEVEL);
@Nonnull
- protected final PrintStream reporterStream =
- ThreadConfig.get(REPORTER_OUTPUT_STREAM).getPrintStream();
+ protected final PrintStream streamByDefault = ThreadConfig.get(REPORTER_OUTPUT_STREAM)
+ .getPrintStream();
+ @Nonnull
+ protected final Map<ProblemLevel, PrintStream> streamByLevel =
+ new EnumMap<ProblemLevel, PrintStream>(ProblemLevel.class);
+
+ protected CommonReporter() {
+ for (final Entry<ProblemLevel, OutputStreamFile> entry : ThreadConfig.get(
+ Reporter.REPORTER_OUTPUT_STREAM_BY_LEVEL).entrySet()) {
+ streamByLevel.put(entry.getKey(), entry.getValue().getPrintStream());
+ }
+ }
@Override
public void report(@Nonnull Severity severity, @Nonnull Reportable reportable) {
diff --git a/jack/src/com/android/jack/reporting/DefaultReporter.java b/jack/src/com/android/jack/reporting/DefaultReporter.java
index ac9e3357..83718787 100644
--- a/jack/src/com/android/jack/reporting/DefaultReporter.java
+++ b/jack/src/com/android/jack/reporting/DefaultReporter.java
@@ -19,6 +19,8 @@ package com.android.jack.reporting;
import com.android.jack.reporting.Reportable.ProblemLevel;
import com.android.sched.util.codec.ImplementationName;
+import java.io.PrintStream;
+
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
@@ -48,6 +50,12 @@ public class DefaultReporter extends CommonReporter {
}
messageBuffer.append(": ");
messageBuffer.append(message);
- reporterStream.println(messageBuffer.toString());
+
+ PrintStream printer = streamByLevel.get(problemLevel);
+ if (printer == null) {
+ printer = streamByDefault;
+ }
+
+ printer.println(messageBuffer.toString());
}
}
diff --git a/jack/src/com/android/jack/reporting/Reporter.java b/jack/src/com/android/jack/reporting/Reporter.java
index 5a09d073..c42e5e8e 100644
--- a/jack/src/com/android/jack/reporting/Reporter.java
+++ b/jack/src/com/android/jack/reporting/Reporter.java
@@ -18,13 +18,23 @@ package com.android.jack.reporting;
import com.android.jack.config.id.Arzon;
import com.android.jack.config.id.Brest;
+import com.android.jack.reporting.Reportable.ProblemLevel;
+import com.android.sched.util.codec.EnumCodec;
+import com.android.sched.util.codec.ListCodec;
import com.android.sched.util.codec.OutputStreamCodec;
+import com.android.sched.util.codec.PairCodec;
+import com.android.sched.util.codec.PairListToMapCodecConverter;
import com.android.sched.util.config.HasKeyId;
import com.android.sched.util.config.id.ImplementationPropertyId;
import com.android.sched.util.config.id.PropertyId;
+import com.android.sched.util.config.id.PropertyId.ShutdownRunnable;
import com.android.sched.util.file.FileOrDirectory.Existence;
import com.android.sched.util.file.OutputStreamFile;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Map.Entry;
+
import javax.annotation.Nonnull;
/**
@@ -52,6 +62,26 @@ public interface Reporter {
.addDefaultValue("--").requiredIf(REPORTER.getClazz().isImplementedBy(DefaultReporter.class)
.or(REPORTER.getClazz().isImplementedBy(SdkReporter.class))).withCategory(Brest.get());
- public void report(@Nonnull Severity severity, @Nonnull Reportable reportable);
+ @Nonnull
+ public static final PropertyId<Map<ProblemLevel, OutputStreamFile>>
+ REPORTER_OUTPUT_STREAM_BY_LEVEL =
+ PropertyId
+ .create(
+ "jack.reporter.level.file",
+ "File where the reporter will write by level",
+ new PairListToMapCodecConverter<ProblemLevel, OutputStreamFile>(
+ new ListCodec<Entry<ProblemLevel, OutputStreamFile>>("pair",
+ new PairCodec<ProblemLevel, OutputStreamFile>(new EnumCodec<ProblemLevel>(
+ ProblemLevel.values()).ignoreCase(), new OutputStreamCodec(
+ Existence.MAY_EXIST).allowStandardOutputOrError()).on("="))))
+ .addDefaultValue(Collections.<ProblemLevel, OutputStreamFile>emptyMap())
+ .setShutdownHook(new ShutdownRunnable<Map<ProblemLevel, OutputStreamFile>>() {
+ @Override
+ public void run(@Nonnull Map<ProblemLevel, OutputStreamFile> map) {
+ for (OutputStreamFile osf : map.values()) {
+ osf.getPrintStream().close();
+ }
+ }});
+ public void report(@Nonnull Severity severity, @Nonnull Reportable reportable);
}
diff --git a/jack/src/com/android/jack/reporting/SdkReporter.java b/jack/src/com/android/jack/reporting/SdkReporter.java
index 505933cb..c72eab3e 100644
--- a/jack/src/com/android/jack/reporting/SdkReporter.java
+++ b/jack/src/com/android/jack/reporting/SdkReporter.java
@@ -19,6 +19,8 @@ package com.android.jack.reporting;
import com.android.jack.reporting.Reportable.ProblemLevel;
import com.android.sched.util.codec.ImplementationName;
+import java.io.PrintStream;
+
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
@@ -62,6 +64,12 @@ public class SdkReporter extends CommonReporter {
}
messageBuffer.append(MESSAGE_SEPARATOR);
messageBuffer.append(message);
- reporterStream.println(messageBuffer.toString());
+
+ PrintStream printer = streamByLevel.get(problemLevel);
+ if (printer == null) {
+ printer = streamByDefault;
+ }
+
+ printer.println(messageBuffer.toString());
}
}