@Test public void testLogHelper() { String name = "MyLogger"; TestLoggerAdapter adapter = new TestLoggerAdapter(name); MustacheEngine engine = MustacheEngineBuilder.newBuilder() .registerHelpers(HelpersBuilder.empty() .add("log", LogHelper.builder().setDefaultLevel(Level.INFO) .setLoggerAdapter(adapter).build()) .build()) .build(); String msg = "Hello me!"; engine.compileMustache("log_helper1", "{{log \"" + msg + "\" level=\"WARN\"}}").render(null); assertEquals(Level.WARN, adapter.getLevels().get(0)); assertEquals(msg + " [log_helper1:1]", adapter.getMessages().get(0)); assertEquals(adapter.getParameters().get(0).length, 0); msg = "Hello {}!"; engine.compileMustache("log_helper2", "{{log this \"me\"}}") .render(msg); assertEquals(Level.INFO, adapter.getLevels().get(1)); assertEquals(msg + " [log_helper2:1]", adapter.getMessages().get(1)); assertEquals(adapter.getParameters().get(1).length, 1); engine = MustacheEngineBuilder.newBuilder() .registerHelpers(HelpersBuilder.empty() .add("log", LogHelper.builder().setAppendTemplateInfo(false) .setDefaultLevel(Level.INFO) .setLoggerAdapter(adapter).build()) .build()) .build(); engine.compileMustache("log_helper3", "{{log \"" + msg + "\"}}") .render(null); assertEquals(Level.INFO, adapter.getLevels().get(2)); assertEquals(msg, adapter.getMessages().get(2)); assertEquals(adapter.getParameters().get(2).length, 0); }
public LogHelper(LoggerAdapter adapter, Level defaultLevel, boolean appendTemplateInfo) { Checker.checkArgumentsNotNull(adapter, defaultLevel); this.defaultLevel = defaultLevel; this.adapter = adapter; this.appendTemplateInfo = appendTemplateInfo; }
LogHelper extends BasicValueHelper { public LogHelper(LoggerAdapter adapter, Level defaultLevel, boolean appendTemplateInfo) { Checker.checkArgumentsNotNull(adapter, defaultLevel); this.defaultLevel = defaultLevel; this.adapter = adapter; this.appendTemplateInfo = appendTemplateInfo; } }
LogHelper extends BasicValueHelper { public LogHelper(LoggerAdapter adapter, Level defaultLevel, boolean appendTemplateInfo) { Checker.checkArgumentsNotNull(adapter, defaultLevel); this.defaultLevel = defaultLevel; this.adapter = adapter; this.appendTemplateInfo = appendTemplateInfo; } LogHelper(LoggerAdapter adapter, Level defaultLevel,
            boolean appendTemplateInfo); }
LogHelper extends BasicValueHelper { public LogHelper(LoggerAdapter adapter, Level defaultLevel, boolean appendTemplateInfo) { Checker.checkArgumentsNotNull(adapter, defaultLevel); this.defaultLevel = defaultLevel; this.adapter = adapter; this.appendTemplateInfo = appendTemplateInfo; } LogHelper(LoggerAdapter adapter, Level defaultLevel,
            boolean appendTemplateInfo); @Override void execute(Options options); static Builder builder(); }
LogHelper extends BasicValueHelper { public LogHelper(LoggerAdapter adapter, Level defaultLevel, boolean appendTemplateInfo) { Checker.checkArgumentsNotNull(adapter, defaultLevel); this.defaultLevel = defaultLevel; this.adapter = adapter; this.appendTemplateInfo = appendTemplateInfo; } LogHelper(LoggerAdapter adapter, Level defaultLevel,
            boolean appendTemplateInfo); @Override void execute(Options options); static Builder builder();  }