List of usage examples for org.apache.commons.io.output ProxyWriter ProxyWriter
public ProxyWriter(Writer proxy)
From source file:nl.armatiek.xslweb.saxon.log.Slf4JLogger.java
@Override public StreamResult asStreamResult() { Writer w = new ProxyWriter(new StringWriter()) { @Override/*w ww .j a v a 2s . c om*/ public void flush() throws IOException { logger.info(out.toString()); super.flush(); } }; return new StreamResult(w); }
From source file:nl.armatiek.xslweb.web.servlet.XSLWebServlet.java
private Destination getDestination(WebApp webApp, Destination destination, PipelineStep step) { if (webApp.getDevelopmentMode() && step.getLog()) { StringWriter sw = new StringWriter(); sw.write("----------\n"); sw.write("OUTPUT OF STEP: \"" + step.getName() + "\":\n"); Serializer debugSerializer = webApp.getProcessor().newSerializer(new ProxyWriter(sw) { @Override/*from www . j av a 2s.c o m*/ public void flush() throws IOException { logger.debug(out.toString()); } }); debugSerializer.setOutputProperty(Serializer.Property.METHOD, "xml"); debugSerializer.setOutputProperty(Serializer.Property.INDENT, "yes"); if (destination instanceof XdmDestination) { destination = new TeeSourceDestination((XdmDestination) destination, debugSerializer); } else { destination = new TeeDestination(destination, debugSerializer); } } return destination; }
From source file:org.apereo.portal.utils.web.PortletHttpServletResponseWrapper.java
@Override public PrintWriter getWriter() throws IOException { if (this.printWriter == null) { if (logger.isDebugEnabled()) { this.printWriter = new PrintWriter(new StringWriter() { @Override//from w w w . j a v a 2s .c o m public void close() throws IOException { super.close(); final String data = this.toString(); if (data.length() > 0) { logger.warn("Ignored {} chars written to PrintWriter by {}\n\n{}", new Object[] { data.length(), portletWindow, data }); } } }); } else { this.printWriter = new PrintWriter(new ProxyWriter(NullWriter.NULL_WRITER) { private long count = 0; @Override public void close() throws IOException { super.close(); if (count > 0) { logger.warn( "Ignored {} chars written to PrintWriter by {}, turn on DEBUG logging to see the output", count, portletWindow); } } @Override protected void afterWrite(int n) throws IOException { count += n; } }); } } return this.printWriter; }