Java Code Examples for org.fusesource.jansi.Ansi#toString()
The following examples show how to use
org.fusesource.jansi.Ansi#toString() .
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: ColorFormatter.java From tomee with Apache License 2.0 | 6 votes |
@Override public synchronized String format(final LogRecord record) { final boolean exception = record.getThrown() != null; final Ansi sbuf = prefix(record); sbuf.a(record.getLevel().getLocalizedName()); sbuf.a(" - "); sbuf.a(formatMessage(record)); if (!exception) { suffix(sbuf, record); } sbuf.newline(); if (exception) { try { final StringWriter sw = new StringWriter(); final PrintWriter pw = new PrintWriter(sw); record.getThrown().printStackTrace(pw); pw.close(); sbuf.a(sw.toString()); } catch (final Exception ex) { // no-op } finally { suffix(sbuf, record); } } return sbuf.toString(); }
Example 2
Source File: VisageFormatter.java From Visage with MIT License | 5 votes |
@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(); }