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.Logger
logger
Log to log check logging level.protected StringBuilder
sb
string "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 void
close()
protected void
finalize()
void
flush()
protected void
log()
protected void
stripExtraNewLine()
void
write(char[] cbuf, int off, int len)
void
write(int c)
void
write(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:
write
in classFilterWriter
- Throws:
IOException
-
write
public void write(char[] cbuf, int off, int len) throws IOException
- Overrides:
write
in classFilterWriter
- Throws:
IOException
-
write
public void write(String str, int off, int len) throws IOException
- Overrides:
write
in classFilterWriter
- Throws:
IOException
-
flush
public void flush() throws IOException
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classFilterWriter
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterWriter
- Throws:
IOException
-
finalize
protected void finalize() throws Throwable
-
log
protected void log()
-
stripExtraNewLine
protected final void stripExtraNewLine()
-
-