MavenColorRenderer extends PatternRenderer { @Override protected void renderLevel(Event event, StringBuilder buff) { if (!isActivated) { buff.append("["); super.renderLevel(event, buff); buff.append("] "); return; } if (event.getLevel() == ERROR) { buff.append(ansi().fgBright(RED).bold().a("[" + ERROR.name() + "]").reset()) .append(" "); return; } if (LogLevelActivation.isShown()) { if (event.getLevel() == WARN) { buff.append(ansi().fgBright(YELLOW).bold().a("[WARNING]").reset()) .append(" "); } else { buff.append("["); super.renderLevel(event, buff); buff.append("] "); } } } MavenColorRenderer();  MavenColorRenderer(boolean isActivated);  MavenColorRenderer(String pattern);  MavenColorRenderer(String pattern, boolean isActivated);   }
@Test public void do_not_render_level_when_colorization_is_activated() { StringBuilder result = new StringBuilder(); new MavenColorRenderer(true).renderLevel(anyEvent(), result); assertThat(result.toString()).isEmpty(); }
@Test public void render_level_when_colorization_is_activated_and_property_equals_false() { System.setProperty("maven.color.hide.level", "false"); StringBuilder result = new StringBuilder(); new MavenColorRenderer(true).renderLevel(event(INFO, "message"), result); assertThat(result.toString()).isEqualTo("[INFO] "); }
@Test public void do_not_render_level_when_colorization_is_activated_and_property_equals_true() { System.setProperty("maven.color.hide.level", "true"); StringBuilder result = new StringBuilder(); new MavenColorRenderer(true).renderLevel(event(INFO, "message"), result); assertThat(result.toString()).isEmpty(); }
@Test public void render_level_when_colorization_is_deactivated() { StringBuilder result = new StringBuilder(); new MavenColorRenderer(false).renderLevel(event(INFO, "message"), result); assertThat(result.toString()).isEqualTo("[INFO] "); }