private static void appendFancy(Appendable out, Object value, boolean bold) throws IOException { boolean withStyle = options.fancy(); if (bold && withStyle) { out.append("\33[1m"); } out.append(printable(value)); if (bold && withStyle) { out.append("\33[0m"); } }
public static Logger logger() { if (options.loggerFactory() == null) { synchronized (Log.class) { if (options.loggerFactory() == null) { options.loggerFactory(createLoggerFactory()); } } } try { return options.loggerFactory().call(); } catch (Exception e) { throw new RuntimeException(e); } }
private static void printKeyValue(Appendable out, String key, Object value) throws IOException { boolean bold = key.startsWith("!"); if (bold) { key = key.substring(1); } if (key.equalsIgnoreCase("password") || key.endsWith("password")) { if (value instanceof String) { if (U.notEmpty((String) value)) { value = "*****"; } } } out.append(" | "); out.append(key); out.append(" = "); appendFancy(out, value, bold); if (value instanceof Throwable) { Throwable err = (Throwable) value; if (options.stackTraceOnStdErr()) { err.printStackTrace(); } else { ByteArrayOutputStream stream = new ByteArrayOutputStream(); err.printStackTrace(new PrintStream(stream)); out.append("\n"); out.append(stream.toString()); } } }
if (topic == null && options.inferCaller()) { topic = getCallingClass(); if (options.prefix() != null) { sb.append(options.prefix()); if (options.showDateTime()) { sb.append(" | "); sb.append(options().dateTimeFormat().format(new Date())); if (options.showThread()) { sb.append(" | "); sb.append(Thread.currentThread().getName());
if (topic == null && options.inferCaller()) { topic = getCallingClass(); if (options.prefix() != null) { sb.append(options.prefix()); if (options.showDateTime()) { sb.append(" | "); sb.append(options().dateTimeFormat().format(new Date())); if (options.showThread()) { sb.append(" | "); sb.append(Thread.currentThread().getName());
private static String code(String code, String text) { return Log.options().fancy() && !GlobalCfg.uniformOutput() ? "\33[" + code + "m" + text + "\33[0m" : text; }
public static Logger logger() { if (options.loggerFactory() == null) { synchronized (Log.class) { if (options.loggerFactory() == null) { options.loggerFactory(createLoggerFactory()); } } } try { return options.loggerFactory().call(); } catch (Exception e) { throw new RuntimeException(e); } }
private static void printKeyValue(Appendable out, String key, Object value) throws IOException { boolean bold = key.startsWith("!"); if (bold) { key = key.substring(1); } if (key.equalsIgnoreCase("password") || key.endsWith("password")) { if (value instanceof String) { if (U.notEmpty((String) value)) { value = "*****"; } } } out.append(" | "); out.append(key); out.append(" = "); appendFancy(out, value, bold); if (value instanceof Throwable) { Throwable err = (Throwable) value; if (options.stackTraceOnStdErr()) { err.printStackTrace(); } else { ByteArrayOutputStream stream = new ByteArrayOutputStream(); err.printStackTrace(new PrintStream(stream)); out.append("\n"); out.append(stream.toString()); } } }
private static void activateRootConfig() { U.must(Env.isInitialized()); String root = Env.root(); if (U.notEmpty(root) && !APP.has("jar")) { APP.set("jar", Msc.path(root, "app.jar")); } String appJar = APP.entry("jar").str().getOrNull(); if (U.notEmpty(appJar)) { ClasspathUtil.appJar(appJar); } boolean fancyByDefault = Env.dev() || System.console() != null; Log.options().fancy(LOG.entry("fancy").bool().or(fancyByDefault)); LogLevel logLevel = LOG.entry("level").to(LogLevel.class).getOrNull(); if (logLevel != null && !Env.test()) { Log.setLogLevel(logLevel); } if (GlobalCfg.quiet()) { Log.setLogLevel(LogLevel.ERROR); // overwrite the configured log level in quiet mode } }
private static void appendFancy(Appendable out, Object value, boolean bold) throws IOException { boolean withStyle = options.fancy(); if (bold && withStyle) { out.append("\33[1m"); } out.append(printable(value)); if (bold && withStyle) { out.append("\33[0m"); } }