Repository: GoogleContainerTools/jib
File: jib-cli/src/main/java/com/google/cloud/tools/jib/cli/cli2/logging/CliLogger.java (Java)

Code before:
public class CliLogger {

  /**
   * Create a new logger for the cli.
   *
   * @param verbosity the configure verbosity
   * @param consoleOutput the configured consoleOutput format
   * @return a new ConsoleLogger instance
   */
  public static ConsoleLogger newLogger(Verbosity verbosity, ConsoleOutput consoleOutput) {
    CliLogger cliLogger = new CliLogger(verbosity, System.out, System.err);
    boolean isRichConsole = isRichConsole(consoleOutput);

    return newLogger(cliLogger, isRichConsole, new SingleThreadedExecutor());
  }

  @VisibleForTesting
  static ConsoleLogger newLogger(
      CliLogger cliLogger, boolean isRichConsole, SingleThreadedExecutor executor) {
    // rich logger will use an explicit progress event handler
    ConsoleLoggerBuilder builder =
        isRichConsole
            ? ConsoleLoggerBuilder.rich(executor, true)
            : ConsoleLoggerBuilder.plain(executor).progress(cliLogger::lifecycle);
    builder.error(cliLogger::error);
    builder.warn(cliLogger::warn);
    builder.lifecycle(cliLogger::lifecycle);
    builder.info(cliLogger::info);
    builder.debug(cliLogger::debug);

    return builder.build();
  }

  @VisibleForTesting
  static boolean isRichConsole(ConsoleOutput consoleOutput) {
    switch (consoleOutput) {
      case plain:
        return false;
      case auto:
        // Enables progress footer when ANSI is supported (Windows or TERM not 'dumb').
        return System.getProperty("os.name").startsWith("windows")
            || !"dumb".equals(System.getenv("TERM"));
      case rich:
      default:
        return true;
    }
  }

  private final Verbosity verbosity;
  private final PrintStream out;
  private final PrintStream err;

Review comment (suggestion):
Flipping `enableTwoCursorUpJump` doesn't effectively change output and is not required to fix the issue. However, since there's no need to employ the two-cursor-up-jump trick (was only necessary for Maven), I'm turning it off.

Code after:
public class CliLogger {

  /**
   * Create a new logger for the CLI.
   *
   * @param verbosity the configure verbosity
   * @param consoleOutput the configured consoleOutput format
   * @return a new ConsoleLogger instance
   */
  public static ConsoleLogger newLogger(Verbosity verbosity, ConsoleOutput consoleOutput) {
    return newLogger(
        verbosity, consoleOutput, System.out, System.err, new SingleThreadedExecutor());
  }

  @VisibleForTesting
  static ConsoleLogger newLogger(
      Verbosity verbosity,
      ConsoleOutput consoleOutput,
      PrintStream stdout,
      PrintStream stderr,
      SingleThreadedExecutor executor) {
    boolean enableRichProgress =
        isRichConsole(consoleOutput) && verbosity.atLeast(Verbosity.lifecycle);
    ConsoleLoggerBuilder builder =
        enableRichProgress
            ? ConsoleLoggerBuilder.rich(executor, false)
            : ConsoleLoggerBuilder.plain(executor);
    if (verbosity.atLeast(Verbosity.error)) {
      builder.error(stderr::println);
    }
    if (verbosity.atLeast(Verbosity.warn)) {
      builder.warn(stdout::println);
    }
    if (verbosity.atLeast(Verbosity.lifecycle)) {
      builder.lifecycle(stdout::println);
      // Rich progress reporting will be through ProgressEvent (note this is not LogEvent of
      // Level.PROGRESS), so we ignore PROGRESS LogEvent.
      if (!enableRichProgress) {
        builder.progress(stdout::println);
      }
    }
    if (verbosity.atLeast(Verbosity.info)) {
      builder.info(stdout::println);
    }
    if (verbosity.atLeast(Verbosity.debug)) {
      builder.debug(stdout::println);
    }

    return builder.build();
  }