/*
 * RESTHeart - the Web API for MongoDB
 * Copyright (C) SoftInstigate Srl
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.restheart.utils;

import org.slf4j.Logger;

/**
 *
 * @author Andrea Di Cesare <andrea@softinstigate.com>
 */
public class LogUtils {
    public static enum Level {
        TRACE, DEBUG, INFO, WARN, ERROR
    }

    public static void log(Logger logger, Level level, String format, Object... argArray) {
        if (logger != null && level != null) {
            switch (level) {
                case TRACE:
                    logger.trace(format, argArray);
                    break;
                case DEBUG:
                    logger.debug(format, argArray);
                    break;
                case INFO:
                    logger.info(format, argArray);
                    break;
                case WARN:
                    logger.warn(format, argArray);
                    break;
                case ERROR:
                    logger.error(format, argArray);
                    break;
            }
        }
    }
}

@@ -777,16 +777,240 @@
 utils;%0A%0A
+import org.fusesource.jansi.Ansi;%0Aimport org.fusesource.jansi.Ansi.Color;%0Aimport static org.fusesource.jansi.Ansi.Color.GREEN;%0Aimport static org.fusesource.jansi.Ansi.Color.RED;%0Aimport static org.fusesource.jansi.Ansi.ansi;%0A
 import o
@@ -1924,10 +1924,2047 @@
 %7D%0A    %7D%0A
+    %0A    public static void boxedError(%0A            Logger LOGGER,%0A            String... rows) %7B%0A        boxedMessage(LOGGER, Level.ERROR, RED, GREEN, rows);%0A    %7D%0A    %0A    public static void boxedWarn(%0A            Logger LOGGER,%0A            String... rows) %7B%0A        boxedMessage(LOGGER, Level.WARN, RED, GREEN, rows);%0A    %7D%0A    %0A    public static void boxedInfo(%0A            Logger LOGGER,%0A            String... rows) %7B%0A        boxedMessage(LOGGER, Level.INFO, GREEN, GREEN, rows);%0A    %7D%0A    %0A    public static void boxedMessage(%0A            Logger LOGGER,%0A            Level level,%0A            Color firstRowColor,%0A            Color rowsColor,%0A            String... rows) %7B%0A%0A        var msg = header();%0A        var first = true;%0A        for (var row : rows) %7B%0A            msg.a(sr())%0A                    .fg(first ? firstRowColor: rowsColor)%0A                    .a(pad(row, 66))%0A                    .a(er())%0A                    .reset();%0A            %0A            first = false;%0A        %7D%0A%0A        msg.a(footer());%0A%0A        LogUtils.log(LOGGER, level, msg.toString(), null);%0A    %7D%0A%0A    private static Ansi sr() %7B%0A        return ansi().fg(GREEN).a(%22%7C %22).reset();%0A    %7D%0A%0A    private static Ansi er() %7B%0A        return ansi().fg(GREEN).a(%22%7C%5Cn%22).reset();%0A    %7D%0A%0A    private static Ansi header() %7B%0A        return ansi().a(%22%5Cn%22).fg(GREEN).a(%0A                %22*-------------------------------------------------------------------*%5Cn%22%0A                + %22%7C                                                                   %7C%5Cn%22)%0A                .reset();%0A    %7D%0A%0A    private static Ansi footer() %7B%0A        return ansi().fg(GREEN).a(%0A                %22%7C                                                                   %7C%5Cn%22%0A                + %22*-------------------------------------------------------------------*%5Cn%22)%0A                .reset();%0A%0A    %7D%0A%0A    private static String pad(String s, int length) %7B%0A        var ret = new String(s);%0A        while (ret.length() %3C length) %7B%0A            ret = ret.concat(%22 %22);%0A        %7D%0A        return ret;%0A    %7D%0A
 %7D%0A

Add log utils methods to log emphasized messages in text boxes