Java Code Examples for org.fusesource.jansi.Ansi#fgBright()

The following examples show how to use org.fusesource.jansi.Ansi#fgBright() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StyleRenderer.java    From helidon-build-tools with Apache License 2.0 6 votes vote down vote up
private static void apply(Ansi ansi, Code code, boolean bright) {
    if (code.isColor()) {
        final Color color = code.getColor();
        if (code.isBackground()) {
            if (bright) {
                ansi.bgBright(color);
            } else {
                ansi.bg(color);
            }
        } else {
            if (bright) {
                ansi.fgBright(color);
            } else {
                ansi.fg(color);
            }
        }
    } else if (code.isAttribute()) {
        ansi.a(code.getAttribute());
    }
}
 
Example 2
Source File: LogOutputSpec.java    From jkube with Eclipse Public License 2.0 5 votes vote down vote up
private String formatPrefix(String prefix, boolean withColor) {
    if (withColor) {
        Ansi ansi = ansi();
        if (fgBright) {
            ansi.fgBright(color);
        } else {
            ansi.fg(color);
        }
        return ansi.a(prefix).reset().toString();
    } else {
        return prefix;
    }
}
 
Example 3
Source File: VisageFormatter.java    From Visage with MIT License 5 votes vote down vote up
@Override
public String format(LogRecord record) {
	if (record.getThrown() != null) {
		record.getThrown().printStackTrace();
	}
	Ansi ansi = Ansi.ansi();
	if (Visage.ansi) {
		ansi.fgBright(Color.BLACK);
	}
	Date date = new Date(record.getMillis());
	ansi.a("@");
	ansi.a(format.format(date));
	if (Visage.ansi) {
		ansi.reset();
	}
	ansi.a(Strings.padStart(Thread.currentThread().getName(), 22, ' '));
	ansi.a(" ");
	if (Visage.ansi && colors.containsKey(record.getLevel())) {
		ansi.fgBright(colors.get(record.getLevel()));
	}
	ansi.a(names.get(record.getLevel()));
	if (Visage.ansi) {
		ansi.reset();
	}
	ansi.a(": ");
	if (Visage.ansi && colors.containsKey(record.getLevel()) && record.getLevel().intValue() >= Level.SEVERE.intValue()) {
		ansi.bold();
		ansi.fgBright(colors.get(record.getLevel()));
	}
	ansi.a(record.getMessage());
	if (Visage.ansi) {
		ansi.reset();
	}
	ansi.a("\n");
	return ansi.toString();
}
 
Example 4
Source File: LogOutputSpec.java    From docker-maven-plugin with Apache License 2.0 5 votes vote down vote up
private String formatPrefix(String prefix,boolean withColor) {
    if (withColor) {
        Ansi ansi = ansi();
        if (fgBright) {
            ansi.fgBright(color);
        } else {
            ansi.fg(color);
        }
        return ansi.a(prefix).reset().toString();
    } else {
        return prefix;
    }
}
 
Example 5
Source File: FormatHelper.java    From Launcher with GNU General Public License v3.0 4 votes vote down vote up
public static Ansi rawAnsiFormat(LogHelper.Level level, String dateTime, boolean sub) {
    Ansi.Color levelColor;
    boolean bright = level != LogHelper.Level.DEBUG;
    switch (level) {
        case WARNING:
            levelColor = Ansi.Color.YELLOW;
            break;
        case ERROR:
            levelColor = Ansi.Color.RED;
            break;
        default: // INFO, DEBUG, Unknown
            levelColor = Ansi.Color.WHITE;
            break;
    }

    // Date-time
    Ansi ansi = new Ansi();
    ansi.fg(Ansi.Color.WHITE).a(dateTime);

    // Level
    ansi.fgBright(Ansi.Color.WHITE).a(" [").bold();
    if (bright) {
        ansi.fgBright(levelColor);
    } else {
        ansi.fg(levelColor);
    }
    ansi.a(level).boldOff().fgBright(Ansi.Color.WHITE).a("] ");

    // Message
    if (bright) {
        ansi.fgBright(levelColor);
    } else {
        ansi.fg(levelColor);
    }
    if (sub) {
        ansi.a(' ').a(Ansi.Attribute.ITALIC);
    }

    // Finish with reset code
    return ansi;
}