Search in sources :

Example 1 with ConsoleLoggerBuilder

use of com.google.cloud.tools.jib.plugins.common.logging.ConsoleLoggerBuilder in project jib by google.

the class CliLogger method newLogger.

/**
 * Create a new logger for the CLI.
 *
 * @param verbosity the configure verbosity
 * @param httpTraceLevel the log level for http trace
 * @param consoleOutput the configured consoleOutput format
 * @param stdout the writer to store stdout
 * @param stderr the writer to store stderr
 * @param executor a {@link SingleThreadedExecutor} to ensure that all messages are logged in a
 *     sequential, deterministic order
 * @return a new ConsoleLogger instance
 */
public static ConsoleLogger newLogger(Verbosity verbosity, HttpTraceLevel httpTraceLevel, ConsoleOutput consoleOutput, PrintWriter stdout, PrintWriter stderr, SingleThreadedExecutor executor) {
    boolean enableRichProgress = isRichConsole(consoleOutput, httpTraceLevel) && verbosity.atLeast(Verbosity.lifecycle);
    ConsoleLoggerBuilder builder = enableRichProgress ? ConsoleLoggerBuilder.rich(executor, false) : ConsoleLoggerBuilder.plain(executor);
    if (verbosity.atLeast(Verbosity.error)) {
        builder.error(message -> stderr.println("[ERROR] " + message));
    }
    if (verbosity.atLeast(Verbosity.warn)) {
        builder.warn(message -> stdout.println("[WARN] " + message));
    }
    if (verbosity.atLeast(Verbosity.lifecycle)) {
        builder.lifecycle(stdout::println);
        // 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();
}
Also used : ConsoleLoggerBuilder(com.google.cloud.tools.jib.plugins.common.logging.ConsoleLoggerBuilder)

Example 2 with ConsoleLoggerBuilder

use of com.google.cloud.tools.jib.plugins.common.logging.ConsoleLoggerBuilder in project jib by GoogleContainerTools.

the class CliLogger method newLogger.

/**
 * Create a new logger for the CLI.
 *
 * @param verbosity the configure verbosity
 * @param httpTraceLevel the log level for http trace
 * @param consoleOutput the configured consoleOutput format
 * @param stdout the writer to store stdout
 * @param stderr the writer to store stderr
 * @param executor a {@link SingleThreadedExecutor} to ensure that all messages are logged in a
 *     sequential, deterministic order
 * @return a new ConsoleLogger instance
 */
public static ConsoleLogger newLogger(Verbosity verbosity, HttpTraceLevel httpTraceLevel, ConsoleOutput consoleOutput, PrintWriter stdout, PrintWriter stderr, SingleThreadedExecutor executor) {
    boolean enableRichProgress = isRichConsole(consoleOutput, httpTraceLevel) && verbosity.atLeast(Verbosity.lifecycle);
    ConsoleLoggerBuilder builder = enableRichProgress ? ConsoleLoggerBuilder.rich(executor, false) : ConsoleLoggerBuilder.plain(executor);
    if (verbosity.atLeast(Verbosity.error)) {
        builder.error(message -> stderr.println("[ERROR] " + message));
    }
    if (verbosity.atLeast(Verbosity.warn)) {
        builder.warn(message -> stdout.println("[WARN] " + message));
    }
    if (verbosity.atLeast(Verbosity.lifecycle)) {
        builder.lifecycle(stdout::println);
        // 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();
}
Also used : ConsoleLoggerBuilder(com.google.cloud.tools.jib.plugins.common.logging.ConsoleLoggerBuilder)

Aggregations

ConsoleLoggerBuilder (com.google.cloud.tools.jib.plugins.common.logging.ConsoleLoggerBuilder)2