Package org.smooks.testkit
Class StdoutToLog4jFilter
- java.lang.Object
-
- java.io.Writer
-
- java.io.FilterWriter
-
- org.smooks.testkit.StdoutToLog4jFilter
-
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
public class StdoutToLog4jFilter extends FilterWriter
StoutToLog4jFilter is just a simple FileWriter implementation that supresses output unless the log4j priority is set to debug. This class in indended to be used with hsql embedded server and to be used like this:Log targetLogger = LogFactory.getLog("org.hsqldb"); server.setLogWriter(new PrintWriter(new StdoutToLog4jFilter(server.getLogWriter(), targetLogger)));- Author:
- Daniel Bevenius
-
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.LoggerloggerLog to log check logging level.protected StringBuildersbstring "buffer"-
Fields inherited from class java.io.FilterWriter
out
-
-
Constructor Summary
Constructors Constructor Description StdoutToLog4jFilter(Writer writer)StdoutToLog4jFilter(Writer writer, org.slf4j.Logger logger)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()protected voidfinalize()voidflush()protected voidlog()protected voidstripExtraNewLine()voidwrite(char[] cbuf, int off, int len)voidwrite(int c)voidwrite(String str, int off, int len)
-
-
-
Field Detail
-
logger
protected org.slf4j.Logger logger
Log to log check logging level.
-
sb
protected final StringBuilder sb
string "buffer"
-
-
Method Detail
-
write
public void write(int c) throws IOException- Overrides:
writein classFilterWriter- Throws:
IOException
-
write
public void write(char[] cbuf, int off, int len) throws IOException- Overrides:
writein classFilterWriter- Throws:
IOException
-
write
public void write(String str, int off, int len) throws IOException
- Overrides:
writein classFilterWriter- Throws:
IOException
-
flush
public void flush() throws IOException- Specified by:
flushin interfaceFlushable- Overrides:
flushin classFilterWriter- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterWriter- Throws:
IOException
-
finalize
protected void finalize() throws Throwable
-
log
protected void log()
-
stripExtraNewLine
protected final void stripExtraNewLine()
-
-