aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools
diff options
context:
space:
mode:
authorGravatar vladmos <vladmos@google.com>2017-08-10 20:30:17 +0200
committerGravatar Marcel Hlopko <hlopko@google.com>2017-08-11 12:56:15 +0200
commita664a5118e552504ba7962e1cccfea43b51ef28e (patch)
tree0f0926df29537fc48208721818a24bc2817e1ee3 /src/main/java/com/google/devtools
parent4435515d156dbb0cc40869de686d326b175f61b8 (diff)
Make the print function output debug messages
RELNOTES: The `print` function now prints debug messages instead of warnings. PiperOrigin-RevId: 164880003
Diffstat (limited to 'src/main/java/com/google/devtools')
-rw-r--r--src/main/java/com/google/devtools/build/lib/events/Event.java31
-rw-r--r--src/main/java/com/google/devtools/build/lib/events/EventKind.java9
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandEventHandler.java1
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/FancyTerminalEventHandler.java17
-rw-r--r--src/main/java/com/google/devtools/build/lib/syntax/MethodLibrary.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/util/io/AnsiTerminal.java11
7 files changed, 63 insertions, 12 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/events/Event.java b/src/main/java/com/google/devtools/build/lib/events/Event.java
index e5fb781b22..e0bf233b65 100644
--- a/src/main/java/com/google/devtools/build/lib/events/Event.java
+++ b/src/main/java/com/google/devtools/build/lib/events/Event.java
@@ -156,17 +156,17 @@ public final class Event implements Serializable {
}
/**
- * Reports a warning.
+ * Reports an error.
*/
- public static Event warn(@Nullable Location location, String message) {
- return new Event(EventKind.WARNING, location, message, null);
+ public static Event error(@Nullable Location location, String message){
+ return new Event(EventKind.ERROR, location, message, null);
}
/**
- * Reports an error.
+ * Reports a warning.
*/
- public static Event error(@Nullable Location location, String message){
- return new Event(EventKind.ERROR, location, message, null);
+ public static Event warn(@Nullable Location location, String message) {
+ return new Event(EventKind.WARNING, location, message, null);
}
/**
@@ -184,10 +184,10 @@ public final class Event implements Serializable {
}
/**
- * Reports a warning.
+ * Reports a debug message.
*/
- public static Event warn(String message) {
- return warn(null, message);
+ public static Event debug(@Nullable Location location, String message) {
+ return new Event(EventKind.DEBUG, location, message, null);
}
/**
@@ -198,6 +198,13 @@ public final class Event implements Serializable {
}
/**
+ * Reports a warning.
+ */
+ public static Event warn(String message) {
+ return warn(null, message);
+ }
+
+ /**
* Reports atemporal statements about the build, i.e. they're true for the duration of execution.
*/
public static Event info(String message) {
@@ -211,4 +218,10 @@ public final class Event implements Serializable {
return progress(null, message);
}
+ /**
+ * Reports a debug message.
+ */
+ public static Event debug(String message) {
+ return debug(null, message);
+ }
}
diff --git a/src/main/java/com/google/devtools/build/lib/events/EventKind.java b/src/main/java/com/google/devtools/build/lib/events/EventKind.java
index 0146fda747..087de602d6 100644
--- a/src/main/java/com/google/devtools/build/lib/events/EventKind.java
+++ b/src/main/java/com/google/devtools/build/lib/events/EventKind.java
@@ -52,6 +52,11 @@ public enum EventKind {
PROGRESS,
/**
+ * For debug messages
+ */
+ DEBUG,
+
+ /**
* For progress messages (temporal information) relating to the start
* and end of particular tasks.
* (e.g. "Loading package foo", "Compiling bar", etc.)
@@ -102,6 +107,7 @@ public enum EventKind {
public static final Set<EventKind> ERRORS_AND_WARNINGS = EnumSet.of(
EventKind.ERROR,
EventKind.WARNING,
+ EventKind.DEBUG,
EventKind.FAIL,
EventKind.TIMEOUT
);
@@ -109,6 +115,7 @@ public enum EventKind {
public static final Set<EventKind> ERRORS_WARNINGS_AND_INFO = EnumSet.of(
EventKind.ERROR,
EventKind.WARNING,
+ EventKind.DEBUG,
EventKind.PASS,
EventKind.FAIL,
EventKind.TIMEOUT,
@@ -126,6 +133,7 @@ public enum EventKind {
public static final Set<EventKind> ERRORS_AND_WARNINGS_AND_OUTPUT = EnumSet.of(
EventKind.ERROR,
EventKind.WARNING,
+ EventKind.DEBUG,
EventKind.FAIL,
EventKind.TIMEOUT,
EventKind.STDOUT,
@@ -135,6 +143,7 @@ public enum EventKind {
public static final Set<EventKind> ERRORS_WARNINGS_AND_INFO_AND_OUTPUT = EnumSet.of(
EventKind.ERROR,
EventKind.WARNING,
+ EventKind.DEBUG,
EventKind.PASS,
EventKind.FAIL,
EventKind.TIMEOUT,
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 400d958e3b..7d10f655cd 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
@@ -299,6 +299,7 @@ public class BlazeCommandEventHandler implements EventHandler {
case TIMEOUT:
case ERROR:
case WARNING:
+ case DEBUG:
case DEPCHECKER:
prefix = event.getKind() + ": ";
break;
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java b/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java
index 93931536d1..def5a1e0a8 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java
@@ -339,6 +339,7 @@ public class ExperimentalEventHandler implements EventHandler {
case FAIL:
case WARNING:
case INFO:
+ case DEBUG:
case SUBCOMMAND:
boolean incompleteLine;
if (showProgress && buildRunning) {
@@ -401,6 +402,9 @@ public class ExperimentalEventHandler implements EventHandler {
case INFO:
terminal.setTextColor(Color.GREEN);
break;
+ case DEBUG:
+ terminal.setTextColor(Color.YELLOW);
+ break;
case SUBCOMMAND:
terminal.setTextColor(Color.BLUE);
break;
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/FancyTerminalEventHandler.java b/src/main/java/com/google/devtools/build/lib/runtime/FancyTerminalEventHandler.java
index 07234d5ef3..fa74355b31 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/FancyTerminalEventHandler.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/FancyTerminalEventHandler.java
@@ -201,6 +201,11 @@ public class FancyTerminalEventHandler extends BlazeCommandEventHandler {
// and scroll it.
warning(event);
break;
+ case DEBUG:
+ // For debug messages, highlight the word "Debug" in boldface yellow,
+ // and scroll it.
+ debug(event);
+ break;
case SUBCOMMAND:
subcmd(event);
break;
@@ -361,6 +366,18 @@ public class FancyTerminalEventHandler extends BlazeCommandEventHandler {
crlf();
}
+ private void debug(Event debug) throws IOException {
+ previousLineErasable = false;
+ if (useColor) {
+ terminal.textYellow();
+ }
+ terminal.writeString("DEBUG: ");
+ terminal.resetTerminal();
+ writeTimestampAndLocation(debug);
+ writeStringWithPotentialPeriod(debug.getMessage());
+ crlf();
+ }
+
/**
* Writes the given String to the terminal. This method also writes a trailing period if the
* message doesn't end with a punctuation character.
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/MethodLibrary.java b/src/main/java/com/google/devtools/build/lib/syntax/MethodLibrary.java
index c4104623c2..f0f625e6de 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/MethodLibrary.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/MethodLibrary.java
@@ -2143,7 +2143,7 @@ public class MethodLibrary {
if (env.getSemantics().internalSkylarkFlagTestCanary) {
msg += "<== skylark flag test ==>";
}
- env.handleEvent(Event.warn(loc, msg));
+ env.handleEvent(Event.debug(loc, msg));
return Runtime.NONE;
}
};
diff --git a/src/main/java/com/google/devtools/build/lib/util/io/AnsiTerminal.java b/src/main/java/com/google/devtools/build/lib/util/io/AnsiTerminal.java
index a28b8f7e57..59ae7ac6d5 100644
--- a/src/main/java/com/google/devtools/build/lib/util/io/AnsiTerminal.java
+++ b/src/main/java/com/google/devtools/build/lib/util/io/AnsiTerminal.java
@@ -132,20 +132,27 @@ public class AnsiTerminal {
}
/**
- * Makes text print on the terminal in red.
+ * Makes text print on the terminal in green.
*/
public void textGreen() throws IOException {
setTextColor(Color.GREEN);
}
/**
- * Makes text print on the terminal in red.
+ * Makes text print on the terminal in magenta.
*/
public void textMagenta() throws IOException {
setTextColor(Color.MAGENTA);
}
/**
+ * Makes text print on the terminal in yellow.
+ */
+ public void textYellow() throws IOException {
+ setTextColor(Color.YELLOW);
+ }
+
+ /**
* Set the terminal title.
*/
public void setTitle(String title) throws IOException {