use of ch.qos.logback.classic.turbo.TurboFilter in project sling by apache.
the class TurboFilterTracker method addingService.
@Override
public Object addingService(ServiceReference reference) {
TurboFilter tf = (TurboFilter) super.addingService(reference);
tf.setContext(loggerContext);
tf.start();
attachFilter(tf);
filters.put(reference, tf);
return tf;
}
use of ch.qos.logback.classic.turbo.TurboFilter in project sling by apache.
the class TurboFilterTracker method removedService.
@Override
public void removedService(ServiceReference reference, Object service) {
TurboFilter tf = (TurboFilter) service;
filters.remove(reference);
loggerContext.getTurboFilterList().remove(tf);
super.removedService(reference, service);
}
use of ch.qos.logback.classic.turbo.TurboFilter in project sling by apache.
the class SlingLogPanel method appendTurboFilterData.
private void appendTurboFilterData(final PrintWriter pw, final String consoleAppRoot, final LoggerStateContext ctx) {
if (ctx.loggerContext.getTurboFilterList().isEmpty()) {
return;
}
pw.println("<div class='table'>");
pw.println("<div class='ui-widget-header ui-corner-top buttonGroup'>Turbo Filters</div>");
pw.println("<table class='nicetable ui-widget'>");
pw.println("<thead class='ui-widget-header'>");
pw.println("<tr>");
pw.println("<th>Turbo Filter</th>");
pw.print("<th>");
// no need to escape
pw.print(getConfigColTitle(consoleAppRoot));
pw.println("</th>");
pw.println("</tr>");
pw.println("</thead>");
pw.println("<tbody class='ui-widget-content'>");
for (final TurboFilter tf : ctx.loggerContext.getTurboFilterList()) {
pw.println("<tr>");
pw.println("<td>");
pw.print(XmlUtil.escapeXml(getName(tf)));
pw.println("</td>");
pw.print("<td>");
pw.print(formatPid(consoleAppRoot, tf, ctx));
pw.println("</td>");
pw.println("</tr>");
}
pw.println("</tbody>");
pw.println("</table>");
pw.println("</div>");
}
use of ch.qos.logback.classic.turbo.TurboFilter in project cassandra by apache.
the class ThreadAwareSecurityManager method install.
public static void install() {
if (installed)
return;
System.setSecurityManager(new ThreadAwareSecurityManager());
Logger l = LoggerFactory.getLogger(ThreadAwareSecurityManager.class);
ch.qos.logback.classic.Logger logbackLogger = (ch.qos.logback.classic.Logger) l;
LoggerContext ctx = logbackLogger.getLoggerContext();
TurboFilterList turboFilterList = ctx.getTurboFilterList();
for (int i = 0; i < turboFilterList.size(); i++) {
TurboFilter turboFilter = turboFilterList.get(i);
if (turboFilter instanceof ReconfigureOnChangeFilter) {
ReconfigureOnChangeFilter reconfigureOnChangeFilter = (ReconfigureOnChangeFilter) turboFilter;
turboFilterList.set(i, new SMAwareReconfigureOnChangeFilter(reconfigureOnChangeFilter));
break;
}
}
installed = true;
}
use of ch.qos.logback.classic.turbo.TurboFilter in project sling by apache.
the class LogTracerTest method checkTracing.
@Test
public void checkTracing() throws Exception {
HttpServletRequest request = mock(SlingHttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
when(request.getParameter(LogTracer.PARAM_TRACER_CONFIG)).thenReturn("a.b.c;level=trace,a.b;level=debug");
activateTracer();
Level oldLevel = rootLogger().getLevel();
rootLogger().setLevel(Level.INFO);
FilterChain chain = new FilterChain() {
@Override
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
TurboFilter turboFilter = context.getService(TurboFilter.class);
assertNotNull(turboFilter);
getLogContext().addTurboFilter(turboFilter);
getLogger("a").info("a-info");
getLogger("a").debug("a-debug");
getLogger("a.b").info("a.b-info");
getLogger("a.b").debug("a.b-debug");
getLogger("a.b").trace("a.b-trace");
getLogger("a.b.c").debug("a.b.c-debug");
getLogger("a.b.c").trace("a.b.c-trace");
getLogger("a.b.c.d").trace("a.b.c.d-trace");
if (getLogger("a.b.c").isTraceEnabled()) {
getLogger("a.b.c").trace("a.b.c-trace2");
}
}
};
Filter filter = getFilter(true);
filter.doFilter(request, response, chain);
assertNull(context.getService(TurboFilter.class));
List<String> logs = logCollector.getLogs();
assertThat(logs, hasItem("a-info"));
assertThat(logs, not(hasItem("a-debug")));
assertThat(logs, hasItem("a.b-info"));
assertThat(logs, hasItem("a.b-debug"));
assertThat(logs, not(hasItem("a.b-trace")));
assertThat(logs, hasItem("a.b.c-debug"));
assertThat(logs, hasItem("a.b.c-trace"));
assertThat(logs, hasItem("a.b.c-trace2"));
assertThat(logs, hasItem("a.b.c.d-trace"));
rootLogger().setLevel(oldLevel);
}
Aggregations