Example #1
0
 /** @return a six-character string, so it is a fixed width */
 public static String formatForConsole(Locale locale, long durationInMillis, Ansi ansi) {
   if (durationInMillis < 100) {
     return ansi.asSuccessText("<100ms");
   } else if (durationInMillis < 1000) {
     return ansi.asWarningText(String.format(locale, " %dms", durationInMillis));
   } else {
     double seconds = durationInMillis / 1000.0;
     return ansi.asErrorText(String.format(locale, "%5.1fs", seconds));
   }
 }
Example #2
0
 /**
  * @param successMessage single line of text without a trailing newline. If stdErr is attached to
  *     a terminal, then this will append an ANSI reset escape sequence followed by a newline.
  */
 public void printSuccess(String successMessage) {
   Preconditions.checkArgument(
       !successMessage.endsWith("\n"), "Trailing newline will be added by this method");
   LOG.debug("Build success: %s", successMessage);
   ansi.printHighlightedSuccessText(stdErr, successMessage);
   stdErr.print('\n');
 }
Example #3
0
 /** Prints an error message to stderr that will be highlighted in red if stderr is a tty. */
 public void printErrorText(String message) {
   LOG.warn("Build error: %s", message);
   stdErr.println(ansi.asErrorText(message));
 }
Example #4
0
 private void printBuildFailureInternal(String failureMessage) {
   ansi.printlnHighlightedFailureText(stdErr, String.format("BUILD FAILED: %s", failureMessage));
 }