org.apache.sling.scripting.core.impl
Class LogWriter

java.lang.Object
  extended by java.io.Writer
      extended by org.apache.sling.scripting.core.impl.LogWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable

public class LogWriter
extends Writer

The LogWriter is a simple Writer which writes lines of data to a given SLF4J Logger. Data is gathered in an internal buffer until the flush() method is called or until a CR or LF character is encountered in the data to be written.


Field Summary
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
LogWriter(org.slf4j.Logger logger)
          Creates a writer based on the given logger.
 
Method Summary
 void close()
          Just calls flush()
 void flush()
          Writes any data conained in the buffer to the logger as an error message.
 void write(char[] cbuf, int off, int len)
          Writes the indicated characters to the internal buffer, flushing the buffer on any occurrence of a CR of LF.
 void write(int c)
          Writes the character to the internal buffer unless the character is a CR or LF in which case the buffer is written to the logger as an error message.
 
Methods inherited from class java.io.Writer
append, append, append, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogWriter

public LogWriter(org.slf4j.Logger logger)
Creates a writer based on the given logger.

Method Detail

write

public void write(int c)
Writes the character to the internal buffer unless the character is a CR or LF in which case the buffer is written to the logger as an error message.

Overrides:
write in class Writer

write

public void write(char[] cbuf,
                  int off,
                  int len)
Writes the indicated characters to the internal buffer, flushing the buffer on any occurrence of a CR of LF.

Specified by:
write in class Writer

flush

public void flush()
Writes any data conained in the buffer to the logger as an error message.

Specified by:
flush in interface Flushable
Specified by:
flush in class Writer

close

public void close()
Just calls flush()

Specified by:
close in interface Closeable
Specified by:
close in class Writer


Copyright © 2007-2013 The Apache Software Foundation. All Rights Reserved.